# Class PasswordValidationCallback

java.lang.Object
jakarta.security.auth.message.callback.PasswordValidationCallback

All Implemented Interfaces:
  `Callback`

public class PasswordValidationCallback extends Object implements Callback
A callback that enables an authentication module to supply a username and password to the runtime and obtain the result of password validation. The runtime validates the credentials and updates the `Subject` if authentication succeeds.

## Constructor Summary

Constructors
Constructor
Description
`PasswordValidationCallback(Subject subject, String username, char[] password)`
Creates a new `PasswordValidationCallback` with the specified subject, username, and password.

## Method Summary

Modifier and Type
Method
Description
`void`
`clearPassword()`
Clears the password from memory for security purposes.
`char[]`
`getPassword()`
Returns the password to be validated.
`boolean`
`getResult()`
Returns the result of the password validation.
`Subject`
`getSubject()`
Returns the `Subject` associated with this callback.
`String`
`getUsername()`
Returns the username to be validated.
`void`
`setResult(boolean result)`
Sets the result of the password validation performed by the runtime.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### PasswordValidationCallback

public PasswordValidationCallback(Subject subject, String username, char[] password)
Creates a new `PasswordValidationCallback` with the specified subject, username, and password.

Parameters:
  `subject` - the `Subject` to be populated upon successful authentication
  `username` - the username to validate
  `password` - the password to validate

## Method Details

### getSubject

public Subject getSubject()
Returns the `Subject` associated with this callback. The runtime populates this subject with authentication information upon successful validation.

Returns:
  the `Subject` for this callback

### getUsername

public String getUsername()
Returns the username to be validated.

Returns:
  the username

### getPassword

public char[] getPassword()
Returns the password to be validated.

Returns:
  the password character array

### clearPassword

public void clearPassword()
Clears the password from memory for security purposes. After calling this method, `getPassword()` will return an empty character array.

### setResult

public void setResult(boolean result)
Sets the result of the password validation performed by the runtime.

Parameters:
  `result` - `true` if the password validation succeeded, `false` otherwise

### getResult

public boolean getResult()
Returns the result of the password validation.

Returns:
  `true` if the password was validated successfully, `false` otherwise