issrg.pba.rbac.xmlpolicy
Class XMLPolicyParser.RoleHierarchyNode

java.lang.Object
  extended by issrg.pba.rbac.xmlpolicy.PolicyXMLNode
      extended by issrg.pba.rbac.xmlpolicy.XMLPolicyParser.RoleHierarchyNode
All Implemented Interfaces:
Role, RoleHierarchyNode
Enclosing class:
XMLPolicyParser

public class XMLPolicyParser.RoleHierarchyNode
extends PolicyXMLNode
implements RoleHierarchyNode

This is the class representing SupRole nodes. It knows its value and its direct subordinates. However, it can always tell you whether a given Role is subordinate to it or not.

Version:
1.0
Author:
A Otenko

Field Summary
protected  int hierarchyLevel
          This is a number, representing how high in the hierarchy this node is located.
protected  XMLPolicyParser.RoleHierarchyNode[] subordinates
           
protected  java.lang.String type
           
protected  java.lang.String value
           
 
Fields inherited from class issrg.pba.rbac.xmlpolicy.PolicyXMLNode
attributes, children, name, nodeStr
 
Constructor Summary
XMLPolicyParser.RoleHierarchyNode(org.xml.sax.Attributes attrs)
           
 
Method Summary
 int getLevel()
          This method returns the hierarchy level of the node.
 java.lang.String getRoleType()
          This method returns the Role Type.
 java.lang.Object getRoleValue()
          This method returns the Role Value as Object (required by issrg.pba.rbac.Role interface).
 java.lang.String getValue()
          This method returns the Role Value as String.
 boolean isSuperiorTo(RoleHierarchyNode rhn)
          This method returns whether or not the given role's privileges should be inherited or not.
 void optimise(java.util.Map roleHierarchy)
          This method links the roles together, using the given Map as a reference to other Roles.
 void setLevel(int level)
          This method sets the hierarchy level of the node.
protected  void setRoleType(java.lang.String t)
          This method sets the type of the role; for use by the Role Spec Policy only at the object initialisation time.
 java.lang.String toString()
          The string representation of this node is the role value.
 
Methods inherited from class issrg.pba.rbac.xmlpolicy.PolicyXMLNode
addChild, addString, construct, getAttributes, getChildren, getName, getString, toXML, toXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hierarchyLevel

protected int hierarchyLevel
This is a number, representing how high in the hierarchy this node is located. It helps to optimise calculations of who is superior to who.

Its property is that hierarchy level of the most superior roles is 0, and that any child role hierarchy level is a bigger integer (not always greater just by one, because this is not a tree). So if this role has bigger integer than another, then the former definitely cannot be superior to the latter.


type

protected java.lang.String type

value

protected java.lang.String value

subordinates

protected XMLPolicyParser.RoleHierarchyNode[] subordinates
Constructor Detail

XMLPolicyParser.RoleHierarchyNode

public XMLPolicyParser.RoleHierarchyNode(org.xml.sax.Attributes attrs)
Method Detail

optimise

public void optimise(java.util.Map roleHierarchy)
              throws PolicyParsingException
This method links the roles together, using the given Map as a reference to other Roles. Before calling this method, it is useless to call getLevel or isSuperiorTo, as they will not be able to determine hierarchical relationships between two roles.

Parameters:
roleHierarchy - - the Map of roles, where the key is the role value, and the value is the RoleHierarchyNode
Throws:
PolicyParsingException

getLevel

public int getLevel()
This method returns the hierarchy level of the node.


setLevel

public void setLevel(int level)
This method sets the hierarchy level of the node. It is set only if the given level is greater (lower position) than the current. It also updates the counter of loops in the hierarchy that appeared by adding this node. Note that the latter counter depends on the sequence of updating the hierarchy.

Parameters:
level - - the least new level of the node; if the node already has a higher level, the level won't be updated; otherwise its level and the level of all of its subordinates will be updated

getValue

public java.lang.String getValue()
This method returns the Role Value as String.


getRoleValue

public java.lang.Object getRoleValue()
This method returns the Role Value as Object (required by issrg.pba.rbac.Role interface).

Specified by:
getRoleValue in interface Role
Returns:
value of the role

getRoleType

public java.lang.String getRoleType()
This method returns the Role Type.

Specified by:
getRoleType in interface Role
Returns:
String type of the role

setRoleType

protected void setRoleType(java.lang.String t)
This method sets the type of the role; for use by the Role Spec Policy only at the object initialisation time.


isSuperiorTo

public boolean isSuperiorTo(RoleHierarchyNode rhn)
This method returns whether or not the given role's privileges should be inherited or not. The node is equal to the current one only if they refer to the same node, or their values are equal.

TODO: do i remove String equality of their values?

Specified by:
isSuperiorTo in interface RoleHierarchyNode
Parameters:
rhn - is the role
Returns:
true, if rhn is equal to, or is subordinate to this node

toString

public java.lang.String toString()
The string representation of this node is the role value.

Overrides:
toString in class PolicyXMLNode
Returns:
a string representation of this XML element; by default returns the XML representation of it