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
User
s. Basically more than one User
belong to a Role. Security access policies are assigned to Roles
instead of User
s.- Author:
- Heiko Scherrer
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A builder class to construct Role instances. -
Field Summary
Modifier and TypeFieldDescriptionprivate Set
<SecurityObject> AllSecurityObject
s assigned to the Role.private Boolean
Whether or not this Role is immutable.static final String
static final String
The default prefix String for each created Role.AllUser
s assigned to the Role.Fields inherited from class org.ameba.integration.jpa.ApplicationEntity
C_ID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addGrant
(SecurityObject grant) Add an existingSecurityObject
to the Role.void
addGrants
(Set<SecurityObject> grants) Add existingSecurityObject
s to the Role.boolean
Add an existingUser
to the Role.void
Add existingUser
s to the Role.boolean
Compare the name.Return a Set of allSecurityObject
s belonging to the Role.Get the immutable.getUsers()
Return a Set of allUser
s assigned to the Role.int
hashCode()
normalizeName
(String name) boolean
removeGrant
(SecurityObject grant) Add an existingSecurityObject
to the Role.boolean
removeGrants
(List<? extends SecurityObject> grants) Add an existingSecurityObject
to the Role.void
removeUser
(User user) Remove aUser
from the Role.void
setGrants
(Set<SecurityObject> grants) Set allSecurityObject
s assigned to the Role.void
setImmutable
(Boolean immutable) Set the Role as immutable.protected void
void
setPersistentKey
(String pKey) void
Set allUser
s belonging to this Role.Methods inherited from class org.openwms.core.uaa.impl.SecurityObject
getDescription, getName, setDescription, toString
Methods inherited from class org.ameba.integration.jpa.ApplicationEntity
getPersistentKey, hasPersistentKey, onEntityPersist, onPersist
Methods 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
AllUser
s assigned to the Role. -
grants
AllSecurityObject
s 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:
setPersistentKey
in classSecurityObject
-
setName
- Overrides:
setName
in classSecurityObject
-
getImmutable
Get the immutable.- Returns:
- the immutable.
-
setImmutable
Set the Role as immutable.- Parameters:
immutable
-true
if so
-
getUsers
Return a Set of allUser
s assigned to the Role.- Returns:
- A Set of all
User
s assigned to the Role
-
addUser
Add an existingUser
to the Role.- Parameters:
user
- TheUser
to be added- Returns:
- true if the
User
was new in the collection ofUser
s, otherwise false - Throws:
IllegalArgumentException
- if user is null
-
addUsers
Add existingUser
s to the Role.- Parameters:
users
- A Set ofUser
s to be added to the Role- Throws:
IllegalArgumentException
- if grants is null
-
removeUser
Remove aUser
from the Role.- Parameters:
user
- TheUser
to be removed- Throws:
IllegalArgumentException
- if user is null
-
setUsers
Set allUser
s belonging to this Role.- Parameters:
users
- A Set ofUser
s to be assigned to the Role- Throws:
IllegalArgumentException
- if users is null
-
getGrants
Return a Set of allSecurityObject
s belonging to the Role.- Returns:
- A Set of all
SecurityObject
s belonging to this Role
-
addGrant
Add an existingSecurityObject
to the Role.- Parameters:
grant
- TheSecurityObject
to be added to the Role.- Returns:
- true if the
SecurityObject
was new to the collection ofSecurityObject
s, otherwise false - Throws:
IllegalArgumentException
- if grant is null
-
addGrants
Add existingSecurityObject
s to the Role.- Parameters:
grants
- A Set ofSecurityObject
s to be added to the Role- Throws:
IllegalArgumentException
- if grants is null
-
removeGrant
Add an existingSecurityObject
to the Role.- Parameters:
grant
- TheSecurityObject
to be added to the Role- Returns:
- true if the
SecurityObject
was successfully removed from the Set ofSecurityObject
s, otherwise false - Throws:
IllegalArgumentException
- if grant is null
-
removeGrants
Add an existingSecurityObject
to the Role.- Parameters:
grants
- A list ofSecurityObject
s to be removed from the Role- Returns:
- true if the
SecurityObject
was successfully removed from the Set ofSecurityObject
s, otherwise false - Throws:
IllegalArgumentException
- ifgrants
is null
-
setGrants
Set allSecurityObject
s assigned to the Role. Already existingSecurityObject
s will be removed.- Parameters:
grants
- A Set ofSecurityObject
s 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:
hashCode
in classSecurityObject
- See Also:
-
equals
Compare the name.Does not delegate to the
SecurityObject.equals(Object)
and uses the name for comparison.- Overrides:
equals
in classSecurityObject
- See Also:
-