| John McGrath 2005-06-03, 4:00 pm |
| I have an idea how the AccessController class is supposed to be used, but
I have not written much code that needs to worry about security and I want
to be sure on this.
Typically, I would have just used the System.getProperty() method to get
the value of a System property, but I recently came across some code that
used doPrivileged() with a GetPropertyAction to get the "line.separator"
system property:
String separator = (String) AccessController.doPrivileged(
new GetPropertyAction( "line.separator" ) );
As I understand it, this would make sense if the code that needs to get
the property has PropertyPermission for this property, but the code that
calls it does not. Is that correct? Assuming that is the case, do you
think such as scenario would be at all common? Under what circumstances
would it make sense to use a GetPropertyAction?
--
Regards,
John McGrath
|