Methods Summary |
---|
private static com.sun.enterprise.security.ClientSecurityContext | generateDefaultSecurityContext()
final String PRINCIPAL_NAME = "auth.default.principal.name";
final String PRINCIPAL_PASS = "auth.default.principal.password";
ServerConfiguration config = ServerConfiguration.getConfiguration();
String username = config.getProperty(PRINCIPAL_NAME, "guest");
String password = config.getProperty(PRINCIPAL_PASS, "guest123");
synchronized (ClientSecurityContext.class) {
// login & all that stuff..
try {
final Subject subject = new Subject();
final PasswordCredential pc = new PasswordCredential(username,
password, "default");
AppservAccessController.doPrivileged(new PrivilegedAction() {
public java.lang.Object run() {
subject.getPrivateCredentials().add(pc);
return null;
}
});
// we do not need to generate any credential as authorization
// decisions are not being done on the appclient side.
ClientSecurityContext defaultCSC =
new ClientSecurityContext(username, subject);
setCurrent(defaultCSC);
return defaultCSC;
} catch(Exception e) {
_logger.log(Level.SEVERE,
"java_security.gen_security_context", e);
return null;
}
}
|
public java.security.Principal | getCallerPrincipal()This method returns the caller principal.
This information may be redundant since the same information
can be inferred by inspecting the Credentials of the caller.
return initiator;
|
public static com.sun.enterprise.security.ClientSecurityContext | getCurrent()This method gets the SecurityContext stored here. If using a
per-thread authentication model, it gets the context from
Thread Local Store (TLS) of the current thread. If not using a
per-thread authentication model, it gets the singleton context.
if (isPerThreadAuth) {
return (ClientSecurityContext) localCsc.get();
} else {
return sharedCsc;
}
|
public javax.security.auth.Subject | getSubject()
return subject;
|
public static com.sun.enterprise.security.ClientSecurityContext | init()Initialize the SecurityContext & handle the unauthenticated
principal case
ClientSecurityContext sc = getCurrent();
if (sc == null) { // there is no current security context
// create a default one if
sc = generateDefaultSecurityContext();
}
return sc;
|
public static void | setCurrent(com.sun.enterprise.security.ClientSecurityContext sc)This method sets the SecurityContext to be stored here.
if (isPerThreadAuth) {
localCsc.set(sc);
} else {
sharedCsc = sc;
}
|
public java.lang.String | toString()
return "ClientSecurityContext[ " + "Initiator: " + initiator +
"Subject " + subject + " ]";
|