Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 92749 invoked from network); 25 Jun 2004 17:35:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 25 Jun 2004 17:35:19 -0000 Received: (qmail 59994 invoked by uid 500); 25 Jun 2004 17:35:30 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 59927 invoked by uid 500); 25 Jun 2004 17:35:29 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 59897 invoked by uid 500); 25 Jun 2004 17:35:28 -0000 Received: (qmail 59887 invoked by uid 99); 25 Jun 2004 17:35:28 -0000 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Fri, 25 Jun 2004 10:35:26 -0700 Received: (qmail 92709 invoked by uid 1797); 25 Jun 2004 17:35:12 -0000 Date: 25 Jun 2004 17:35:12 -0000 Message-ID: <20040625173512.92708.qmail@minotaur.apache.org> From: tomdz@apache.org To: db-ojb-cvs@apache.org Subject: cvs commit: db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess PersistentFieldAutoProxyImpl.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N tomdz 2004/06/25 10:35:12 Modified: src/java/org/apache/ojb/broker/metadata/fieldaccess PersistentFieldAutoProxyImpl.java Log: Now uses PersistentFieldDirectAccessImpl if a concrete field is present and we're allowed to directly access the field Revision Changes Path 1.10 +34 -4 db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldAutoProxyImpl.java Index: PersistentFieldAutoProxyImpl.java =================================================================== RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldAutoProxyImpl.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- PersistentFieldAutoProxyImpl.java 8 May 2004 08:45:01 -0000 1.9 +++ PersistentFieldAutoProxyImpl.java 25 Jun 2004 17:35:12 -0000 1.10 @@ -15,6 +15,9 @@ * limitations under the License. */ +import java.lang.reflect.Field; +import java.lang.reflect.Member; + import org.apache.commons.beanutils.DynaBean; import org.apache.ojb.broker.metadata.MetadataException; import org.apache.ojb.broker.util.ClassHelper; @@ -92,6 +95,17 @@ */ private AbstractPersistentField getDirectImpl() throws MetadataException { + return getFieldImpl(PersistentFieldDirectAccessImpl.class); + } + + /** + * Returns an instance of the privileged field-direct handler. + * + * @return The handler instance + * @throws MetadataException If the handler could not be found, or cannot handle the field + */ + private AbstractPersistentField getPrivilegedDirectImpl() throws MetadataException + { return getFieldImpl(PersistentFieldPrivilegedImpl.class); } @@ -136,15 +150,31 @@ /* * this switches on a series of exceptions. Sadly, it is the only real way to detect - * which one works. The cache should manage things so this chain only need be called - * once per field. --Brian + * which one works. --Brian */ try { - AbstractPersistentField.computeField(rootObjectType, fieldName, isNestedField(), false); + Field field = AbstractPersistentField.computeField(rootObjectType, fieldName, isNestedField(), false); + SecurityManager manager = System.getSecurityManager(); - wrapped = getDirectImpl(); + // ok we have a real field, + // however, for non-public fields we have to check whether we're allowed to access + // it directly; this is guarded by the security manager, so we ask it + try + { + if ((manager != null) && !field.isAccessible()) + { + // this throws an exception if we're not allowed to the access the declared members + manager.checkMemberAccess(field.getDeclaringClass(), Member.DECLARED); + } + // no security manager or we're allowed to access the field + wrapped = getDirectImpl(); + } + catch (SecurityException ex) + { + wrapped = getPrivilegedDirectImpl(); + } hasBeenDetermined = true; return wrapped; } --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org