This class accepts Unicode UTF-8 encoded file
Each entry in the password file contains a username followed by a password. Password can be in clear text or as a hash. Hashed passwords must follow the below format. hashedPassword = base64_encoded_64_byte_salt W base64_encoded_hash W hash_algorithm where, W = spaces, base64_encoded_64_byte_salt = 64 byte random salt, base64_encoded_hash = hash_algorithm(password + salt), hash_algorithm = Algorithm string as specified in hash_algorithm is an optional field. If not specified, SHA3-512 will be assumed.
If passwords are in clear, they will be over-written by their hash if hashing is requested by setting com.sun.management.jmxremote.password.toHashes property to true in the management.properties file and if the password file is writable and if the system security policy allows writing into the password file, if a security manager is configured
In order to change the password for a role, replace the hashed password entry with a new clear text password or a new hashed password. If the new password is in clear, it will be replaced with its hash when a new login attempt is made.
A given role should have at most one entry in this file. If a role has no entry, it has no access. If multiple entries are found for the same role name, then the last one will be used.
A user generated hashed password file can also be used instead of a clear-text password file. If generated by the user, hashed passwords must follow the format specified above.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private static final int | |
| private boolean | |
| private static final ClassLogger | |
| private final String | |
| private final SecureRandom | |
| private final boolean | |
| private final Map |
| Access | Constructor and Description |
|---|---|
| public | HashedPasswordManager(String
UTF-8 encoded input file to read passwords from filename, boolean Request for clear passwords to be hashed shouldHashPasswords)Creates a new password manager for the input password file |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized boolean | Returns: true if authentication succeeds, false otherwiseInput username userName, char[] Input password inputPassword)Authenticate the supplied credentials against the one present in the file |
| private String[] | |
| public synchronized void | |
| private String[] | |
| private void |
| DefaultHashAlgorithm | back to summary |
|---|---|
| private static final String DefaultHashAlgorithm | |
| DefaultSaltLength | back to summary |
|---|---|
| private static final int DefaultSaltLength | |
| isLogged | back to summary |
|---|---|
| private boolean isLogged | |
| logger | back to summary |
|---|---|
| private static final ClassLogger logger | |
| passwordFile | back to summary |
|---|---|
| private final String passwordFile | |
| random | back to summary |
|---|---|
| private final SecureRandom random | |
| shouldHashPasswords | back to summary |
|---|---|
| private final boolean shouldHashPasswords | |
| userCredentialsMap | back to summary |
|---|---|
| private final Map<String, HashedPasswordManager. | |
| HashedPasswordManager | back to summary |
|---|---|
| public HashedPasswordManager(String filename, boolean shouldHashPasswords) Creates a new password manager for the input password file
| |
| authenticate | back to summary |
|---|---|
| public synchronized boolean authenticate(String userName, char[] inputPassword) Authenticate the supplied credentials against the one present in the file
| |
| getHash | back to summary |
|---|---|
| private String[] getHash(String algorithm, String password) | |
| loadPasswords | back to summary |
|---|---|
| public synchronized void loadPasswords() throws IOException Load passwords from the password file.
This method should be called for every login attempt to load new/changed credentials, if any.
If hashing is requested, clear passwords will be over-written with their SHA3-512 hash
| |
| readPasswordFile | back to summary |
|---|---|
| private String[] readPasswordFile() throws IOException | |
| writePasswordFile | back to summary |
|---|---|
| private void writePasswordFile(String input) throws IOException | |
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private final String | |
| private final String | |
| private final String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String |
| b64Hash | back to summary |
|---|---|
| private final String b64Hash | |
| b64Salt | back to summary |
|---|---|
| private final String b64Salt | |
| hashAlgorithm | back to summary |
|---|---|
| private final String hashAlgorithm | |
| userName | back to summary |
|---|---|
| private final String userName | |
| UserCredentials | back to summary |
|---|---|
| public UserCredentials(String userName, String hashAlgorithm, String b64Salt, String b64Hash) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |