Reputation: 121
I have an unusual super class.
it instantiates the subclass using reflection, and calls a subclass method in the main method
ie, String processor= System.getProperty(PROCESSOR_CLASS); sub = (ClassName) class.forName(processor).newInstance();
sub.init(props);
I am writing a wrapper (sub) for the super class that will also be abstract, and will be used as a base class by a large number of subclasses.
The problem I have is that props contains sensitive information. I need to prevent a subclass that extends from sub from using reflection to access the props.
Can anyone give me an example of doing this using the Java security manager, or some other method?
Thanks very much for your help
Upvotes: 0
Views: 134
Reputation: 1146
By default the JVM does not have a SecurityManager available. A security manager could be installed either by passing the following option to the jvm
-Djava.security.manager
or by setting one in the code
System.setSecurityManager(new SecurityManager());
Upvotes: 1