|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openpermis.policy.bean.basic.BasicPart
org.openpermis.policy.bean.basic.BasicPartBean
org.openpermis.policy.bean.basic.BasicRoleHierarchy
public class BasicRoleHierarchy
A DAG of roles.
Nested Class Summary | |
---|---|
private class |
BasicRoleHierarchy.AdjacentSet
Set for Adjacent Roles using SerialNumber as primary key. |
static class |
BasicRoleHierarchy.Direction
|
private class |
BasicRoleHierarchy.RoleSet
Set for Roles using SerialNumber as primary key. |
Field Summary | |
---|---|
private BasicRoleHierarchy.RoleSet |
roles
|
private static long |
serialVersionUID
|
private BasicRoleHierarchy.AdjacentSet |
subroles
|
private BasicRoleHierarchy.AdjacentSet |
superroles
|
Constructor Summary | |
---|---|
protected |
BasicRoleHierarchy(SerialNumber serialNumber,
URI identity)
Creates a role hierarchy. |
Method Summary | |
---|---|
private void |
addEdge(String role,
String subrole)
Adds an edge. precondition: edge not yet exists. |
void |
addRole(String role)
Adds a new role in this role hierarchy, if not yet exists. |
void |
addRole(String role,
Set<String> parentRoles)
Adds a new role in this role hierarchy. |
void |
addRole(String role,
String parentRole)
Adds a new role in this role hierarchy. |
protected void |
appendPartDetails(StringBuilder sb)
Appends the details of this extended part for the string representation of this part. |
private void |
appendRolePartDetails(StringBuilder sb)
|
private boolean |
areRolesEqual(String role1,
String role2)
Checks for equal roles. |
protected boolean |
comparablePart(BasicPart part)
Check if the part specified is comparable to this part. |
boolean |
connectRoles(String parentRole,
String childRole)
Convenience method: add an edge between two roles. |
boolean |
disconnectRoles(String parentRole,
String childRole)
Convenience method: remove an edge between two roles. |
private boolean |
edgeExists(String parentRole,
String childRole)
Returns true if childRole is a child-role of role. |
PartBean |
findBySerialNumber(SerialNumber partSerialNumber)
Returns the part bean corresponding to the specified serial number. The basic implementation returns this bean if its serial number matches the one passed in or null if not. |
private String |
findNodeWithNoSubNodes(BasicRoleHierarchy.Direction direction,
BasicRoleHierarchy.RoleSet subsetRoles)
Try to find any node in given subsetRoles with no successors within given subsetRoles. |
private void |
fireRoleHierarchyEvent()
|
private void |
forceArgumentNotNull(Object obj)
Checks for null-argument. |
private void |
forceEdgeExists(String parentRole,
String childRole)
Checks for existence. |
private void |
forceEdgeNotExists(String parentRole,
String childRole)
Checks for existence. |
private void |
forceRoleExists(String role)
Checks for existence. |
private void |
forceRoleNotExists(String role)
Checks for existence. |
private void |
forceRolesExist(Collection<String> checkRoles)
Checks for existence. |
private BasicRoleHierarchy.RoleSet |
getAdjacentRoles(String role,
BasicRoleHierarchy.Direction direction)
Returns a unmodifiable list of all adjacent role. |
Set<String> |
getChildRoles(String role)
Returns a unmodifiable list of all children. |
Set<String> |
getLeafRoles()
Returns a list of all roles with no children. |
Set<String> |
getParentRoles(String role)
Returns a unmodifiable list of all parents. |
Set<String> |
getRoles()
Returns a unmodifiable list of all roles in this hierarchy. |
Set<String> |
getRootRoles()
Returns a list of all roles with no parents. |
protected String |
getSimpleClassName()
Returns the simple implementation class name of this class. |
Set<String> |
getSubRoles(String role)
Returns all sub roles of 'role' including 'role' itself. |
Set<String> |
getSuperRoles(String role)
Returns all superior roles of 'role' including 'role' itself. |
private BasicRoleHierarchy.RoleSet |
getTransitiveClosure(String role,
BasicRoleHierarchy.Direction direction)
|
private boolean |
inTransitiveClosure(String role,
String findRole,
BasicRoleHierarchy.Direction direction)
Returns true if there's a way from "role" to "findrole" using given direction. precondition: role exists and graph is cycle-free |
boolean |
isChildRole(String role,
String childRole)
Returns true if childRole is a child-role of role. |
boolean |
isLeafRole(String role)
Returns true if role is leaf, i.e. has no children. |
boolean |
isParentRole(String role,
String parentRole)
Returns true if parentRole is a parent-role of role. |
boolean |
isPartValid(PartProblemReporter reporter)
Checks if the extended state of this part is valid. |
boolean |
isRootRole(String role)
Returns true if role is root, i.e. has no parents. |
boolean |
isSubRole(String role,
String subRole)
Returns true if subRole is a sub-role of role. |
boolean |
isSuperRole(String role,
String superRole)
Returns true if superRole is a super-role of role. |
private void |
removeEdge(String role,
String subrole)
Removes an edge. precondition: edge exists. |
void |
removeRole(String role)
Removes a role from role hierarchy |
boolean |
renameRole(String role,
String newName)
Renames an existing role. |
boolean |
roleExists(String role)
Checks if a role exists in this role hierarchy. |
void |
setChildRoles(String role,
Set<String> childrenRoles)
Set new children roles of a role. |
void |
setParentRoles(String role,
Set<String> parentRoles)
Set new parent roles of a role. |
private boolean |
treeClosed()
Check if role tree is closed. |
private boolean |
treeTopologicallySortable()
Check if role tree is cycle-free. |
private boolean |
treeTopologicallySortable(BasicRoleHierarchy.Direction direction)
Check if role tree is cycle-free in the given direction. |
Methods inherited from class org.openpermis.policy.bean.basic.BasicPartBean |
---|
addPropertyChangeListener, equalSerialNumber, firePropertyChange, getPartBeanType, getSerialNumber, getSerialNumberString, notifyIdentityChange, notifyNameChange, removePropertyChangeListener, toShortString |
Methods inherited from class org.openpermis.policy.bean.basic.BasicPart |
---|
appendDetails, equalPart, equals, getIdentity, getName, hashCode, hasPartIdentity, hasPartName, isChildCollectionValid, isChildNotNull, isChildNullOrValid, isChildValid, isIdentityValid, isNameValid, isValid, partHashCode, reportProblem, setIdentity, setName, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.openpermis.policy.Part |
---|
equals, hashCode, isValid, toString |
Methods inherited from interface org.openpermis.policy.Identifiable |
---|
getIdentity |
Methods inherited from interface org.openpermis.policy.bean.PartBean |
---|
addPropertyChangeListener, equalSerialNumber, getPartBeanType, getSerialNumber, removePropertyChangeListener, toShortString |
Methods inherited from interface org.openpermis.policy.Part |
---|
equals, hashCode, isValid, toString |
Methods inherited from interface org.openpermis.policy.bean.IdentifiableBean |
---|
setIdentity |
Methods inherited from interface org.openpermis.policy.Identifiable |
---|
getIdentity |
Field Detail |
---|
private static final long serialVersionUID
-1728538401158979463L
private final BasicRoleHierarchy.RoleSet roles
private final BasicRoleHierarchy.AdjacentSet subroles
private final BasicRoleHierarchy.AdjacentSet superroles
Constructor Detail |
---|
protected BasicRoleHierarchy(SerialNumber serialNumber, URI identity)
serialNumber
- the serial number of this part.Method Detail |
---|
private void fireRoleHierarchyEvent()
private boolean areRolesEqual(String role1, String role2)
role1
- the first rolerole2
- the second role
private boolean edgeExists(String parentRole, String childRole)
parentRole
- the role to start search from..childRole
- the role to find.
true
if found.private void forceArgumentNotNull(Object obj)
obj
- the object to check.private void forceEdgeExists(String parentRole, String childRole)
parentRole
- the role to start search from..childRole
- the role to find.private void forceEdgeNotExists(String parentRole, String childRole)
parentRole
- the role to start search from..childRole
- the role to find.private void forceRoleExists(String role)
role
- the role to checkprivate void forceRolesExist(Collection<String> checkRoles)
checkRoles
- the roles to checkprivate void forceRoleNotExists(String role)
role
- the role to checkprivate void addEdge(String role, String subrole)
role
- the parent role.subrole
- the child role.private void removeEdge(String role, String subrole)
role
- the parent role.subrole
- the child role.private String findNodeWithNoSubNodes(BasicRoleHierarchy.Direction direction, BasicRoleHierarchy.RoleSet subsetRoles)
subsetRoles
- the subset to search in.private boolean treeTopologicallySortable(BasicRoleHierarchy.Direction direction)
private boolean treeTopologicallySortable()
private boolean treeClosed()
private BasicRoleHierarchy.RoleSet getAdjacentRoles(String role, BasicRoleHierarchy.Direction direction)
role
- role to search fordirection
- {DIRECTION_CHILDREN, DIRECTION_PARENTS}
private BasicRoleHierarchy.RoleSet getTransitiveClosure(String role, BasicRoleHierarchy.Direction direction)
private boolean inTransitiveClosure(String role, String findRole, BasicRoleHierarchy.Direction direction)
role
- the role to start search.findRole
- the role to find
true
if the findRole could be found.public Set<String> getSuperRoles(String role)
getSuperRoles
in interface RoleHierarchy
role
- identifies a role in the hierarchy.
public Set<String> getSubRoles(String role)
getSubRoles
in interface RoleHierarchy
role
- identifies a role in the hierarchy.
public boolean roleExists(String role)
roleExists
in interface RoleHierarchyBean
role
- the role to search.
public Set<String> getRoles()
getRoles
in interface RoleHierarchyBean
public Set<String> getRootRoles()
getRootRoles
in interface RoleHierarchyBean
public Set<String> getLeafRoles()
getLeafRoles
in interface RoleHierarchyBean
public Set<String> getChildRoles(String role)
getChildRoles
in interface RoleHierarchyBean
public Set<String> getParentRoles(String role)
getParentRoles
in interface RoleHierarchyBean
public boolean isRootRole(String role)
isRootRole
in interface RoleHierarchyBean
role
- the role to check.
true
if found.public boolean isLeafRole(String role)
isLeafRole
in interface RoleHierarchyBean
role
- the role to check.
true
if found.public boolean isSubRole(String role, String subRole)
isSubRole
in interface RoleHierarchyBean
role
- the role to start search from.subRole
- the role to find.
true
if found.public boolean isSuperRole(String role, String superRole)
isSuperRole
in interface RoleHierarchyBean
role
- the role to start search from..superRole
- the role to find.
true
if found.public boolean isChildRole(String role, String childRole)
isChildRole
in interface RoleHierarchyBean
role
- the role to start search from..childRole
- the role to find.
true
if found.public boolean isParentRole(String role, String parentRole)
isParentRole
in interface RoleHierarchyBean
role
- the role to start search from..parentRole
- the role to find.
true
if found.public void setChildRoles(String role, Set<String> childrenRoles)
setChildRoles
in interface RoleHierarchyBean
role
- role to set children for.childrenRoles
- children roles to setpublic void setParentRoles(String role, Set<String> parentRoles)
setParentRoles
in interface RoleHierarchyBean
role
- role to set parents for.parentRoles
- parent roles to setpublic boolean connectRoles(String parentRole, String childRole)
connectRoles
in interface RoleHierarchyBean
parentRole
- parent role.childRole
- child role
true
if edge was addedpublic boolean disconnectRoles(String parentRole, String childRole)
disconnectRoles
in interface RoleHierarchyBean
parentRole
- parent role.childRole
- child role
true
if edge was removedpublic void addRole(String role)
addRole
in interface RoleHierarchyBean
role
- the new role to be added.public void addRole(String role, String parentRole)
addRole
in interface RoleHierarchyBean
role
- the new role to be added.parentRole
- the parent where the role is appended.public void addRole(String role, Set<String> parentRoles)
addRole
in interface RoleHierarchyBean
role
- the new role to be added.parentRoles
- the parents where the role is appended.public void removeRole(String role)
removeRole
in interface RoleHierarchyBean
role
- the role to be removed.public boolean renameRole(String role, String newName)
RoleHierarchyBean
The renamed role will keep its super and sub roles.
renameRole
in interface RoleHierarchyBean
role
- the role to be renamed.newName
- the new name for the role
true
if role was renamed.public PartBean findBySerialNumber(SerialNumber partSerialNumber)
BasicPartBean
If the part bean contains other part beans, it searches its child beans recursively.
The basic implementation returns this bean if its serial number matches
the one passed in or null
if not. Subclasses that contain other
parts must traverse their children.
findBySerialNumber
in interface PartBean
findBySerialNumber
in class BasicPartBean
partSerialNumber
- the SerialNumber
of the part bean to return.
PartBean
or null
if no
matching part bean is found.public boolean isPartValid(PartProblemReporter reporter)
BasicPart
isPartValid
in class BasicPart
reporter
- the problem reporter to use, may be null
.BasicPart
,
Part.isValid(PartProblemReporter)
,
BasicPart.reportProblem(org.openpermis.policy.PartProblemReporter, org.openpermis.policy.PartProblemReporter.ProblemMessage, java.lang.Object...)
protected boolean comparablePart(BasicPart part)
BasicPart
comparablePart
in class BasicPart
part
- the part to check.
true
if the part supplied is comparable to this part.BasicPart
protected String getSimpleClassName()
BasicPart
If your implementation represents an interface implementation return the interface
simple class name here. In short: return the instance you are checking against in
BasicPart.comparablePart(BasicPart)
.
getSimpleClassName
in class BasicPart
private void appendRolePartDetails(StringBuilder sb)
protected void appendPartDetails(StringBuilder sb)
BasicPart
appendPartDetails
in class BasicPart
sb
- the string builder to add the details to.BasicPart
,
BasicPart.appendDetails(StringBuilder, String, Object)
|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
PERMIS Role Based Access Control 0.4.0 (Build 15)
2009/05/20 08:14:59
Copyright (c) 2002-2007 Ergon Informatik AG