Class PasswordValidationCallback

java.lang.Object
jakarta.security.auth.message.callback.PasswordValidationCallback
All Implemented Interfaces:
Callback

public class PasswordValidationCallback extends Object implements Callback
Callback for PasswordValidation.

This callback may be used by an authentication module to employ the password validation facilities of its containing runtime. This Callback would typically be called by a ServerAuthModule during validateRequest processing.

This callback causes the following actions to be done:

  1. Validate the credentials
  2. If validated set caller principal (conceptually just like CallerPrincipalCallback does)
  3. If validated and groups available set groups (conceptually just like GroupPrincipalCallback does)
The code below shows a hypothetical example of how a PasswordValidationCallback could be implemented by a Jakarta Authentication implementation provided CallbackHandler:
 
 protected void processPasswordValidation(PasswordValidationCallback pwdCallback) {

    // 1. Validate the credentials
    Caller caller = ContainerSpecificStore.validate(pwdCallback.getUsername(), getPassword(pwdCallback));

    if (caller != null) {
        // 2. If validated set caller principal, just like CallerPrincipalCallback does
        processCallerPrincipal(new CallerPrincipalCallback(pwdCallback.getSubject(), caller.getCallerPrincipal()));

        if (!caller.getGroups().isEmpty()) {
            // 3. If validated and groups available set groups, just like GroupPrincipalCallback does
            processGroupPrincipal(new GroupPrincipalCallback(pwdCallback.getSubject(), caller.getGroupsAsArray()));
        }

        pwdCallback.setResult(true);
    }
 }
 
 
Note that in this example:
  • processCallerPrincipal represents how the CallbackHandler would handle the CallerPrincipalCallback.
  • processGroupPrincipal represents how the CallbackHandler would handle the GroupPrincipalCallback.
  • Caller and ContainerSpecificStore are hypothetical implementation specific types.