if(this.securityManagement == null)
throw new IllegalStateException("SecurityManagement has not been injected");
Subject subject = new Subject();
//Validate the caller
Principal principal = SecurityActions.getPrincipal();
AuthenticationManager authenticationManager = securityManagement.getAuthenticationManager(securityDomainName);
if(authenticationManager == null)
{
String defaultSecurityDomain = SecurityConstants.DEFAULT_APPLICATION_POLICY;
if(log.isTraceEnabled())
{
log.trace("AuthenticationManager for "
+ securityDomainName + " not found. Using " + defaultSecurityDomain);
}
authenticationManager =
securityManagement.getAuthenticationManager(defaultSecurityDomain);
}
if(authenticationManager.isValid(principal,
SecurityActions.getCredential(), subject) == false)
throw new SecurityException("Unauthenticated caller:" + principal);
return subject;
}