Record Class User
java.lang.Object
java.lang.Record
net.tangly.core.domain.User
- Record Components:
username- username is the identifier of the user in the context of a tenantpasswordHash- password hash is the encrypted password of the useractive- true if the user is active and can log in the applicationnaturalPersonId- optional identifier of the natural person associated with the useraccessRights- list of access rights for the user on the different domains of the applicationgravatarEmail- email address used to retrieve the avatar of the user through the gravatar service
public record User(@NotNull String username, @NotNull String passwordHash, @NotNull String passwordSalt, boolean active, String naturalPersonId, @NotNull List<AccessRights> accessRights, String gravatarEmail)
extends Record
An application user can log in the application and access to domain data based on domain access rights.
A user is defined in the context of a tenant.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull List<AccessRights> Returns the value of theaccessRightsrecord component.accessRightsFor(@NotNull String domain) Returns the access rights of a user for a specific domain.booleanactive()Returns the value of theactiverecord component.booleanauthenticate(@NotNull String password) Authenticates the user based on the password provided.static byte[]Returns the avatar of a user based on the email address of the user.static StringencryptPassword(@NotNull String password, @NotNull String salt) Encrypts the password of a user using a salt.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thegravatarEmailrecord component.booleanhasAdminRightsFor(@NotNull String domain) final inthashCode()Returns a hash code value for this object.Returns the value of thenaturalPersonIdrecord component.static StringnewSalt()Generates a new salt value with a JDK provided random generator.@NotNull StringReturns the value of thepasswordHashrecord component.@NotNull StringReturns the value of thepasswordSaltrecord component.final StringtoString()Returns a string representation of this record class.@NotNull Stringusername()Returns the value of theusernamerecord component.
-
Constructor Details
-
User
public User(@NotNull @NotNull String username, @NotNull @NotNull String passwordHash, @NotNull @NotNull String passwordSalt, boolean active, String naturalPersonId, @NotNull @NotNull List<AccessRights> accessRights, String gravatarEmail) Creates an instance of aUserrecord class.- Parameters:
username- the value for theusernamerecord componentpasswordHash- the value for thepasswordHashrecord componentpasswordSalt- the value for thepasswordSaltrecord componentactive- the value for theactiverecord componentnaturalPersonId- the value for thenaturalPersonIdrecord componentaccessRights- the value for theaccessRightsrecord componentgravatarEmail- the value for thegravatarEmailrecord component
-
-
Method Details
-
encryptPassword
-
newSalt
Generates a new salt value with a JDK provided random generator.- Returns:
- new salt value
-
avatar
Returns the avatar of a user based on the email address of the user.- Parameters:
gravatarEmail- email address of the user registered in the gravatar service- Returns:
- avatar picture of the user
-
accessRightsFor
Returns the access rights of a user for a specific domain.- Parameters:
domain- domain for which the access rights are requested- Returns:
- access rights of the user for the domain
-
hasAdminRightsFor
-
authenticate
Authenticates the user based on the password provided.- Parameters:
password- password to authenticate the user- Returns:
- true if the password is correct
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
username
-
passwordHash
Returns the value of thepasswordHashrecord component.- Returns:
- the value of the
passwordHashrecord component
-
passwordSalt
Returns the value of thepasswordSaltrecord component.- Returns:
- the value of the
passwordSaltrecord component
-
active
-
naturalPersonId
Returns the value of thenaturalPersonIdrecord component.- Returns:
- the value of the
naturalPersonIdrecord component
-
accessRights
Returns the value of theaccessRightsrecord component.- Returns:
- the value of the
accessRightsrecord component
-
gravatarEmail
Returns the value of thegravatarEmailrecord component.- Returns:
- the value of the
gravatarEmailrecord component
-