Package org.eclipse.hono.auth
Class EncodedPassword
- java.lang.Object
-
- org.eclipse.hono.auth.EncodedPassword
-
public final class EncodedPassword extends Object
Encoded password representation.Helps with parsing strings in the form of {Base64(salt)}password-hash into a value object, like
EncodedPassword password = new EncodedPassword("{VGhlU2FsdA==}1L/qmnQ8kbgckAodOCbtyJAhoiK4k0rBtBBN+WD+TIE="); System.out.println(password.salt + " " + password.password);
-
-
Field Summary
Fields Modifier and Type Field Description String
hashFunction
The hash function used for creating the hash value.String
password
The password hash if this object has been created from an encoded password or the clear text password to be encoded.byte[]
salt
The salt used for hashing the password ornull
if no salt is used.
-
Constructor Summary
Constructors Constructor Description EncodedPassword(String formattedPassword)
Creates an instance from the {Base64(salt)}password-hash formatted String.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
format()
Creates a string representation of this password that is compatible with Spring Security password encoders.static EncodedPassword
fromHonoSecret(io.vertx.core.json.JsonObject secret)
Creates a new instance from Hono Secret.
-
-
-
Field Detail
-
salt
public byte[] salt
The salt used for hashing the password ornull
if no salt is used.
-
password
public String password
The password hash if this object has been created from an encoded password or the clear text password to be encoded.
-
hashFunction
public String hashFunction
The hash function used for creating the hash value. Defaults toCredentialsConstants.DEFAULT_HASH_FUNCTION
.
-
-
Constructor Detail
-
EncodedPassword
public EncodedPassword(String formattedPassword)
Creates an instance from the {Base64(salt)}password-hash formatted String.- Parameters:
formattedPassword
- Password hash in the {Base64(salt)}password-hash format
-
-
Method Detail
-
fromHonoSecret
public static EncodedPassword fromHonoSecret(io.vertx.core.json.JsonObject secret) throws IllegalArgumentException
Creates a new instance from Hono Secret.The secret is expected to be of type hashed-password as defined by Hono's Credentials API.
- Parameters:
secret
- JSON object that contains the Hono-formatted secret.- Returns:
- The password value object.
- Throws:
NullPointerException
- if secret isnull
.IllegalArgumentException
- if the secret does not contain a password hash or if the salt is not valid Base64 schema.
-
format
public String format()
Creates a string representation of this password that is compatible with Spring Security password encoders.- Returns:
- The value of this object formatted as {Base64(salt)}password.
-
-