Package io.openems.edge.common.user
Class ManagedUser
java.lang.Object
io.openems.common.session.AbstractUser
io.openems.edge.common.user.User
io.openems.edge.common.user.ManagedUser
A
User
that can be used for Logging in. Managed by the
UserService
.-
Field Summary
FieldsFields inherited from class io.openems.edge.common.user.User
DEFAULT_EDGE_ID
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
hashPassword
(char[] password, byte[] salt, int iterations, int keyLength) Hashes a password.static byte[]
hashPassword
(String password, byte[] salt, int iterations, int keyLength) Hashes a password.static boolean
validatePassword
(byte[] password1, byte[] salt, String password2) Validates if password+salt match the given password.boolean
validatePassword
(String password) Validates a given password against the Users password+salt.static boolean
validatePassword
(String passwordAsBase64, String saltAsBase64, String password) Validates if password+salt match the given password.Methods inherited from class io.openems.edge.common.user.User
assertRoleIsAtLeast, from, getRole, toString
Methods inherited from class io.openems.common.session.AbstractUser
getEdgeRoles, getGlobalRole, getId, getLanguage, getName, getRole, setLanguage, setRole
-
Field Details
-
KEY_LENGTH
public static final int KEY_LENGTH- See Also:
-
ITERATIONS
public static final int ITERATIONS- See Also:
-
-
Constructor Details
-
ManagedUser
-
ManagedUser
-
-
Method Details
-
validatePassword
Validates a given password against the Users password+salt.- Parameters:
password
- the given password- Returns:
- true if passwords match
-
validatePassword
public static boolean validatePassword(String passwordAsBase64, String saltAsBase64, String password) Validates if password+salt match the given password.- Parameters:
passwordAsBase64
- the hashed passwordsaltAsBase64
- the saltpassword
- the given password- Returns:
- true if they match.
-
validatePassword
Validates if password+salt match the given password.- Parameters:
password1
- the hashed passwordsalt
- the saltpassword2
- the given password- Returns:
- true if they match.
-
hashPassword
Hashes a password. Source: https://www.owasp.org/index.php/Hashing_Java.- Parameters:
password
- the passwordsalt
- the saltiterations
- the number of iterationskeyLength
- the length of the key- Returns:
- the hashed password
-
hashPassword
public static byte[] hashPassword(char[] password, byte[] salt, int iterations, int keyLength) Hashes a password. Source: https://www.owasp.org/index.php/Hashing_Java.- Parameters:
password
- the passwordsalt
- the saltiterations
- the number of iterationskeyLength
- the length of the key- Returns:
- the hashed password
-