org.openxri.xml
Class XRD

java.lang.Object
  extended by org.openxri.xml.XRD
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class XRD
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

This class describes the XRD XML element used for XRI Authority resolution.

Author:
=chetan, =wil
See Also:
Serialized Form

Field Summary
static java.lang.String CURRENT_VERSION
           
 
Constructor Summary
XRD()
          Constructs an empty XRD
XRD(org.w3c.dom.Element oElem, boolean bKeepDOM)
          This method creates the XRD from DOM.
 
Method Summary
 void addCanonicalID(CanonicalID canonicalId)
          Deprecated.  
 void addEquivID(EquivID equivID)
           
 void addLocalID(LocalID localId)
           
 void addRedirect(Redirect redirect)
           
 void addRef(Ref ref)
           
 void addService(Service service)
          Adds a service element
 void clearDOM()
          This method resets any DOM state in the XRI Descriptor.
 java.lang.Object clone()
          Clone this object
 void fromDOM(org.w3c.dom.Element oElem)
          This method populates the object from DOM.
 void genXmlID()
          Generates a new id attribute and sets it
 CanonicalEquivID getCanonicalEquivID()
          Gets the CanonicalEquivID
 CanonicalID getCanonicalID()
          Gets the CanonicalID
 CanonicalID getCanonicalidAt(int n)
          Deprecated.  
 org.w3c.dom.Element getDOM()
          This method returns DOM stored with this object.
 EquivID getEquivIDAt(int n)
           
 java.util.Date getExpires()
          Returns the expires element value
 java.lang.String getExtension()
           
 LocalID getLocalIDAt(int n)
           
 int getNumCanonicalids()
          Deprecated.  
 int getNumEquivIDs()
           
 int getNumLocalIDs()
           
 int getNumRedirects()
           
 int getNumRefs()
           
 int getNumServices()
          Returns the number of services elements
 int getNumTypes()
          Returns the number of services elements
 java.util.Vector getOtherTagValues(java.lang.String sTag)
          Returns unspecified simple elements in the Service by Tag
 java.util.ArrayList getPrioritizedRedirects()
           
 java.util.ArrayList getPrioritizedRefs()
           
 java.util.ArrayList getPrioritizedServices()
          Returns a vector of all the service elements
 java.lang.String getProviderID()
          Returns the provider id element value
 java.lang.String getQuery()
          Returns the query element value
 Redirect getRedirectAt(int n)
           
 java.util.Vector getRedirects()
           
 Ref getRefAt(int n)
           
 java.util.Vector getRefs()
           
 Assertion getSAMLAssertion()
          Returns the SAML assertion
 PrioritizedList getSelectedServices()
           
 ServerStatus getServerStatus()
           
 java.lang.String getServerStatusCode()
           
 Service getServiceAt(int n)
          Returns the service element at the specified index
 java.util.Vector getServices()
           
 Status getStatus()
           
 java.lang.String getStatusCode()
           
 XRDType getTypeAt(int n)
          Returns the Type element at the specified index
 java.lang.String getXmlID()
          Returns the id attribute
 boolean isValid()
          Checks if this XRD is valid based on the optional Expires element
static XRD parseXRD(java.lang.String xmlStr, boolean bKeepDOM)
          Constructs XRD from a String
 void reset()
          This method resets the state of the XRD.
 java.lang.String serializeDOM(boolean bIndent, boolean bOmitXMLDeclaration)
          Serializes the DOM associated with this XRD.
 void setCanonicalEquivID(CanonicalEquivID ceid)
          Sets the CanonicalEquivID
 void setCanonicalID(CanonicalID cid)
          Sets the CanonicalID
 void setDOM(org.w3c.dom.Element oElem)
          This method will import an XRD from DOM, and hold on to it, as retrievable by getDOM.
 void setEquivIDs(java.util.Collection col)
           
 void setExpires(java.util.Date d)
          Sets the expires element value
 void setExtension(java.lang.String extension)
           
 boolean setOtherTagValues(java.lang.String sTag, java.lang.String sTagValue)
          Stores simple elements in the Service by Tag Here we are converting the String object that is being passed into XML Element before storing it into moOtherChildrenVectorsMap Vector.
 void setProviderID(java.lang.String sVal)
          Sets the provider id element value
 void setQuery(java.lang.String sVal)
          Sets the query element value
 void setRedirects(java.util.Collection col)
           
 void setRefs(java.util.Collection col)
           
 void setSAMLAssertion(Assertion oSAMLAssertion)
          Sets the SAML assertion
 void setSelectedServices(java.util.Collection svcs)
           
 void setServerStatus(ServerStatus serverStatus)
          Sets the ServerStatus
 void setServices(java.util.Collection col)
           
 void setStatus(Status status)
           
 void setXmlID(java.lang.String sVal)
          Sets the id attribute
 void sign(java.security.PrivateKey oKey)
          This will sign the XRD using the provided Private Key.
 org.w3c.dom.Element toDOM(org.w3c.dom.Document doc)
          This method will make DOM using the specified document.
 org.w3c.dom.Element toDOM(org.w3c.dom.Document doc, boolean wantFiltered)
          This method create a DOM using the specified document.
 java.lang.String toResultString()
          Returns this XRD with only the selected services (filtered and sorted) as XML.
 java.lang.String toString()
          Returns object as a formatted XML string.
 void verifySignature(java.security.PublicKey oPubKey)
          This will verify the XRD against the given public key.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CURRENT_VERSION

