* @param password a {@code String} representing the password.
*/
protected void registerWithCallbackHandler(Principal userPrincipal, String username,
String password) {
if (this.callbackHandler instanceof WebJASPICallbackHandler) {
WebJASPICallbackHandler cbh = (WebJASPICallbackHandler) callbackHandler;
PasswordValidationCallback passwordValidationCallback =
new PasswordValidationCallback(null, username, password.toCharArray());
CallerPrincipalCallback callerCallback = new CallerPrincipalCallback(null, userPrincipal);
try {
cbh.handle(new Callback[] {passwordValidationCallback, callerCallback});
} catch (Exception e) {
throw new RuntimeException("Error handling callbacks: " + e.getLocalizedMessage(), e);
}
} else
throw new RuntimeException(" Unsupported Callback handler " + this.callbackHandler.getClass().