Package org.appng.core.domain
Class SubjectImpl
- java.lang.Object
-
- org.appng.core.domain.SubjectImpl
-
- All Implemented Interfaces:
Serializable
,Account
,AuthSubject
,Identifiable<Integer>
,Nameable
,Named<Integer>
,Subject
,Versionable<Date>
,Auditable<Integer>
@Entity public class SubjectImpl extends Object implements Subject, Auditable<Integer>
DefaultSubject
-implementation- Author:
- Matthias Müller
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.appng.api.model.AuthSubject
AuthSubject.PasswordChangePolicy
-
-
Constructor Summary
Constructors Constructor Description SubjectImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
List<Role>
getApplicationRoles(Application application)
String
getAuthName()
Returns the username of thisAccount
, e.g.@Size(max=8192,message="{validation.string.max}") String
getDescription()
Returns the description.String
getDigest()
Returns the salted digest for thisAuthSubject
.@Pattern(regexp="^([a-zA-Z0-9_\\.-])+@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]){2,}$",message="{validation.email}") String
getEmail()
Returns the email for thisAccount
, e.g.Date
getExpiryDate()
The date on which the subject expires.Integer
getFailedLoginAttempts()
Returns the number of failed login attempts for this subject.List<Group>
getGroups()
Integer
getId()
Returns the id.@NotNull(message="{validation.notNull}") @Size(min=2,max=3,message="{validation.string.min.max}") String
getLanguage()
Returns the language tag for thisAccount
in the IETF BCP 47 notation:<lang>-<country>
.
Examples: en en-US de de-CHDate
getLastLogin()
Returns the date of the last login, if any.@NotNull(message="{validation.notNull}") @Pattern(regexp="^((((CN|cn)=[^,]+),?)*(((OU|ou)=[^,]+),?)*(((DC|dc)=[^,]+),?)*)|(([a-zA-Z0-9_\\.-])+(@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]){2,})?)$",message="{validation.usernameGroup}") @Size(max=255,message="{validation.string.max}") String
getName()
Returns the name.AuthSubject.PasswordChangePolicy
getPasswordChangePolicy()
Returns theAuthSubject.PasswordChangePolicy
for this subjectDate
getPasswordLastChanged()
Returns the date when the password was last changed.@NotNull(message="{validation.notNull}") @Size(max=64,message="{validation.string.max}") String
getRealname()
Returns the real name of thisAccount
, e.g.String
getSalt()
Returns the salt for thisAuthSubject
.String
getTimeZone()
Returns the timezone for thisAccount
, e.g.String
getTypeName()
UserType
getUserType()
Returns theUserType
.Date
getVersion()
Returns the version.boolean
hasApplication(Application application)
int
hashCode()
boolean
isAuthenticated()
Checks whether thisSubject
is authenticated.boolean
isAuthorized(Authorizable<?> authorizable)
Checks whether thisSubject
has authorization for the givenAuthorizable
.boolean
isExpired(Date date)
boolean
isInactive(Date now, Integer inactiveLockPeriod)
boolean
isLocked()
Whether or not the subject is locked.void
setEmail(String email)
String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.appng.core.domain.Auditable
getAuditName
-
Methods inherited from interface org.appng.api.model.AuthSubject
setDigest, setPasswordChangePolicy, setPasswordLastChanged, setSalt
-
-
-
-
Method Detail
-
getName
@NotNull(message="{validation.notNull}") @Pattern(regexp="^((((CN|cn)=[^,]+),?)*(((OU|ou)=[^,]+),?)*(((DC|dc)=[^,]+),?)*)|(([a-zA-Z0-9_\\.-])+(@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]){2,})?)$", message="{validation.usernameGroup}") @Size(max=255, message="{validation.string.max}") public @NotNull(message="{validation.notNull}") @Pattern(regexp="^((((CN|cn)=[^,]+),?)*(((OU|ou)=[^,]+),?)*(((DC|dc)=[^,]+),?)*)|(([a-zA-Z0-9_\\.-])+(@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]){2,})?)$",message="{validation.usernameGroup}") @Size(max=255,message="{validation.string.max}") String getName()
Description copied from interface:Nameable
Returns the name.
-
getDescription
@Size(max=8192, message="{validation.string.max}") public @Size(max=8192,message="{validation.string.max}") String getDescription()
Description copied from interface:Nameable
Returns the description.- Specified by:
getDescription
in interfaceNameable
- Returns:
- the description
-
getId
public Integer getId()
Description copied from interface:Identifiable
Returns the id.- Specified by:
getId
in interfaceIdentifiable<Integer>
- Returns:
- the id
-
getVersion
public Date getVersion()
Description copied from interface:Versionable
Returns the version.- Specified by:
getVersion
in interfaceVersionable<Date>
- Returns:
- the version
-
getLanguage
@NotNull(message="{validation.notNull}") @Size(min=2, max=3, message="{validation.string.min.max}") public @NotNull(message="{validation.notNull}") @Size(min=2,max=3,message="{validation.string.min.max}") String getLanguage()
Description copied from interface:Account
Returns the language tag for thisAccount
in the IETF BCP 47 notation:<lang>-<country>
.
Examples:- en
- en-US
- de
- de-CH
- Specified by:
getLanguage
in interfaceAccount
- Returns:
- the language
- See Also:
Locale.forLanguageTag(String)
-
getRealname
@NotNull(message="{validation.notNull}") @Size(max=64, message="{validation.string.max}") public @NotNull(message="{validation.notNull}") @Size(max=64,message="{validation.string.max}") String getRealname()
Description copied from interface:Account
Returns the real name of thisAccount
, e.g. 'appNG Administrator'.- Specified by:
getRealname
in interfaceAccount
- Returns:
- the real name
-
getEmail
@Pattern(regexp="^([a-zA-Z0-9_\\.-])+@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]){2,}$", message="{validation.email}") public @Pattern(regexp="^([a-zA-Z0-9_\\.-])+@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]){2,}$",message="{validation.email}") String getEmail()
Description copied from interface:Account
Returns the email for thisAccount
, e.g. 'admin@example.com'.
-
setEmail
public void setEmail(String email)
-
getDigest
public String getDigest()
Description copied from interface:AuthSubject
Returns the salted digest for thisAuthSubject
.- Specified by:
getDigest
in interfaceAuthSubject
- Returns:
- the salted digest
-
getSalt
public String getSalt()
Description copied from interface:AuthSubject
Returns the salt for thisAuthSubject
.- Specified by:
getSalt
in interfaceAuthSubject
- Returns:
- the salt
-
getUserType
public UserType getUserType()
Description copied from interface:Subject
Returns theUserType
.- Specified by:
getUserType
in interfaceSubject
- Returns:
- the
UserType
-
isExpired
public boolean isExpired(Date date)
-
getExpiryDate
public Date getExpiryDate()
Description copied from interface:Subject
The date on which the subject expires.- Specified by:
getExpiryDate
in interfaceSubject
- Returns:
- the date, if any (may be
null
)
-
getLastLogin
public Date getLastLogin()
Description copied from interface:Subject
Returns the date of the last login, if any.- Specified by:
getLastLogin
in interfaceSubject
- Returns:
- the date.
-
getPasswordLastChanged
public Date getPasswordLastChanged()
Description copied from interface:Subject
Returns the date when the password was last changed. Default to the creation date of the subject.- Specified by:
getPasswordLastChanged
in interfaceSubject
- Returns:
- the date.
-
isLocked
public boolean isLocked()
Description copied from interface:Subject
Whether or not the subject is locked.
-
getPasswordChangePolicy
public AuthSubject.PasswordChangePolicy getPasswordChangePolicy()
Description copied from interface:AuthSubject
Returns theAuthSubject.PasswordChangePolicy
for this subject- Specified by:
getPasswordChangePolicy
in interfaceAuthSubject
- Returns:
- the
AuthSubject.PasswordChangePolicy
for this subject
-
getFailedLoginAttempts
public Integer getFailedLoginAttempts()
Description copied from interface:Subject
Returns the number of failed login attempts for this subject.- Specified by:
getFailedLoginAttempts
in interfaceSubject
- Returns:
- the number of failed login attempts
-
isAuthenticated
public boolean isAuthenticated()
Description copied from interface:Subject
Checks whether thisSubject
is authenticated.- Specified by:
isAuthenticated
in interfaceSubject
- Returns:
true
if thisSubject
is authenticated,false
otherwise
-
hasApplication
public boolean hasApplication(Application application)
Description copied from interface:Subject
- Specified by:
hasApplication
in interfaceSubject
- Parameters:
application
- theApplication
- Returns:
true
if thisSubject
owns at least oneRole
of the the givenApplication
,false
otherwise
-
getApplicationRoles
public List<Role> getApplicationRoles(Application application)
-
isAuthorized
public boolean isAuthorized(Authorizable<?> authorizable)
Description copied from interface:Subject
Checks whether thisSubject
has authorization for the givenAuthorizable
.- Specified by:
isAuthorized
in interfaceSubject
- Parameters:
authorizable
- theAuthorizable
- Returns:
true
if thisSubject
has authorization for the givenAuthorizable
,false
otherwise
-
getTimeZone
public String getTimeZone()
Description copied from interface:Account
Returns the timezone for thisAccount
, e.g. 'Europe/Berlin'.- Specified by:
getTimeZone
in interfaceAccount
- Returns:
- the timezone
-
getAuthName
public String getAuthName()
Description copied from interface:Account
Returns the username of thisAccount
, e.g. 'admin'.- Specified by:
getAuthName
in interfaceAccount
- Returns:
- the username
-
getTypeName
public String getTypeName()
-
-