public static final java.lang.String CURRENT_VERSION
See Also:
Constant Field Values
Constructor Detail

XRD

public XRD()
Constructs an empty XRD


XRD

public XRD(org.w3c.dom.Element oElem,
           boolean bKeepDOM)
    throws java.net.URISyntaxException,
           java.text.ParseException
This method creates the XRD from DOM. It optionally keeps a pointer to the DOM.

Parameters:
oElem - - The DOM to create the object from
bKeepDOM - - If true, will keep a copy of the DOM with the object
Throws:
java.net.URISyntaxException
java.text.ParseException
Method Detail

reset

public void reset()
This method resets the state of the XRD.


clone

public java.lang.Object clone()
Clone this object

Overrides:
clone in class java.lang.Object

parseXRD

public static XRD parseXRD(java.lang.String xmlStr,
                           boolean bKeepDOM)
                    throws java.net.URISyntaxException,
                           java.text.ParseException
Constructs XRD from a String

Throws:
java.net.URISyntaxException
java.text.ParseException

fromDOM

public void fromDOM(org.w3c.dom.Element oElem)
             throws java.net.URISyntaxException,
                    java.text.ParseException
This method populates the object from DOM. It does not keep a copy of the DOM around. Whitespace information is lost in this process.

Throws:
java.net.URISyntaxException
java.text.ParseException

serializeDOM

public java.lang.String serializeDOM(boolean bIndent,
                                     boolean bOmitXMLDeclaration)
Serializes the DOM associated with this XRD. Will create DOM if no DOM is already stored.

Parameters:
bIndent - - whether or not to indent the XML. If true will break signature.
bOmitXMLDeclaration - - whether or not to omit the XML preamble

toString

public java.lang.String toString()
Returns object as a formatted XML string.

Overrides:
toString in class java.lang.Object
Parameters:
sTab - - The characters to prepend before each new line

toResultString

public java.lang.String toResultString()
Returns this XRD with only the selected services (filtered and sorted) as XML.

Returns:

getDOM

public org.w3c.dom.Element getDOM()
This method returns DOM stored with this object. It may be cached and there is no guarantee as to which document it was created from


setDOM

public void setDOM(org.w3c.dom.Element oElem)
            throws java.net.URISyntaxException,
                   java.text.ParseException
This method will import an XRD from DOM, and hold on to it, as retrievable by getDOM. The fromDOM method, on the otherhand, will not keep a copy of the DOM.

Throws:
java.net.URISyntaxException
java.text.ParseException

clearDOM

public void clearDOM()
This method resets any DOM state in the XRI Descriptor. It is useful for keeping memory consumption low.


toDOM

public org.w3c.dom.Element toDOM(org.w3c.dom.Document doc,
                                 boolean wantFiltered)
This method create a DOM using the specified document. If the wantFiltered argument is true, the returned document will have all prioritized elements sorted and only selected services are returned.

Parameters:
doc - - The document to use for generating DOM
wantFiltered - - Get sorted+filtered Refs and Services

toDOM

public org.w3c.dom.Element toDOM(org.w3c.dom.Document doc)
This method will make DOM using the specified document. If any DOM state has been stored with the object, it will not be used in this method. This method generates a reference-free copy of new DOM.

Parameters:
doc - - The document to use for generating DOM

setOtherTagValues

public boolean setOtherTagValues(java.lang.String sTag,
                                 java.lang.String sTagValue)
Stores simple elements in the Service by Tag Here we are converting the String object that is being passed into XML Element before storing it into moOtherChildrenVectorsMap Vector. The reason we are doing this is, we need to preserve NameSpaces, and also support a scenario where a Child Element under Service Element, can have Sub Elements. With this it will preserve all the Text Nodes under the Sub Element.

Parameters:
sTag - - The tag name. Needs to be the Fully Qualified Name of the XML Element. For Example "usrns1:info1" or "info1" (If not using NameSpaces)
sTagValue - - The tag values. Needs to be valid XML String like -- "Newton"
Returns:
-- Boolean - -True if the String could be Successfully Parsed and Stored, Else it will return false

getOtherTagValues

public java.util.Vector getOtherTagValues(java.lang.String sTag)
Returns unspecified simple elements in the Service by Tag

Parameters:
sTag - - The tag name to get values for
Returns:
a vector of text values whose element tag names match sTag

setExtension

public void setExtension(java.lang.String extension)
                  throws java.net.URISyntaxException,
                         java.text.ParseException
Throws:
java.net.URISyntaxException
java.text.ParseException

getExtension

public java.lang.String getExtension()

getXmlID

public java.lang.String getXmlID()
Returns the id attribute

