|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object issrg.pba.rbac.xmlpolicy.XMLPolicyParser
public class XMLPolicyParser
This class parses the given XML into an internal representation. It creates rules for the DelegationPolicy and AccessPolicy objects.
The parser was written in 2000 when XML DOM3 parsers were not readily available with JDK, so we went for a (lightweight) SAX API. Effectively, this parser converts XML into a tree of PolicyXMLNode objects or its subclasses, very much like modern DOM3 parsers convert XML into a tree of Nodes.
To extend the set of XML elements understood by XML Parser, you need to extend the PolicyXMLNode class and provide a special constructor that contains two arguments: XMLPolicyParser and org.xml.sax.Attributes. Note that the inner classes will have an additional implied argument that is of the type of the containing class (for example, this is why the extensions of the PolicyXMLNode internal to this class do not have XMLPolicyParser as one of their parameters to the constructor - it is there implicitly).
This is a Role based implementation, so it constructs the RoleHierarchy along with Role based rules for the Delegation and Access policy objects.
Note that if the XML complies to a different syntax, the results are unpredictable.
Nested Class Summary | |
---|---|
class |
XMLPolicyParser.ActionPolicyNode
The class representing an ActionPolicy XML node. |
class |
XMLPolicyParser.DomainPolicyNode
This class represents the object that can store many Subject or Target Domain specifications. |
class |
XMLPolicyParser.DomainSpecNode
This class represents the abstract DomainSpec, of which there are two extensions: SubjectDomainSpec and TargetDomainSpec. |
class |
XMLPolicyParser.MSoDPolicySetNode
This class represents the MSoDPolicy set. |
class |
XMLPolicyParser.PMIXMLPolicyNode
This class represents the topmost node: the policy. |
class |
XMLPolicyParser.RepositoryPolicyNode
This class represents the RepositoryPolicy node. |
class |
XMLPolicyParser.RoleAssignmentPolicyNode
This node implements the RoleAssignmentPolicy XML node. |
class |
XMLPolicyParser.RoleHierarchyNode
This is the class representing SupRole nodes. |
class |
XMLPolicyParser.RoleHierarchyPolicyNode
This is the class that represents the RoleHierarchyPolicy node. |
class |
XMLPolicyParser.RoleListNode
This is an implementation of Role List. |
class |
XMLPolicyParser.RoleSpecNode
This class is the implementation of the RoleSpec XML node. |
class |
XMLPolicyParser.SOAPolicyNode
This class implements the SOAPolicy XML node. |
class |
XMLPolicyParser.SubjectDomainPolicyNode
This is a simple extension of DomainPolicyNode that makes sure that SubjectPolicy is constructed correctly. |
class |
XMLPolicyParser.SubjectDomainSpecNode
This is a simple extension of DomainSpecNode that makes sure that only SubjectDomainSpecs are interpreted, and no ObjectClasses are allowed. |
class |
XMLPolicyParser.TargetAccessPolicyNode
This class represents the TargetAccessPolicy XML node. |
class |
XMLPolicyParser.TargetDomainPolicyNode
This is a simple extension of DomainPolicyNode that makes sure that TargetPolicy is constructed correctly. |
class |
XMLPolicyParser.TargetDomainSpecNode
This is a simple extension of DomainSpecNode that makes sure that only TargetDomainSpecs are interpreted, and ObjectClasses are allowed. |
Field Summary | |
---|---|
protected org.xml.sax.Attributes |
attrs
This is used when creating new nodes |
protected XMLPolicyParser.RoleAssignmentPolicyNode |
delegationPolicy
This is the reference to the object, containing the rules for role assignment |
protected static java.util.Map |
knownNodes
This is a collection of all known nodes. |
protected org.xml.sax.Locator |
locator
This is a parsing-specific variable. |
protected java.util.Vector |
nodeStack
The node stack represents the current state of the parsing tree. |
protected XMLPolicyParser.PMIXMLPolicyNode |
pmiXMLPolicy
This is the whole Policy as a parsed tree of XML nodes. |
protected XMLPolicyParser.RoleHierarchyPolicyNode |
roleHierarchyPolicy
This is a reference to a <RoleHierarchyPolicy> XML node. |
protected ValidityPeriod |
validityForRoleList
This variable is used by the RoleList node to assign the correct validity period to the roles in the role list. |
Constructor Summary | |
---|---|
protected |
XMLPolicyParser()
|
|
XMLPolicyParser(org.xml.sax.InputSource xmlSource)
This constructor can build a policy out of an InputSource, containing an XML Policy. |
|
XMLPolicyParser(java.lang.String xml)
This constructor can build a policy out of the string representation of the XML. |
Method Summary | |
---|---|
void |
characters(char[] arr,
int start,
int len)
This is a callback function that is invoked by the SAX parsing process. |
void |
endDocument()
VOID |
void |
endElement(java.lang.String URI,
java.lang.String localName,
java.lang.String qName)
This is the end of the recursion body; it is called each time the element closing tag is encountered: You should not invoke it manually. |
void |
endPrefixMapping(java.lang.String prefix)
VOID |
void |
error(org.xml.sax.SAXParseException spe)
|
void |
fatalError(org.xml.sax.SAXParseException spe)
|
java.util.Map |
getAccessRules()
This method returns a Map of Target Access Rules, indexed by action name. |
java.util.Map |
getAssignmentRules()
This method returns the set of delegation and assignment rules, as specified by RoleHierarchyPolicy. |
java.util.Map |
getAuthzTokenParsingRules()
This method returns a Role Hierarchy Policy as the only rule. |
java.util.Set |
getEnvAttributes()
This method returns the Set of environment nodes in a target access policy. |
java.util.List |
getMSoDSet()
This method returns a List of Multi-Session Separation of Duties statements. |
java.lang.String |
getPolicyID()
This method returns the ID of the parsed Policy. |
java.lang.String[] |
getRepositoryURLs()
This method returns the URLs of the repositories specified in the RepositoryPolicy. |
XMLPolicyParser.RoleHierarchyNode |
getRole(java.lang.String roleType,
java.lang.String roleValue)
Returns the role with the given value from the RoleHierarchy. |
java.util.Map |
getSOAs()
This method returns the SOA policy of the current XML policy |
Subtree |
getSubjectDomains()
This method returns the domain covering all the allowed subjects. |
static XMLPolicyParser |
getXMLPolicyParser(java.io.InputStream is)
This is a utility method that parses the policy provided as a InputStream. |
static XMLPolicyParser |
getXMLPolicyParser(java.lang.String policy)
This is a utility method that parses the policy provided as a String. |
void |
ignorableWhitespace(char[] arr,
int start,
int len)
VOID |
static void |
printNodes()
For debugging purposes. |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
VOID |
static void |
registerDefaultNodes()
This method registers a set of default XML Nodes understood by XML Parser. |
static void |
registerXMLNode(java.lang.String nodeName,
java.lang.Class nodeClass)
This method can register any PolicyXMLNode constructor with parameters XMLPolicyParser and org.xml.sax.Attributes to it. |
void |
setDocumentLocator(org.xml.sax.Locator l)
This method sets a source locator, which is used when sending error messages: You should not invoke this method manually. |
void |
skippedEntity(java.lang.String what)
VOID |
void |
startDocument()
|
void |
startElement(java.lang.String URI,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes attrs)
This is the start of the recursion body of the parser; it is called any time the opening tag of an element is encountered: You should not invoke it manually. |
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String URI)
VOID |
void |
warning(org.xml.sax.SAXParseException spe)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.util.Map knownNodes
protected XMLPolicyParser.PMIXMLPolicyNode pmiXMLPolicy
protected java.util.Vector nodeStack
protected XMLPolicyParser.RoleHierarchyPolicyNode roleHierarchyPolicy
protected ValidityPeriod validityForRoleList
protected org.xml.sax.Locator locator
protected XMLPolicyParser.RoleAssignmentPolicyNode delegationPolicy
protected org.xml.sax.Attributes attrs
Constructor Detail |
---|
protected XMLPolicyParser()
public XMLPolicyParser(org.xml.sax.InputSource xmlSource) throws PbaException
xmlSource
- is the source, containing the XML Policy to parse
PbaException
public XMLPolicyParser(java.lang.String xml) throws PbaException
xml
- is the XML text of the policy
PbaException
Method Detail |
---|
public static void registerDefaultNodes()
registerXMLNode(java.lang.String, java.lang.Class)
public static XMLPolicyParser getXMLPolicyParser(java.lang.String policy) throws PbaException
policy
- - the XML text of the PERMIS XML Policy
PbaException,
- if there was a problem parsing the policy
PbaException
public static XMLPolicyParser getXMLPolicyParser(java.io.InputStream is) throws PbaException
is
- - the InputStream with the XML text of the PERMIS XML Policy
PbaException
public static void printNodes()
public static void registerXMLNode(java.lang.String nodeName, java.lang.Class nodeClass) throws java.lang.NoSuchMethodException
nodeName
- is the name of the XML element the provided class can
parsenodeClass
- is the class of the parser; it must have a constructor
with the first parameter
being XMLPolicyParser and the other being org.xml.sax.Attributes,
where XMLPolicyParser will be the reference to the XMLPolicyParser
that performs parsing, and the Attributes is the set of attributes of
the element being parsed
java.lang.NoSuchMethodException
public void skippedEntity(java.lang.String what)
skippedEntity
in interface org.xml.sax.ContentHandler
public void processingInstruction(java.lang.String target, java.lang.String data)
processingInstruction
in interface org.xml.sax.ContentHandler
public void ignorableWhitespace(char[] arr, int start, int len)
ignorableWhitespace
in interface org.xml.sax.ContentHandler
public void characters(char[] arr, int start, int len)
For the details of the parameters please refer to the XML SAX API documentation.
characters
in interface org.xml.sax.ContentHandler
public void startElement(java.lang.String URI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXParseException
startElement
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXParseException
PolicyXMLNode
public void endElement(java.lang.String URI, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
construct
method of the closing element.
endElement
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
public void startDocument()
startDocument
in interface org.xml.sax.ContentHandler
public void endDocument()
endDocument
in interface org.xml.sax.ContentHandler
public void setDocumentLocator(org.xml.sax.Locator l)
setDocumentLocator
in interface org.xml.sax.ContentHandler
public void startPrefixMapping(java.lang.String prefix, java.lang.String URI)
startPrefixMapping
in interface org.xml.sax.ContentHandler
public void endPrefixMapping(java.lang.String prefix)
endPrefixMapping
in interface org.xml.sax.ContentHandler
public void warning(org.xml.sax.SAXParseException spe)
warning
in interface org.xml.sax.ErrorHandler
public void fatalError(org.xml.sax.SAXParseException spe)
fatalError
in interface org.xml.sax.ErrorHandler
public void error(org.xml.sax.SAXParseException spe)
error
in interface org.xml.sax.ErrorHandler
public XMLPolicyParser.RoleHierarchyNode getRole(java.lang.String roleType, java.lang.String roleValue)
roleType
- - the type of the role, as defined in the
RoleHierarchyPolicy; if there is no RoleSpec with this type, null is
returnedroleValue
- - the value of the role of the given type, as defined
in the RoleSpec defining the role hierarchy of the given type
public java.util.Map getAccessRules()
getAccessRules
in interface PolicyParser
public java.util.Map getAssignmentRules()
getAssignmentRules
in interface PolicyParser
AssignmentRule
public java.util.Map getAuthzTokenParsingRules()
getAuthzTokenParsingRules
in interface PolicyParser
public java.lang.String getPolicyID()
getPolicyID
in interface PolicyParser
public java.lang.String[] getRepositoryURLs()
getRepositoryURLs
in interface PolicyParser
public Subtree getSubjectDomains()
public java.util.Map getSOAs()
public java.util.List getMSoDSet()
PolicyParser
Each element in the List is a issrg.pba.rbac.policies.MSoDRule.
getMSoDSet
in interface PolicyParser
public java.util.Set getEnvAttributes()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |