Package org.openwms.core.uaa.impl
Class Role
java.lang.Object
org.ameba.integration.jpa.BaseEntity
org.ameba.integration.jpa.ApplicationEntity
org.openwms.core.uaa.impl.SecurityObject
org.openwms.core.uaa.impl.Role
- All Implemented Interfaces:
Serializable,org.ameba.integration.TypedEntity<Long>
A Role is a group of
Users. Basically more than one User belong to a Role. Security access policies are assigned to Roles
instead of Users.- Author:
- Heiko Scherrer
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder class to construct Role instances. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Set<SecurityObject> AllSecurityObjects assigned to the Role.private BooleanWhether or not this Role is immutable.static final Stringstatic final StringThe default prefix String for each created Role.AllUsers assigned to the Role.Fields inherited from class org.ameba.integration.jpa.ApplicationEntity
C_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddGrant(SecurityObject grant) Add an existingSecurityObjectto the Role.voidaddGrants(Set<SecurityObject> grants) Add existingSecurityObjects to the Role.booleanAdd an existingUserto the Role.voidAdd existingUsers to the Role.booleanCompare the name.Return a Set of allSecurityObjects belonging to the Role.Get the immutable.getUsers()Return a Set of allUsers assigned to the Role.inthashCode()normalizeName(String name) booleanremoveGrant(SecurityObject grant) Add an existingSecurityObjectto the Role.booleanremoveGrants(List<? extends SecurityObject> grants) Add an existingSecurityObjectto the Role.voidremoveUser(User user) Remove aUserfrom the Role.voidsetGrants(Set<SecurityObject> grants) Set allSecurityObjects assigned to the Role.voidsetImmutable(Boolean immutable) Set the Role as immutable.protected voidvoidsetPersistentKey(String pKey) voidSet allUsers belonging to this Role.Methods inherited from class org.openwms.core.uaa.impl.SecurityObject
getDescription, getName, setDescription, toStringMethods inherited from class org.ameba.integration.jpa.ApplicationEntity
getPersistentKey, hasPersistentKey, onEntityPersist, onPersistMethods inherited from class org.ameba.integration.jpa.BaseEntity
getCreatedBy, getCreateDt, getLastModifiedBy, getLastModifiedDt, getOl, getPk, isNew, setCreatedBy, setCreateDt, setLastModifiedBy, setLastModifiedDt, setOl
-
Field Details
-
NOT_ALLOWED_TO_CREATE_A_ROLE_WITH_AN_EMPTY_NAME
- See Also:
-
immutable
Whether or not this Role is immutable. Immutable Roles can't be modified. -
users
AllUsers assigned to the Role. -
grants
AllSecurityObjects assigned to the Role. -
ROLE_PREFIX
The default prefix String for each created Role. Name is "ROLE_" .- See Also:
-
-
Constructor Details
-
Role
protected Role()Dear JPA... -
Role
Create a new Role with a name.- Parameters:
name- The name of the Role- Throws:
IllegalArgumentException- when name is null or empty
-
Role
Create a new Role with a name and a description.- Parameters:
name- The name of the Roledescription- The description text of the Role- Throws:
IllegalArgumentException- when name is null or empty
-
-
Method Details
-
normalizeName
-
setPersistentKey
- Overrides:
setPersistentKeyin classSecurityObject
-
setName
- Overrides:
setNamein classSecurityObject
-
getImmutable
Get the immutable.- Returns:
- the immutable.
-
setImmutable
Set the Role as immutable.- Parameters:
immutable-trueif so
-
getUsers
Return a Set of allUsers assigned to the Role.- Returns:
- A Set of all
Users assigned to the Role
-
addUser
Add an existingUserto the Role.- Parameters:
user- TheUserto be added- Returns:
- true if the
Userwas new in the collection ofUsers, otherwise false - Throws:
IllegalArgumentException- if user is null
-
addUsers
Add existingUsers to the Role.- Parameters:
users- A Set ofUsers to be added to the Role- Throws:
IllegalArgumentException- if grants is null
-
removeUser
Remove aUserfrom the Role.- Parameters:
user- TheUserto be removed- Throws:
IllegalArgumentException- if user is null
-
setUsers
Set allUsers belonging to this Role.- Parameters:
users- A Set ofUsers to be assigned to the Role- Throws:
IllegalArgumentException- if users is null
-
getGrants
Return a Set of allSecurityObjects belonging to the Role.- Returns:
- A Set of all
SecurityObjects belonging to this Role
-
addGrant
Add an existingSecurityObjectto the Role.- Parameters:
grant- TheSecurityObjectto be added to the Role.- Returns:
- true if the
SecurityObjectwas new to the collection ofSecurityObjects, otherwise false - Throws:
IllegalArgumentException- if grant is null
-
addGrants
Add existingSecurityObjects to the Role.- Parameters:
grants- A Set ofSecurityObjects to be added to the Role- Throws:
IllegalArgumentException- if grants is null
-
removeGrant
Add an existingSecurityObjectto the Role.- Parameters:
grant- TheSecurityObjectto be added to the Role- Returns:
- true if the
SecurityObjectwas successfully removed from the Set ofSecurityObjects, otherwise false - Throws:
IllegalArgumentException- if grant is null
-
removeGrants
Add an existingSecurityObjectto the Role.- Parameters:
grants- A list ofSecurityObjects to be removed from the Role- Returns:
- true if the
SecurityObjectwas successfully removed from the Set ofSecurityObjects, otherwise false - Throws:
IllegalArgumentException- ifgrantsis null
-
setGrants
Set allSecurityObjects assigned to the Role. Already existingSecurityObjects will be removed.- Parameters:
grants- A Set ofSecurityObjects to be assigned to the Role- Throws:
IllegalArgumentException- if grants is null
-
hashCode
public int hashCode()Delegates to the superclass and uses the hashCode of the String ROLE for calculation.
- Overrides:
hashCodein classSecurityObject- See Also:
-
equals
Compare the name.Does not delegate to the
SecurityObject.equals(Object)and uses the name for comparison.- Overrides:
equalsin classSecurityObject- See Also:
-