You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Chris Giordano <gi...@more.net> on 2003/06/24 21:21:27 UTC

[PATCH] PersistentFieldDefaultImpl.java

Greetings,

I've been working with OJB configured with Tomcat using the Java 
Security Manager and have run into a piece of code that requires the use 
of the doPrivileged API but is missing.  

In the file: 
 /org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDefaultImpl.java 
, the following method uses the doPrivileged API at the top of the 
function but the code in the finally block also needs to be marked as 
privileged code.  The attached file is a cvs diff that wraps the code in 
the finally block using an anonymous inner class.

 public synchronized Object get(Object obj) throws MetadataException
 {
        boolean before = getField().isAccessible();
        AccessController.doPrivileged(setAccessibleAction);
         ...

         try
         {
              ...
          }
          catch(...)
          {
               ...
           }
           finally
           {
               field.setAccessible(before);
            }
  }

Thanks.

Chris Giordano
giordano@more.net

Re: [PATCH] PersistentFieldDefaultImpl.java

Posted by Armin Waibel <ar...@code-au-lait.de>.
patch is in CVS.
Thanks!

regards,
Armin

----- Original Message -----
From: "Chris Giordano" <gi...@more.net>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Thursday, June 26, 2003 12:24 AM
Subject: Re: [PATCH] PersistentFieldDefaultImpl.java


> I submitted this patch yesterday but have now put it into scarab as
well.
>
> Refer to Patch ID: OJB184
>
> Chris Giordano
> giordano@more.net
>
>
> Chris Giordano wrote:
>
> > Greetings,
> >
> > I've been working with OJB configured with Tomcat using the Java
> > Security Manager and have run into a piece of code that requires the
> > use of the doPrivileged API but is missing.
> > In the file:
> >
/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDefaultImpl.j
ava
> > , the following method uses the doPrivileged API at the top of the
> > function but the code in the finally block also needs to be marked
as
> > privileged code.  The attached file is a cvs diff that wraps the
code
> > in the finally block using an anonymous inner class.
> >
> > public synchronized Object get(Object obj) throws MetadataException
> > {
> >        boolean before = getField().isAccessible();
> >        AccessController.doPrivileged(setAccessibleAction);
> >         ...
> >
> >         try
> >         {
> >              ...
> >          }
> >          catch(...)
> >          {
> >               ...
> >           }
> >           finally
> >           {
> >               field.setAccessible(before);
> >            }
> >  }
> >
> > Thanks.
> >
> > Chris Giordano
> > giordano@more.net
> >
>
>-----------------------------------------------------------------------
-
> >
> >Index: PersistentFieldDefaultImpl.java
> >===================================================================
> >RCS file:
/home/cvspublic/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/fiel
daccess/PersistentFieldDefaultImpl.java,v
> >retrieving revision 1.16
> >diff -r1.16 PersistentFieldDefaultImpl.java
> >209c209,217
> ><             field.setAccessible(before);
> >---
> >
> >
> >>            final boolean fbefore = before;
> >>            AccessController.doPrivileged( new PrivilegedAction()
> >>            {
> >>                public Object run()
> >>                {
> >>                    field.setAccessible(fbefore);
> >>                    return null;
> >>                }
> >>            });
> >>
> >>
> >
> >
> >
>
>-----------------------------------------------------------------------
-
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >For additional commands, e-mail: ojb-user-help@db.apache.org
> >
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>




---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: [PATCH] PersistentFieldDefaultImpl.java

Posted by Chris Giordano <gi...@more.net>.
I submitted this patch yesterday but have now put it into scarab as well.

Refer to Patch ID: OJB184

Chris Giordano
giordano@more.net


Chris Giordano wrote:

> Greetings,
>
> I've been working with OJB configured with Tomcat using the Java 
> Security Manager and have run into a piece of code that requires the 
> use of the doPrivileged API but is missing. 
> In the file: 
> /org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDefaultImpl.java 
> , the following method uses the doPrivileged API at the top of the 
> function but the code in the finally block also needs to be marked as 
> privileged code.  The attached file is a cvs diff that wraps the code 
> in the finally block using an anonymous inner class.
>
> public synchronized Object get(Object obj) throws MetadataException
> {
>        boolean before = getField().isAccessible();
>        AccessController.doPrivileged(setAccessibleAction);
>         ...
>
>         try
>         {
>              ...
>          }
>          catch(...)
>          {
>               ...
>           }
>           finally
>           {
>               field.setAccessible(before);
>            }
>  }
>
> Thanks.
>
> Chris Giordano
> giordano@more.net
>
>------------------------------------------------------------------------
>
>Index: PersistentFieldDefaultImpl.java
>===================================================================
>RCS file: /home/cvspublic/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/fieldaccess/PersistentFieldDefaultImpl.java,v
>retrieving revision 1.16
>diff -r1.16 PersistentFieldDefaultImpl.java
>209c209,217
><             field.setAccessible(before);
>---
>  
>
>>            final boolean fbefore = before;
>>            AccessController.doPrivileged( new PrivilegedAction() 
>>            {
>>                public Object run() 
>>                {
>>                    field.setAccessible(fbefore);
>>                    return null;
>>                }
>>            });
>>    
>>
>
>  
>
>------------------------------------------------------------------------
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>