I need to ensure that a method from a class is only executed by selected methods from different packages.
package myApp.security;
public class SecurityStuff{
public static final SecurityStuff security = new SecurityStuff();
public KeyStore getKeyStore(){
//if invoked by MySock.getTLSServerSocket()
return keyStore;
//if not, should return null
}
}
package myApp.socks;
public class MySock{
public void getTLSServerSocket(){
KeyStore keyStore = SecurityStuff.security.getKeyStore();
}
}
With the 2 classes above, how do I ensure that SecurityStuff.getKeyStore()
would return the KeyStore
iff it is from the classes & methods that I allow?
Please take into account that the jar would be obfuscated later.