Constructors Summary |
---|
public XMLSignatureInput(byte[] inputOctets)Construct a XMLSignatureInput from an octet array.
This is a comfort method, which internally converts the byte[] array into an InputStream
NOTE: no defensive copy
// NO defensive copy
//this._inputOctetStreamProxy = new ByteArrayInputStream(inputOctets);
this.bytes=inputOctets;
|
public XMLSignatureInput(InputStream inputOctetStream)Constructs a XMLSignatureInput from an octet stream. The
stream is directly read.
this._inputOctetStreamProxy=inputOctetStream;
//this(JavaUtils.getBytesFromStream(inputOctetStream));
|
public XMLSignatureInput(String inputStr)Construct a XMLSignatureInput from a String.
This is a comfort method, which internally converts the String into a byte[] array using the {@link java.lang.String#getBytes()} method.
this(inputStr.getBytes());
|
public XMLSignatureInput(String inputStr, String encoding)Construct a XMLSignatureInput from a String with a given encoding.
This is a comfort method, which internally converts the String into a byte[] array using the {@link java.lang.String#getBytes()} method.
this(inputStr.getBytes(encoding));
|
public XMLSignatureInput(Node rootNode)Construct a XMLSignatureInput from a subtree rooted by rootNode. This
method included the node and all his descendants in the output.
this._subNode = rootNode;
|
public XMLSignatureInput(Set inputNodeSet)Constructor XMLSignatureInput
this._inputNodeSet = inputNodeSet;
|
Methods Summary |
---|
public void | addNodeFilter(com.sun.org.apache.xml.internal.security.signature.NodeFilter filter)
if (isOctetStream()) {
try {
convertToNodes();
} catch (Exception e) {
throw new XMLSecurityRuntimeException("signature.XMLSignatureInput.nodesetReference",e);
}
}
nodeFilters.add(filter);
|
void | convertToNodes()
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
dfactory.setValidating(false);
dfactory.setNamespaceAware(true);
DocumentBuilder db = dfactory.newDocumentBuilder();
// select all nodes, also the comments.
try {
db.setErrorHandler(new com.sun.org.apache.xml.internal.security.utils
.IgnoreAllErrorHandler());
Document doc = db.parse(this.getOctetStream());
XMLUtils.circumventBug2650(doc);
this._subNode=doc.getDocumentElement();
} catch (SAXException ex) {
// if a not-wellformed nodeset exists, put a container around it...
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write("<container>".getBytes());
baos.write(this.getBytes());
baos.write("</container>".getBytes());
byte result[] = baos.toByteArray();
Document document = db.parse(new ByteArrayInputStream(result));
this._subNode=document.getDocumentElement().getFirstChild().getFirstChild();
}
this._inputOctetStreamProxy=null;
this.bytes=null;
|
public byte[] | getBytes()Returns the byte array from input which was specified as the parameter of {@link XMLSignatureInput} constructor
if (bytes!=null) {
return bytes;
}
InputStream is = getResetableInputStream();
if (is!=null) {
//reseatable can read again bytes.
if (bytes==null) {
is.reset();
bytes=JavaUtils.getBytesFromStream(is);
}
return bytes;
}
Canonicalizer20010315OmitComments c14nizer =
new Canonicalizer20010315OmitComments();
bytes=c14nizer.engineCanonicalize(this);
return bytes;
|
public org.w3c.dom.Node | getExcludeNode()Gets the exclude node of this XMLSignatureInput
return excludeNode;
|
public java.lang.String | getHTMLRepresentation()Method getHTMLRepresentation
XMLSignatureInputDebugger db = new XMLSignatureInputDebugger(this);
return db.getHTMLRepresentation();
|
public java.lang.String | getHTMLRepresentation(java.util.Set inclusiveNamespaces)Method getHTMLRepresentation
XMLSignatureInputDebugger db = new XMLSignatureInputDebugger( this,
inclusiveNamespaces);
return db.getHTMLRepresentation();
|
public java.lang.String | getMIMEType()Returns MIMEType
return this._MIMEType;
|
public java.util.List | getNodeFilters()
// TODO Auto-generated method stub
return nodeFilters;
|
public java.util.Set | getNodeSet(boolean circunvent)Returns the node set from input which was specified as the parameter of {@link XMLSignatureInput} constructor
if (this._inputNodeSet!=null) {
return this._inputNodeSet;
}
if (this.isElement()) {
if (circunvent) {
XMLUtils.circumventBug2650(XMLUtils.getOwnerDocument(_subNode));
}
this._inputNodeSet = new HashSet();
XMLUtils.getSet(_subNode,this._inputNodeSet, excludeNode, this.excludeComments);
return this._inputNodeSet;
}
else if (this.isOctetStream()) {
convertToNodes();
HashSet result=new HashSet();
XMLUtils.getSet(_subNode, result,null,false);
//this._inputNodeSet=result;
return result;
}
throw new RuntimeException(
"getNodeSet() called but no input data present");
|
public java.util.Set | getNodeSet()Returns the node set from input which was specified as the parameter of {@link XMLSignatureInput} constructor
return getNodeSet(false);
|
public java.io.InputStream | getOctetStream()Returns the Octect stream(byte Stream) from input which was specified as the parameter of {@link XMLSignatureInput} constructor
return getResetableInputStream();
|
public java.io.InputStream | getOctetStreamReal()
return this._inputOctetStreamProxy;
|
protected java.io.InputStream | getResetableInputStream()
if ((_inputOctetStreamProxy instanceof ByteArrayInputStream) ) {
if (!_inputOctetStreamProxy.markSupported()) {
throw new RuntimeException("Accepted as Markable but not truly been"+_inputOctetStreamProxy);
}
return _inputOctetStreamProxy;
}
if (bytes!=null) {
_inputOctetStreamProxy=new ByteArrayInputStream(bytes);
return _inputOctetStreamProxy;
}
if (_inputOctetStreamProxy ==null)
return null;
if (_inputOctetStreamProxy.markSupported()) {
if (log.isLoggable(java.util.logging.Level.INFO)) log.log(java.util.logging.Level.INFO, "Mark Suported but not used as reset");
}
bytes=JavaUtils.getBytesFromStream(_inputOctetStreamProxy);
_inputOctetStreamProxy.close();
_inputOctetStreamProxy=new ByteArrayInputStream(bytes);
return _inputOctetStreamProxy;
|
public java.lang.String | getSourceURI()Return SourceURI
return this._SourceURI;
|
public org.w3c.dom.Node | getSubNode()Gets the node of this XMLSignatureInput
return _subNode;
|
public boolean | isByteArray()Determines if the object has been set up with a ByteArray
return ( (bytes!=null)
&& ((this._inputNodeSet == null) && _subNode ==null));
|
public boolean | isElement()Determines if the object has been set up with an Element
return ((this._inputOctetStreamProxy==null)&& (this._subNode!=null)
&& (this._inputNodeSet==null) && !isNodeSet
);
|
public boolean | isExcludeComments()
return excludeComments;
|
public boolean | isInitialized()Is the object correctly set up?
return (this.isOctetStream() || this.isNodeSet());
|
public boolean | isNeedsToBeExpanded()Check if the structured is needed to be circumbented.
return needsToBeExpanded;
|
public boolean | isNodeSet()Determines if the object has been set up with a Node set
return (( (this._inputOctetStreamProxy == null)
&& (this._inputNodeSet != null) ) || isNodeSet);
|
public boolean | isOctetStream()Determines if the object has been set up with an octet stream
return ( ((this._inputOctetStreamProxy != null) || bytes!=null)
&& ((this._inputNodeSet == null) && _subNode ==null));
|
public void | setExcludeComments(boolean excludeComments)
this.excludeComments = excludeComments;
|
public void | setExcludeNode(org.w3c.dom.Node excludeNode)Sets the exclude node of this XMLSignatureInput
this.excludeNode = excludeNode;
|
public void | setMIMEType(java.lang.String MIMEType)Sets MIMEType
this._MIMEType = MIMEType;
|
public void | setNeedsToBeExpanded(boolean needsToBeExpanded)Set if the structured is needed to be circumbented.
this.needsToBeExpanded = needsToBeExpanded;
|
public void | setNodeSet(boolean b)
isNodeSet=b;
|
public void | setOutputStream(java.io.OutputStream os)
outputStream=os;
|
public void | setSourceURI(java.lang.String SourceURI)Sets SourceURI
this._SourceURI = SourceURI;
|
public java.lang.String | toString()Method toString
if (this.isNodeSet()) {
return "XMLSignatureInput/NodeSet/" + this._inputNodeSet.size()
+ " nodes/" + this.getSourceURI();
}
if (this.isElement()) {
return "XMLSignatureInput/Element/" + this._subNode
+ " exclude "+ this.excludeNode + " comments:" +
this.excludeComments
+"/" + this.getSourceURI();
}
try {
return "XMLSignatureInput/OctetStream/" + this.getBytes().length
+ " octets/" + this.getSourceURI();
} catch (Exception ex) {
return "XMLSignatureInput/OctetStream//" + this.getSourceURI();
}
|
public void | updateOutputStream(java.io.OutputStream diOs)
if (diOs==outputStream) {
return;
}
if (bytes!=null) {
diOs.write(bytes);
return;
}else if (_inputOctetStreamProxy==null) {
Canonicalizer20010315OmitComments c14nizer =
new Canonicalizer20010315OmitComments();
c14nizer.setWriter(diOs);
c14nizer.engineCanonicalize(this);
return;
} else {
InputStream is = getResetableInputStream();
if (bytes!=null) {
//already read write it, can be rea.
diOs.write(bytes,0,bytes.length);
return;
}
is.reset();
int num;
byte[] bytesT = new byte[1024];
while ((num=is.read(bytesT))>0) {
diOs.write(bytesT,0,num);
}
}
|