LoginModuleCacheObject lm = null;
synchronized (LoginService.class) {
try {
for (Iterator iter = getRealms().iterator(); iter.hasNext();) {
SecurityRealm securityRealm = (SecurityRealm) iter.next();
if (realmName.equals(securityRealm.getRealmName())) {
AppConfigurationEntry entry = securityRealm.getAppConfigurationEntry();
final String finalClass = entry.getLoginModuleName();
LoginModule module = (LoginModule) AccessController.doPrivileged(new java.security.PrivilegedExceptionAction() {
public Object run() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
return Class.forName(finalClass, true, classLoader).newInstance();
}
});
Subject subject = new Subject();
CallbackProxy callback = new CallbackProxy();
module.initialize(subject, callback, new HashMap(), entry.getOptions());
lm = allocateLoginModuleCacheObject(securityRealm.getMaxLoginModuleAge());
lm.setRealmName(realmName);
lm.setLoginModule(module);
lm.setSubject(subject);
lm.setCallbackHandler(callback);