Package com.isode.dsapi.aci
Class SimpleACIRole
java.lang.Object
com.isode.dsapi.aci.SimpleACIRole
Simple ACI role. This specifies a minimum auth level and the users
that it applies to.
The fields of this class may be accessed directly. There are also methods available to simplify access to some of the fields.
- Since:
- 15.0
- Author:
- jp
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionMinimum authentication level required for this role.Role name.Note to explain intended usage of role, or ""static final Comparator<SimpleACIRole>
Comparator to order SimpleACIRoles by label.boolean
Applies to all users?List of group DNs that it applies to, or nullList of user DNs that it applies to, or nullSimpleACIArea which specifies the regions of the DIT within which user DNs lie that this role applies to, or null -
Constructor Summary
ConstructorsConstructorDescriptionSimpleACIRole
(String label, SimpleACIRole.Auth auth) Create a role with the given label and minimum auth-level, for all users. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addGroupName
(DN dn) Add a name to the 'user_groups' list, creating the list if necessary.void
addUserName
(DN dn) Add a DN to the 'user_names' list, creating the list if necessary.void
Add a new user subtree spec to the 'user_subtree' area, creating the area if necessary.boolean
Test whether two roles' data are identical, apart from their names.int
Calculate a hash value which depends on the 'contents' of the role, but not the name.void
copyFrom
(SimpleACIRole role) Copy data from the given role.deepCopy()
Copy the role.void
dumpXML
(com.isode.util.XMLOutput out) Dump the role out to the given XMLOutput stream.boolean
Test if two roles are identical.Get the original SimpleACIRole associated with this role.boolean
Test whether there have been changes compared to the original role.int
hashCode()
Calculate a hash value which depends on both the 'contents' and the name of the role.boolean
isEmpty()
Return true if this role is empty, i.e.static SimpleACIRole
loadXML
(com.isode.util.XMLInput in) Try to load up a SimpleACIRole from XML.void
Relocate all role-DNs according to the given relocation array (seeSimpleACIWorld.relocate(com.isode.dsapi.DN...)
).void
removeUsersAndGroups
(List<DN> dnlist) Remove all mentions of the given user and/or group DNs from the role.void
Set the note.void
setOriginal
(SimpleACIRole role) Change the original SimpleACIRole used to support hasChanges().void
sort()
Sort contained lists into a consistent order.toString()
Debugging dump.
-
Field Details
-
label
Role name. -
note
Note to explain intended usage of role, or "" -
auth
Minimum authentication level required for this role. -
user_all
public boolean user_allApplies to all users? -
user_names
List of user DNs that it applies to, or null -
user_groups
List of group DNs that it applies to, or null -
user_subtrees
SimpleACIArea which specifies the regions of the DIT within which user DNs lie that this role applies to, or null -
ORDER
Comparator to order SimpleACIRoles by label.
-
-
Constructor Details
-
SimpleACIRole
Create a role with the given label and minimum auth-level, for all users. UseaddUserName(com.isode.dsapi.DN)
,addGroupName(com.isode.dsapi.DN)
and/oraddUserSubtree(com.isode.dsapi.aci.SimpleACIArea.Region)
to make it apply to only specific users or groups.- Parameters:
label
- Name of roleauth
- Minimum auth-level
-
-
Method Details
-
setNote
Set the note. This tidies the note before putting it into 'note', stripping off spaces and tabs at the beginnings or ends of lines.- Parameters:
note
- Note to set, or "". Should never be null.
-
addUserName
Add a DN to the 'user_names' list, creating the list if necessary. If 'user_all' was previously set, it will be cleared by this call.- Parameters:
dn
- User DN
-
addGroupName
Add a name to the 'user_groups' list, creating the list if necessary. If 'user_all' was previously set, it will be cleared by this call.- Parameters:
dn
- Group DN
-
addUserSubtree
Add a new user subtree spec to the 'user_subtree' area, creating the area if necessary. If 'user_all' was previously set, it will be cleared by this call.- Parameters:
ss
- Region to add
-
sort
public void sort()Sort contained lists into a consistent order. This allows equals() and contentsEqual() to work even if values have been loaded back up in a different order. -
relocate
Relocate all role-DNs according to the given relocation array (seeSimpleACIWorld.relocate(com.isode.dsapi.DN...)
).- Parameters:
reloc_arr
- Array containing source/target pairs of DNs specifying the relocations to perform
-
removeUsersAndGroups
Remove all mentions of the given user and/or group DNs from the role.- Parameters:
dnlist
- List of DNs to remove (not null)
-
isEmpty
public boolean isEmpty()Return true if this role is empty, i.e. includes no users.- Returns:
- 'true' if empty, else 'false'.
-
dumpXML
Dump the role out to the given XMLOutput stream.- Throws:
IOException
-
loadXML
Try to load up a SimpleACIRole from XML. Returns null if not found. -
copyFrom
Copy data from the given role.- Parameters:
role
- Role to copy data from, must not be null.
-
deepCopy
Copy the role. This is cheap slow code -- it copies it by converting it via XML. It could perhaps be improved if there was ever a need to do a lot of copying. -
setOriginal
Change the original SimpleACIRole used to support hasChanges(). -
getOriginal
Get the original SimpleACIRole associated with this role. -
hasChanges
public boolean hasChanges()Test whether there have been changes compared to the original role. The role is sorted internally to allow the comparison. If the original role was not set, this method returns false.- Returns:
- TRUE if there have been changes compared to the original role; FALSE otherwise or if the original role was not set.
-
contentsEqual
Test whether two roles' data are identical, apart from their names. The sort() method should be called first if the data was loaded up from different sources, to make sure that lists of DNs compare the same. -
equals
Test if two roles are identical. The sort() method should be called first if the data was loaded up from different sources, to make sure that lists of DNs compare the same. -
contentsHashCode
public int contentsHashCode()Calculate a hash value which depends on the 'contents' of the role, but not the name. This is used for matching up identical roles.- Returns:
- Hash code
-
hashCode
public int hashCode()Calculate a hash value which depends on both the 'contents' and the name of the role. -
toString
Debugging dump.
-