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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPermission
(Permission... permissions) static String
authorityString
(String role) Generate the authority string for a role, applies the prefix if is not yet present.getId()
getName()
boolean
hasPermission
(Permission permission) boolean
hasPermission
(String authority) Does the user have a permission with the requested authority string.void
setAuthority
(String authority) void
setDescription
(String description) void
void
void
setPermissions
(Collection<Permission> permissions) org.springframework.security.core.GrantedAuthority
Convert this role to a Spring securityGrantedAuthority
for use in authentication.toString()
Methods inherited from class com.foreach.across.modules.hibernate.business.SettableIdAuditableEntity
getCreatedBy, getCreatedDate, getLastModifiedBy, getLastModifiedDate, setCreatedBy, setCreatedDate, setLastModifiedBy, setLastModifiedDate
Methods 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:
getId
in interfacecom.foreach.across.modules.hibernate.business.IdBasedEntity
- Specified by:
getId
in interfaceorg.springframework.data.domain.Persistable<Long>
-
setId
- Specified by:
setId
in 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:
true
if permission is present
-
hasPermission
-
toString
-
toGrantedAuthority
public org.springframework.security.core.GrantedAuthority toGrantedAuthority()Convert this role to a Spring securityGrantedAuthority
for 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
-