Class Role
java.lang.Object
com.foreach.across.modules.hibernate.business.SettableIdBasedEntity<T>
com.foreach.across.modules.hibernate.business.SettableIdAuditableEntity<Role>
com.foreach.across.modules.user.business.Role
- All Implemented Interfaces:
com.foreach.across.modules.hibernate.business.Auditable<String>,com.foreach.across.modules.hibernate.business.EntityWithDto<Role>,com.foreach.across.modules.hibernate.business.IdBasedEntity,Serializable,org.springframework.data.domain.Persistable<Long>
@NotThreadSafe
@Entity
public class Role
extends com.foreach.across.modules.hibernate.business.SettableIdAuditableEntity<Role>
implements Serializable
A role represents a number of permissions that can be applied for a principal.
The role is by itself also a
GrantedAuthority that can be used for security checking.- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPermission(Permission... permissions) static StringauthorityString(String role) Generate the authority string for a role, applies the prefix if is not yet present.getId()getName()booleanhasPermission(Permission permission) booleanhasPermission(String authority) Does the user have a permission with the requested authority string.voidsetAuthority(String authority) voidsetDescription(String description) voidvoidvoidsetPermissions(Collection<Permission> permissions) org.springframework.security.core.GrantedAuthorityConvert this role to a Spring securityGrantedAuthorityfor use in authentication.toString()Methods inherited from class com.foreach.across.modules.hibernate.business.SettableIdAuditableEntity
getCreatedBy, getCreatedDate, getLastModifiedBy, getLastModifiedDate, setCreatedBy, setCreatedDate, setLastModifiedBy, setLastModifiedDateMethods inherited from class com.foreach.across.modules.hibernate.business.SettableIdBasedEntity
equals, getNewEntityId, hashCode, isNew, setNewEntityId, toDto
-
Field Details
-
AUTHORITY_PREFIX
- See Also:
-
-
Constructor Details
-
Role
public Role() -
Role
-
Role
-
-
Method Details
-
getId
- Specified by:
getIdin interfacecom.foreach.across.modules.hibernate.business.IdBasedEntity- Specified by:
getIdin interfaceorg.springframework.data.domain.Persistable<Long>
-
setId
- Specified by:
setIdin classcom.foreach.across.modules.hibernate.business.SettableIdBasedEntity<Role>
-
getAuthority
-
setAuthority
-
getName
-
setName
-
getDescription
-
setDescription
-
getPermissions
-
setPermissions
-
addPermission
-
hasPermission
Does the user have a permission with the requested authority string.- Parameters:
authority- string to check- Returns:
trueif permission is present
-
hasPermission
-
toString
-
toGrantedAuthority
public org.springframework.security.core.GrantedAuthority toGrantedAuthority()Convert this role to a Spring securityGrantedAuthorityfor use in authentication.- Returns:
- granted authority
-
authorityString
Generate the authority string for a role, applies the prefix if is not yet present.- Parameters:
role- authority name of the role- Returns:
- authority string
-