public class LoginData
extends sirius.db.mixing.Composite
Note that no uniqueness constraint is placed on the username as the context of unqiueness has to be decided by the outside class.
An example of an actual user is UserAccount
.
Modifier and Type | Field and Description |
---|---|
static sirius.db.mixing.Mapping |
ACCOUNT_LOCKED
Contains a flag which checks if the user is permitted to login.
|
static sirius.db.mixing.Mapping |
API_TOKEN
Provides an API TOKEN which is crypthgraphically created and can be used as password for technical integrations
|
static sirius.db.mixing.Mapping |
GENERATED_PASSWORD
Contains the generated password as cleartext (so it can be reported to the user).
|
static sirius.db.mixing.Mapping |
LAST_EXTERNAL_LOGIN
Records the timestamp of the last login via an external system.
|
static sirius.db.mixing.Mapping |
LAST_LOGIN
Records the timestamp of the last login.
|
static sirius.db.mixing.Mapping |
LAST_PASSWORD_CHANGE
Records the timestamp of the last password change.
|
static sirius.db.mixing.Mapping |
NUMBER_OF_LOGINS
Records the number of logins.
|
static sirius.db.mixing.Mapping |
PASSWORD_HASH
Contains the hashed value of the password to verify the password at login
|
static sirius.db.mixing.Mapping |
SALT
Contains a random salt which is prepended to the password before hashing to block
rainbow tables and the like.
|
static sirius.db.mixing.Mapping |
UCASE_PASSWORD_HASH
Contains the hash value of the password in all upper case.
|
static sirius.db.mixing.Mapping |
USERNAME
Contains the username used to identify the account.
|
Constructor and Description |
---|
LoginData() |
Modifier and Type | Method and Description |
---|---|
protected void |
autofill() |
boolean |
checkPassword(String password,
String defaultSalt)
Checks if the given password is correct.
|
String |
getApiToken() |
String |
getCleartextPassword()
Returns the currently set password in cleartext.
|
String |
getGeneratedPassword() |
LocalDateTime |
getLastExternalLogin() |
LocalDateTime |
getLastLogin() |
LocalDateTime |
getLastPasswordChange() |
int |
getNumberOfLogins() |
String |
getPasswordHash() |
String |
getSalt() |
String |
getUcasePasswordHash() |
String |
getUsername() |
static String |
hashPassword(String salt,
String password)
Computes a password hash for a given salt and password.
|
boolean |
isAccountLocked() |
boolean |
isDisplayGeneratedPassword()
Determines if the generated password should be displayed.
|
void |
setAccountLocked(boolean accountLocked) |
void |
setApiToken(String apiToken) |
void |
setCleartextPassword(String cleartextPassword)
Sets the password in cleartext.
|
void |
setGeneratedPassword(String generatedPassword) |
void |
setLastExternalLogin(LocalDateTime lastExternalLogin) |
void |
setLastLogin(LocalDateTime lastLogin) |
void |
setNumberOfLogins(int numberOfLogins) |
void |
setUsername(String username) |
void |
verifyPassword(String password,
String confirmation,
int minPasswordLength)
Verifys the given password if it meets the length requirement and is equal to its confirmation.
|
public static final sirius.db.mixing.Mapping USERNAME
public static final sirius.db.mixing.Mapping PASSWORD_HASH
public static final sirius.db.mixing.Mapping UCASE_PASSWORD_HASH
public static final sirius.db.mixing.Mapping SALT
public static final sirius.db.mixing.Mapping GENERATED_PASSWORD
public static final sirius.db.mixing.Mapping API_TOKEN
public static final sirius.db.mixing.Mapping NUMBER_OF_LOGINS
public static final sirius.db.mixing.Mapping LAST_LOGIN
public static final sirius.db.mixing.Mapping LAST_EXTERNAL_LOGIN
When using external identity poviders, like SAML, we want to keep track when the last login via this happened as we probably want to enforce regular validations (logins).
public static final sirius.db.mixing.Mapping LAST_PASSWORD_CHANGE
public static final sirius.db.mixing.Mapping ACCOUNT_LOCKED
protected void autofill()
public void verifyPassword(String password, String confirmation, int minPasswordLength)
password
- the password to check forconfirmation
- the confirmation password to check forminPasswordLength
- the minimum password lengthsirius.kernel.health.HandledException
- if password is too short or if passwords do mismatchpublic static String hashPassword(String salt, String password)
salt
- the salt to usepassword
- the password to hashpublic boolean checkPassword(String password, String defaultSalt)
password
- the password to validatedefaultSalt
- the salt used as a fallbackpublic String getCleartextPassword()
Note that this value is transient and therefore not saved to the database.
public void setCleartextPassword(String cleartextPassword)
Note that this value is transient and therefore not saved to the database. This field only exists for convenience, as it can be filled and the associated entity can be save. All hashes will be updated accordingly.
cleartextPassword
- the password as clear textpublic String getPasswordHash()
public String getUcasePasswordHash()
public String getSalt()
public String getGeneratedPassword()
public void setGeneratedPassword(String generatedPassword)
public int getNumberOfLogins()
public void setNumberOfLogins(int numberOfLogins)
public LocalDateTime getLastLogin()
public void setLastLogin(LocalDateTime lastLogin)
public LocalDateTime getLastExternalLogin()
public void setLastExternalLogin(LocalDateTime lastExternalLogin)
public LocalDateTime getLastPasswordChange()
public boolean isDisplayGeneratedPassword()
public boolean isAccountLocked()
public void setAccountLocked(boolean accountLocked)
public String getUsername()
public void setUsername(String username)
public String getApiToken()
public void setApiToken(String apiToken)
Copyright © 2018. All rights reserved.