Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How set Policy.Provider to be your class?

843811Jul 22 2001 — edited Sep 30 2001
I have made a class EJBPolicy that extends java.security.Policy (i'm using jdk1.4), and overrides the abstract methods. Then in my java.home folder, I changed the file "java.security" so the property "policy.provider" now reads "EJBPolicy". I also changed the "java.security" file in my installation folder (just to be sure). I do not have that file in "user.home". I also added the EJBPolicy to the classpath (added both the folder it is in, as well as the file itself). Then I ran my application like this:
java -classpath D:\JAAS;D:\JAAS\M -Djava.security.manager -Djava.security.auth.login.config=jaas.conf -Djava.security.policy=jaasazn.policy JaasAzn

The "jaasazn.policy" file gives me the ability to get/set the Policy. I added a method to my policy class called getName(), which returns "EJBPolicy". However, when I do this in my app:
System.out.println(((EJBPolicy)thePolicy).getName());
it results in the error:
java.lang.ClassCastException: sun.security.provider.PolicyFile

If I call Policy.setPolicy() and set it to my class EJBPolicy, then it works. But I thought I was able to make my class the default polciy class. What am I doing wrong?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 28 2001
Added on Jul 22 2001
5 comments
83 views