public class XSObject extends oracle.security.xmlsec.util.XMLElement implements Referable
A XSObject is typically used to enclose a
SignatureProperties, Manifest or any other XML or non-XML data
object(s) that are to be signed using an enveloping signature.
This is accomplised by adding an Object to a Signature structure
and making that Object the target of a Reference within the
Signature's SignedInfo.
For example:
XSSignature sig = XSSignature.newInstance("MySignature");
Document doc = sig.getOwnerDocument();
To enclose an arbitrary XML element, create a XSObject
and append the element to it:
Element foo = doc.createElementNS("http://example.com/ns", "Foo");
XSObject obj = sig.createObject();
obj.setId("Foo_1");
obj.appendChild(foo);
sig.addObject(obj);
To enclose an arbitrary non-XML object, append its base64-encoded
bytes as a text node:
File f = new File("/home/john/me.jpeg");
byte[] jpeg = new byte[(int)f.length()];
new DataInputStream(new FileInputStream(f)).readFully(jpeg);
XSObject obj = sig.createObject("MyPicture", "image/jped", "base64");
obj.appendChild(doc.createTextNode(Base64.toBase64(jpeg)));
sig.addObject(obj);
| Constructor and Description |
|---|
XSObject(org.w3c.dom.Document owner)
Creates a new
XSObject instance. |
XSObject(org.w3c.dom.Document owner,
java.lang.String id)
Creates a new
XSObject instance. |
XSObject(org.w3c.dom.Document owner,
java.lang.String id,
java.lang.String mimeType,
java.lang.String encoding)
Creates a new
XSObject instance. |
XSObject(org.w3c.dom.Element element)
Creates a new
XSObject instance
from the given Element node. |
XSObject(org.w3c.dom.Element element,
java.lang.String systemId)
Creates a new
XSObject instance
from the given Element node. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getEncoding()
Returns the value of the Encoding attribute of this Object.
|
java.lang.String |
getId()
Returns the value of the Id attribute of this Object.
|
java.lang.String |
getMimeType()
Returns the value of the MimeType attribute of this Object.
|
java.lang.String |
getType()
Returns the URI defined in the XML-DSIG space to identify
the Object element ("http://www.w3.org/2000/09/xmldsig#Object").
|
void |
setEncoding(java.lang.String encoding)
Sets the Encoding attribute of this Object.
|
void |
setId(java.lang.String id)
Sets the Id attribute of this Object.
|
void |
setMimeType(java.lang.String mimeType)
Sets the MimeType attribute of this Object.
|
addNSPrefixAttr, addNSPrefixAttr, addNSPrefixAttrDefault, addNSPrefixAttrDefault, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getChildElementsByTagName, getChildElementsByTagName, getChildElementsByTagNameNS, getChildElementsByTagNameNS, getDefaultNSPrefix, getElement, getElementsByTagName, getElementsByTagNameNS, getTagName, hasAttribute, hasAttributeNS, removeAttribute, removeAttributeNode, removeAttributeNS, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setDefaultNSPrefixappendChild, appendChild, appendTo, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNode, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getSystemId, hasAttributes, hasChildNodes, insertBefore, insertBefore, isSupported, normalize, removeChild, removeChild, replaceChild, replaceChild, setNodeValue, setPrefix, setSystemId, toBytesXML, toStringXMLpublic XSObject(org.w3c.dom.Element element)
throws org.w3c.dom.DOMException
XSObject instance
from the given Element node.element - An Element node in the XML document that conforms to
the XML-DSIG Object schema.org.w3c.dom.DOMExceptionpublic XSObject(org.w3c.dom.Element element,
java.lang.String systemId)
throws org.w3c.dom.DOMException
XSObject instance
from the given Element node.element - An Element node in the XML document that conforms to
the XML-DSIG Object schema.systemId - The URI string system ID for this element.org.w3c.dom.DOMExceptionXMLNode.setSystemId(java.lang.String)public XSObject(org.w3c.dom.Document owner)
throws org.w3c.dom.DOMException
XSObject instance.owner - The owner document of the new XSObjectorg.w3c.dom.DOMExceptionpublic XSObject(org.w3c.dom.Document owner,
java.lang.String id)
throws org.w3c.dom.DOMException
XSObject instance.owner - The owner document of the new XSObject.id - An optional string ID name for this XSObject structure.org.w3c.dom.DOMExceptionpublic XSObject(org.w3c.dom.Document owner,
java.lang.String id,
java.lang.String mimeType,
java.lang.String encoding)
throws org.w3c.dom.DOMException
XSObject instance.owner - The owner document of the new XSObject.id - An optional string ID name for this XSObject structure.mimeType - An optional string describing the data within the object,
as defined in the MIME specification.encoding - An optional URI identifying the enclosed object's encoding method.org.w3c.dom.DOMExceptionpublic void setMimeType(java.lang.String mimeType)
throws org.w3c.dom.DOMException
mimeType - A string describing the MIME type of the data within this Object.org.w3c.dom.DOMExceptionpublic java.lang.String getMimeType()
null if the attribute is missing.public void setEncoding(java.lang.String encoding)
throws org.w3c.dom.DOMException
encoding - A URI identifying the encoding method of the enclosed object.org.w3c.dom.DOMExceptionpublic java.lang.String getEncoding()
null if the attribute is missing.public void setId(java.lang.String id)
throws org.w3c.dom.DOMException
public java.lang.String getId()
public java.lang.String getType()