private static class PlainServerCallbackHandler implements CallbackHandler {
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
ExternalAuthenticationCallback ac = null;
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof ExternalAuthenticationCallback) {
ac = (ExternalAuthenticationCallback) callbacks[i];
break;
} else {
throw new UnsupportedCallbackException(callbacks[i]);
}
}
if (ac != null) {
PasswdAuthenticationProvider provider =
AuthenticationProviderFactory.getAuthenticationProvider(ac.getAuthMethod());
provider.Authenticate(ac.getUserName(), ac.getPasswd());
ac.setAuthenticated(true);
}
}