public AuthenticationProvider(final SecurityRealm securityRealm) {
this.securityRealm = securityRealm;
}
AuthorizingCallbackHandler getCallbackHandler() {
final DomainCallbackHandler callbackHandler = securityRealm.getCallbackHandler();
return new AuthorizingCallbackHandler() {
Subject subject;
@Override
public Class<Callback>[] getSupportedCallbacks() {
return callbackHandler.getSupportedCallbacks();
}
@Override
public boolean isReady() {
return callbackHandler.isReady();
}
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
if (contains(SubjectCallback.class, callbackHandler.getSupportedCallbacks())) {
Callback[] newCallbacks = new Callback[callbacks.length + 1];
System.arraycopy(callbacks, 0, newCallbacks, 0, callbacks.length);
SubjectCallback subjectCallBack = new SubjectCallback();
newCallbacks[newCallbacks.length - 1] = subjectCallBack;
callbackHandler.handle(newCallbacks);
subject = subjectCallBack.getSubject();
} else {
callbackHandler.handle(callbacks);
}
}
@Override
public SubjectUserInfo createSubjectUserInfo(Principal userPrincipal) throws IOException {