}
}
private boolean authenticate(SecurityContext context) {
SecurityContextUtil util = context.getUtil();
SubjectInfo subjectInfo = context.getSubjectInfo();
Subject subject = new Subject();
Principal principal = util.getUserPrincipal();
Object credential = util.getCredential();
boolean authenticated = false;
if (principal == null) {
Identity unauthenticatedIdentity = getUnauthenticatedIdentity();
subjectInfo.addIdentity(unauthenticatedIdentity);
subject.getPrincipals().add(unauthenticatedIdentity.asPrincipal());
authenticated = true;
}
if (authenticated == false) {
AuthenticationManager authenticationManager = context.getAuthenticationManager();
authenticated = authenticationManager.isValid(principal, credential, subject);
}
if (authenticated == true) {
subjectInfo.setAuthenticatedSubject(subject);
}
return authenticated;
}