Re: [Aglets-users] Fwd: Urgent need help! Problem with file access permissions-Aglets
Status: Beta
Brought to you by:
cat4hire
|
From: Thomas H. <max...@us...> - 2012-03-31 23:24:03
|
Could it be that the code is not in any of those three codebases? I know two ways to find out. First: comment out the file access call that is causing the exception, so you have an agent that can run. Launch it in Tahiti the same way as before, except this time there will be no exception. Select the aglet in the main window and press the Info' button. Use the value of the codeBase field to detemine which section, if any, the aglet belongs to. I'd be curious to know that value, too. Second method: Make three tries to see which of the three sections applies to this aglet: make one section at a time grant only permission 'java.security.AllPermission "*", "*";' and keep the other two as until now. If the aglet works only one time of the three, you know which section the codeBase belongs to and then you need to make sure the PropertyPermission grant is written correctly. You could always download aglets-2.5-gamma, load an aglet through a file:// URL and be sure that it is the "file" section where the permission needs to go. Hope this helps, Thomas On Sat, Mar 31, 2012 at 21:27, shruti nagani <shr...@gm...> wrote: > Hi, > > I just added the permissions to all the sections, still getting the same > result. I have attached a jpeg which shows the stacktrace. > > Regards > Shruti > > > On Sun, Apr 1, 2012 at 12:55 AM, shruti nagani <shr...@gm...> > wrote: >> >> Hi Thomas, >> >> Thank you for the prompt reply. I think I understood what you're trying to >> say, I still have one doubt, there are 3 codebase sections in the >> aglets.policy file (atp, http, file), to which should I give >> the necessary permissions. >> >> >> Thanks again! >> >> Regards >> Shruti >> >> >> On Sun, Apr 1, 2012 at 12:27 AM, Thomas Herlea >> <max...@us...> wrote: >>> >>> (Forgot to send this to the list) >>> >>> >>> ---------- Forwarded message ---------- >>> From: Thomas Herlea <max...@us...> >>> Date: Sat, Mar 31, 2012 at 19:23 >>> Subject: Re: Urgent need help! Problem with file access >>> permissions-Aglets >>> To: shruti nagani <shr...@gm...> >>> >>> >>> Dear Shruti, >>> >>> The security exception you got does not mean the aglet is prevented >>> from accessing the file, but that it is prevented from finding out >>> what the current directory is. That is what the 'user.dir' property >>> stores. See >>> http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html >>> for a list of system properties. Perhaps you are using a relative path >>> to your file in your code and therefore at some point the method for >>> accessing the file has to first look up the current directory, at >>> which point it throws the exception. >>> >>> You can use the AccessControlException messages to guide you in adding >>> the required permission to the 'aglets.policy' file. It mentions the >>> missing permission type, 'java.util.PropertyPermission', so you should >>> look it up to see how it is granted >>> >>> (http://docs.oracle.com/javase/7/docs/technotes/guides/security/permissions.html#PropertyPermission). >>> You will discover the parameters available when granting it. These >>> parameters are specific to the permission type, so you really need to >>> look in yhe documentation. For PropertyPermission you specify a >>> pattern to match one or more properties, in your case 'user.dir' or >>> something with wildcards which covers 'user.dir', too. Then you >>> provide in the grant of a PropertyPermission an action about the >>> property or properties matching the first parameter. In your case >>> 'read' is needed, but you also can grant a 'write' permission or both, >>> using the list syntax specified in the documentation. >>> >>> I think it is an interesting problem to determine during development >>> which permissions an aglet may need. Does anyone know a more automated >>> method than looking up in the API documentation which >>> AccessControlExceptions every method call might throw? The guide >>> linked to above does have a section "Methods and the Permissions They >>> Require", but if the method listed there is called internally by >>> another standard library method which you call, I don't know if it is >>> easy to determine what exceptions may be thrown indirectly like that. >>> >>> Good luck! >>> >>> Thomas >>> >>> >>> >>> On Sat, Mar 31, 2012 at 16:28, shruti nagani <shr...@gm...> >>> wrote: >>> > >>> > Hi, >>> > >>> > I am accessing a file on my system from an aglet whose code is also on >>> > my system >>> > I am getting the following exception: >>> > >>> > java.security.AccessControlException:access denied >>> > ("java.util.PropertyPermission" "user.dir" "read") >>> > >>> > at java.security...etc etc >>> > >>> > >>> > I edited the aglets.policy in $HOME/.aglets/security and appended the >>> > following line >>> > >>> > permission java.io.FilePermission >>> > "C:\\Users\\new\\Documents\\arffs\\bayes_labeled.arff", "read"; >>> > >>> > to all 3 sections, (atp, http and file) >>> > >>> > bayes_labeled.arff is the file I need to read >>> > >>> > I am still getting the same exception. Please someone tell what am I >>> > doing wrong here? >>> > >>> > I'll be very grateful! Have been stuck on this for the past week. >>> > >>> > Thanks a tonne in advance!! >>> > >>> > Shruti >>> >>> >>> ------------------------------------------------------------------------------ >>> This SF email is sponsosred by: >>> Try Windows Azure free for 90 days Click Here >>> http://p.sf.net/sfu/sfd2d-msazure >>> _______________________________________________ >>> Aglets-users mailing list >>> Agl...@li... >>> https://lists.sourceforge.net/lists/listinfo/aglets-users >> >> >> >> > > > > -- > Shruti Nagani > B Tech IV Year > Computer Science and Engineering Integrated Dual Degree > IIT Roorkee |