Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Extending SecurityManager gives ExceptionInInitializerError

Reply
Thread Tools

Extending SecurityManager gives ExceptionInInitializerError

 
 
Mike Matthews
Guest
Posts: n/a
 
      07-23-2003
I'm investigating the java security features for possible use in an
application I am writing.

One area that I have been experimenting with is extending the
SecurityManager class and overriding the checkPermission(Permission
perm) method.
When I do this and call

System.setSecurityManager( new TestSecurityManager() );

I get the following exception:


java.lang.ExceptionInInitializerError

at java.lang.System.setSecurityManager0(System.java:2 42)

at java.lang.System.setSecurityManager(System.java:21 1)

at test.TestMain.main(TestMain.java:45)

Caused by: java.security.AccessControlException: access denied
(java.security.SecurityPermission
getProperty.networkaddress.cache.ttl)

at java.security.AccessControlContext.checkPermission (AccessControlContext.java:270)

at java.security.AccessController.checkPermission(Acc essController.java:401)

at java.lang.SecurityManager.checkPermission(Security Manager.java:542)

at test.TestSecurityManager.checkPermission(TestSecur ityManager.java:40)

at java.security.Security.getProperty(Security.java:1 213)

at sun.net.InetAddressCachePolicy$1.run(InetAddressCa chePolicy.java:81)

at java.security.AccessController.doPrivileged(Native Method)

at sun.net.InetAddressCachePolicy.<clinit>(InetAddres sCachePolicy.java:77)

... 3 more

java.security.AccessControlException: access denied
(java.util.logging.LoggingPermission control)

at java.security.AccessControlContext.checkPermission (AccessControlContext.java:270)

at java.security.AccessController.checkPermission(Acc essController.java:401)

at java.lang.SecurityManager.checkPermission(Security Manager.java:542)

at test.TestSecurityManager.checkPermission(TestSecur ityManager.java:40)

at java.util.logging.LogManager.checkAccess(LogManage r.java:759)

at java.util.logging.LogManager.reset(LogManager.java :466)

at java.util.logging.LogManager$Cleaner.run(LogManage r.java:175)

Exception in thread "main"


If I grant myself access to java.security.SecurityPermission
getProperty.networkaddress.cache.ttl
I get:

java.lang.ExceptionInInitializerError

at java.lang.System.setSecurityManager0(System.java:2 42)

at java.lang.System.setSecurityManager(System.java:21 1)

at test.TestMain.main(TestMain.java:45)

Caused by: java.security.AccessControlException: access denied
(java.util.PropertyPermission sun.net.inetaddr.ttl read)

at java.security.AccessControlContext.checkPermission (AccessControlContext.java:270)

at java.security.AccessController.checkPermission(Acc essController.java:401)

at java.lang.SecurityManager.checkPermission(Security Manager.java:542)

at test.TestSecurityManager.checkPermission(TestSecur ityManager.java:40)

at java.lang.SecurityManager.checkPropertyAccess(Secu rityManager.java:1291)

at java.lang.System.getProperty(System.java:572)

at java.lang.Integer.getInteger(Integer.java:772)

at java.lang.Integer.getInteger(Integer.java:689)

at sun.security.action.GetIntegerAction.run(GetIntege rAction.java:90)

at java.security.AccessController.doPrivileged(Native Method)

at sun.net.InetAddressCachePolicy.<clinit>(InetAddres sCachePolicy.java:94)

... 3 more

java.security.AccessControlException: access denied
(java.util.logging.LoggingPermission control)

at java.security.AccessControlContext.checkPermission (AccessControlContext.java:270)

at java.security.AccessController.checkPermission(Acc essController.java:401)

at java.lang.SecurityManager.checkPermission(Security Manager.java:542)

at test.TestSecurityManager.checkPermission(TestSecur ityManager.java:40)

at java.util.logging.LogManager.checkAccess(LogManage r.java:759)

at java.util.logging.LogManager.reset(LogManager.java :466)

at java.util.logging.LogManager$Cleaner.run(LogManage r.java:175)

Exception in thread "main"


If I grant myself java.security.AllPermission then the problem goes
away but this seems pointless.

I get these exceptions even if my overriding method simply calls:

super().checkPermission(perm);

which is what's really bothering me.

If I choose not to override checkPermission(Permission perm) at all in
my SecurityManager class then I get none of these exceptions.

I'm new to the java security packages so any information would be
gratefully received.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SecurityManager 99 problem Dave Croft Computer Support 0 01-10-2007 10:26 AM
Extending SecurityManager oziris Java 2 12-07-2005 05:15 PM
LinkageError and ExceptionInInitializerError Boaz Java 2 11-08-2004 03:55 PM
Error :could not initialize interface awt - Exception:java.lang.ExceptionInInitializerError Stefan Becker Java 0 11-18-2003 11:30 AM
Error :could not initialize interface awt - Exception: java.lang.ExceptionInInitializerError Stefan Becker Java 0 11-17-2003 10:54 AM



Advertisments