• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubt regarding AccessController.doPrivileged() usage

 
Greenhorn
Posts: 2
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am trying understand the basics of java security and AccessController.doPrivileged() usage
i started with a sample program

if i try to run above code using default security manage i am getting AccessControlException
My stacktrace is


from one other forum , i saw one comment
"When you use AccessController.doPrivileged to invoke those operations, the operation is executed with all the rights(permissions) of your protection domain. Hence if your code has enough rights only then it could execute those operations."

http://stackoverflow.com/questions/2233761/when-should-accesscontroller-doprivileged-be-used

What i understood from above is ,if we try to access system property from AccessController.doPrivileged() it should work ,Please correct me .. i think i am wrong ..

Kindly help me to get a clear picture of

1)when we need to use AccessController.doPrivileged() ?.(if SecurityManager is present we use AccessController.doPrivileged why this is failing in above example )
2) what is the real advantage we are getting by using AccessController and PrivilegedAction?.
3) Do we need custom policy file for above example to work ?

Thanks,
Paul



 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch
Don’t know myself, but I think your question is too difficult for “beginning”, so shall move it. You might get more attention because your question will appear twice for a few days.
 
Paul Erric
Greenhorn
Posts: 2
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ritchie,

Thanks for moving my question to correct category. Could you please help me to get a solution?
Still now haven't got any comment regarding this.

Ranchers please help me...
 
reply
    Bookmark Topic Watch Topic
  • New Topic