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:
CallerPrincipalCallback does)
GroupPrincipalCallback does)
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.
| Modifier and Type | Field and Description |
|---|---|
| private char[] | |
| private boolean | |
| private Subject | |
| private String |
| Access | Constructor and Description |
|---|---|
| public | PasswordValidationCallback(Subject
The subject for authentication subject, String The username to authenticate username, char[] The user's password, which may be null. password)Create a PasswordValidationCallback. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public char[] | |
| public boolean | |
| public Subject | |
| public String | |
| public void | setResult(boolean
True if authentication succeeded, false otherwise result)Set the authentication result. |
| password | back to summary |
|---|---|
| private char[] password | |
| result | back to summary |
|---|---|
| private boolean result | |
| subject | back to summary |
|---|---|
| private Subject subject | |
| username | back to summary |
|---|---|
| private String username | |
| PasswordValidationCallback | back to summary |
|---|---|
| public PasswordValidationCallback(Subject subject, String username, char[] password) Create a PasswordValidationCallback. | |
| clearPassword | back to summary |
|---|---|
| public void clearPassword() Clear the password. | |
| getPassword | back to summary |
|---|---|
| public char[] getPassword() Get the password. Note that this method returns a reference to the password. If a clone of the array is created it is the caller's responsibility to zero out the password information after it is no longer needed.
| |
| getResult | back to summary |
|---|---|
| public boolean getResult() Get the authentication result.
| |
| getSubject | back to summary |
|---|---|
| public Subject getSubject() Get the subject.
| |
| getUsername | back to summary |
|---|---|
| public String getUsername() Get the username.
| |
| setResult | back to summary |
|---|---|
| public void setResult(boolean result) Set the authentication result.
| |