Returns:
String The authority id element

setXmlID

public void setXmlID(java.lang.String sVal)
Sets the id attribute


genXmlID

public void genXmlID()
Generates a new id attribute and sets it


getProviderID

public java.lang.String getProviderID()
Returns the provider id element value


setProviderID

public void setProviderID(java.lang.String sVal)
Sets the provider id element value


getQuery

public java.lang.String getQuery()
Returns the query element value


setQuery

public void setQuery(java.lang.String sVal)
Sets the query element value


getExpires

public java.util.Date getExpires()
Returns the expires element value


setExpires

public void setExpires(java.util.Date d)
Sets the expires element value


getNumLocalIDs

public int getNumLocalIDs()

getLocalIDAt

public LocalID getLocalIDAt(int n)

addLocalID

public void addLocalID(LocalID localId)

getNumEquivIDs

public int getNumEquivIDs()

getEquivIDAt

public EquivID getEquivIDAt(int n)

addEquivID

public void addEquivID(EquivID equivID)

getNumCanonicalids

public int getNumCanonicalids()
Deprecated. 


getCanonicalidAt

public CanonicalID getCanonicalidAt(int n)
Deprecated. 


addCanonicalID

public void addCanonicalID(CanonicalID canonicalId)
Deprecated. 


setCanonicalID

public void setCanonicalID(CanonicalID cid)
Sets the CanonicalID


getCanonicalID

public CanonicalID getCanonicalID()
Gets the CanonicalID


setCanonicalEquivID

public void setCanonicalEquivID(CanonicalEquivID ceid)
Sets the CanonicalEquivID


getCanonicalEquivID

public CanonicalEquivID getCanonicalEquivID()
Gets the CanonicalEquivID


getRefs

public java.util.Vector getRefs()
Returns:
Returns a copy of the collection of Refs in the order as it appears in the original XRD

getRefAt

public Ref getRefAt(int n)

getNumRefs

public int getNumRefs()

addRef

public void addRef(Ref ref)

getPrioritizedRefs

public java.util.ArrayList getPrioritizedRefs()

getRedirects

public java.util.Vector getRedirects()
Returns:
Returns a copy of the collection of Redirects in the order as it appears in the original XRD

getRedirectAt

public Redirect getRedirectAt(int n)

getNumRedirects

public int getNumRedirects()

addRedirect

public void addRedirect(Redirect redirect)

getPrioritizedRedirects

public java.util.ArrayList getPrioritizedRedirects()

getNumServices

public int getNumServices()
Returns the number of services elements


getServiceAt

public Service getServiceAt(int n)
Returns the service element at the specified index


getPrioritizedServices

public java.util.ArrayList getPrioritizedServices()
Returns a vector of all the service elements


addService

public void addService(Service service)
Adds a service element


getNumTypes

public int getNumTypes()
Returns the number of services elements


getTypeAt

public XRDType getTypeAt(int n)
Returns the Type element at the specified index


getSAMLAssertion

public Assertion getSAMLAssertion()
Returns the SAML assertion


setSAMLAssertion

public void setSAMLAssertion(Assertion oSAMLAssertion)
Sets the SAML assertion


sign

public void sign(java.security.PrivateKey oKey)
          throws org.apache.xml.security.exceptions.XMLSecurityException
This will sign the XRD using the provided Private Key. The signature will be kept in DOM. DOM will be created if it doesn't exist already.

Parameters:
oKey - - The private key to sign the descriptor with.
Throws:
org.apache.xml.security.exceptions.XMLSecurityException

verifySignature

public void verifySignature(java.security.PublicKey oPubKey)
                     throws org.apache.xml.security.exceptions.XMLSecurityException
This will verify the XRD against the given public key. DOM must already be associated with this descriptor.

Parameters:
oPubKey -
Throws:
org.apache.xml.security.exceptions.XMLSecurityException

isValid

public boolean isValid()
Checks if this XRD is valid based on the optional Expires element


setStatus

public void setStatus(Status status)

getStatus

public Status getStatus()
Returns:
Returns the status.

getServerStatusCode

public java.lang.String getServerStatusCode()
Returns:
Returns the ServerStatus code.

setServerStatus

public void setServerStatus(ServerStatus serverStatus)
Sets the ServerStatus

Parameters:
serverStatus -

getServerStatus

public ServerStatus getServerStatus()
Returns:
Returns the ServerStatus.

getStatusCode

public java.lang.String getStatusCode()
Returns:
Returns the status code.

getServices

public java.util.Vector getServices()
Returns:
Returns a copy of the collection of services as it appears in the original XRD

setServices

public void setServices(java.util.Collection col)

setSelectedServices

public void setSelectedServices(java.util.Collection svcs)

setEquivIDs

public void setEquivIDs(java.util.Collection col)

setRefs

public void setRefs(java.util.Collection col)

setRedirects

public void setRedirects(java.util.Collection col)

getSelectedServices

public PrioritizedList getSelectedServices()
Returns:
Returns the selectedServices.


Copyright © 2005-2012. All Rights Reserved.