You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2011/01/27 12:11:37 UTC
svn commit: r1064079 [7/12] - in /santuario/xml-security-java/trunk/src:
main/java/javax/xml/crypto/ main/java/javax/xml/crypto/dom/
main/java/javax/xml/crypto/dsig/ main/java/javax/xml/crypto/dsig/dom/
main/java/javax/xml/crypto/dsig/keyinfo/ main/jav...
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/Reference.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/Reference.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/Reference.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/Reference.java Thu Jan 27 11:11:33 2011
@@ -164,7 +164,7 @@ private Element digestValueElement;
// this._manifest.appendChild(this._doc.createTextNode("\n"));
if (transforms != null) {
- this.transforms=transforms;
+ this.transforms=transforms;
this._constructionElement.appendChild(transforms.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
@@ -203,9 +203,9 @@ private Element digestValueElement;
this._baseURI=BaseURI;
Element el=XMLUtils.getNextElement(element.getFirstChild());
if (Constants._TAG_TRANSFORMS.equals(el.getLocalName()) &&
- Constants.SignatureSpecNS.equals(el.getNamespaceURI())) {
- transforms = new Transforms(el,this._baseURI);
- el=XMLUtils.getNextElement(el.getNextSibling());
+ Constants.SignatureSpecNS.equals(el.getNamespaceURI())) {
+ transforms = new Transforms(el,this._baseURI);
+ el=XMLUtils.getNextElement(el.getNextSibling());
}
digestMethodElem = el;
digestValueElement =XMLUtils.getNextElement(digestMethodElem.getNextSibling());;
@@ -230,9 +230,9 @@ private Element digestValueElement;
String uri = digestMethodElem.getAttributeNS(null,
Constants._ATT_ALGORITHM);
- if (uri == null) {
- return null;
- }
+ if (uri == null) {
+ return null;
+ }
return MessageDigestAlgorithm.getInstance(this._doc, uri);
}
@@ -420,19 +420,19 @@ private Element digestValueElement;
* @deprecated use getContentsBeforeTransformation
*/
public XMLSignatureInput getTransformsInput() throws ReferenceNotInitializedException
- {
- XMLSignatureInput input=getContentsBeforeTransformation();
- XMLSignatureInput result;
- try {
- result = new XMLSignatureInput(input.getBytes());
- } catch (CanonicalizationException ex) {
- throw new ReferenceNotInitializedException("empty", ex);
- } catch (IOException ex) {
- throw new ReferenceNotInitializedException("empty", ex);
- }
- result.setSourceURI(input.getSourceURI());
- return result;
-
+ {
+ XMLSignatureInput input=getContentsBeforeTransformation();
+ XMLSignatureInput result;
+ try {
+ result = new XMLSignatureInput(input.getBytes());
+ } catch (CanonicalizationException ex) {
+ throw new ReferenceNotInitializedException("empty", ex);
+ } catch (IOException ex) {
+ throw new ReferenceNotInitializedException("empty", ex);
+ }
+ result.setSourceURI(input.getSourceURI());
+ return result;
+
}
private XMLSignatureInput getContentsAfterTransformation(XMLSignatureInput input, OutputStream os)
@@ -572,7 +572,7 @@ private Element digestValueElement;
InclusiveNamespaces in = new InclusiveNamespaces(
XMLUtils.selectNode(
c14nTransform.getElement().getFirstChild(),
- InclusiveNamespaces.ExclusiveCanonicalizationNamespace,
+ InclusiveNamespaces.ExclusiveCanonicalizationNamespace,
InclusiveNamespaces._TAG_EC_INCLUSIVENAMESPACES,0), this.getBaseURI());
inclusiveNamespaces = InclusiveNamespaces.prefixStr2Set(
@@ -691,20 +691,20 @@ private Element digestValueElement;
DigesterOutputStream diOs=new DigesterOutputStream(mda);
OutputStream os=new UnsyncBufferedOutputStream(diOs);
XMLSignatureInput output=this.dereferenceURIandPerformTransforms(os);
- // if signing and c14n11 property == true explicitly add
- // C14N11 transform if needed
- if (Reference.useC14N11 && !validating &&
- !output.isOutputStreamSet() && !output.isOctetStream()) {
- if (transforms == null) {
- transforms = new Transforms(this._doc);
+ // if signing and c14n11 property == true explicitly add
+ // C14N11 transform if needed
+ if (Reference.useC14N11 && !validating &&
+ !output.isOutputStreamSet() && !output.isOctetStream()) {
+ if (transforms == null) {
+ transforms = new Transforms(this._doc);
this._constructionElement.insertBefore
- (transforms.getElement(), digestMethodElem);
- }
- transforms.addTransform(Transforms.TRANSFORM_C14N11_OMIT_COMMENTS);
+ (transforms.getElement(), digestMethodElem);
+ }
+ transforms.addTransform(Transforms.TRANSFORM_C14N11_OMIT_COMMENTS);
output.updateOutputStream(os, true);
- } else {
+ } else {
output.updateOutputStream(os);
- }
+ }
os.flush();
//this.getReferencedBytes(diOs);
//mda.update(data);
@@ -713,7 +713,7 @@ private Element digestValueElement;
} catch (XMLSecurityException ex) {
throw new ReferenceNotInitializedException("empty", ex);
} catch (IOException ex) {
- throw new ReferenceNotInitializedException("empty", ex);
+ throw new ReferenceNotInitializedException("empty", ex);
}
}
@@ -726,13 +726,13 @@ private Element digestValueElement;
*/
public byte[] getDigestValue() throws Base64DecodingException, XMLSecurityException {
if (digestValueElement == null) {
- // The required element is not in the XML!
- Object[] exArgs ={ Constants._TAG_DIGESTVALUE,
- Constants.SignatureSpecNS };
- throw new XMLSecurityException(
- "signature.Verification.NoSignatureElement",
- exArgs);
- }
+ // The required element is not in the XML!
+ Object[] exArgs ={ Constants._TAG_DIGESTVALUE,
+ Constants.SignatureSpecNS };
+ throw new XMLSecurityException(
+ "signature.Verification.NoSignatureElement",
+ exArgs);
+ }
byte[] elemDig = Base64.decode(digestValueElement);
return elemDig;
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/ReferenceNotInitializedException.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/ReferenceNotInitializedException.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/ReferenceNotInitializedException.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/ReferenceNotInitializedException.java Thu Jan 27 11:11:33 2011
@@ -30,9 +30,9 @@ package org.apache.xml.security.signatur
public class ReferenceNotInitializedException extends XMLSignatureException {
/**
- *
- */
- private static final long serialVersionUID = 1L;
+ *
+ */
+ private static final long serialVersionUID = 1L;
/**
* Constructor ReferenceNotInitializedException
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/SignatureProperties.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/SignatureProperties.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/SignatureProperties.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/SignatureProperties.java Thu Jan 27 11:11:33 2011
@@ -83,7 +83,7 @@ public class SignatureProperties extends
* @throws XMLSignatureException
*/
public SignatureProperty item(int i) throws XMLSignatureException {
- try {
+ try {
Element propertyElem =
XMLUtils.selectDsNode(this._constructionElement,
Constants._TAG_SIGNATUREPROPERTY,
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/SignedInfo.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/SignedInfo.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/SignedInfo.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/SignedInfo.java Thu Jan 27 11:11:33 2011
@@ -64,7 +64,7 @@ public class SignedInfo extends Manifest
*/
public SignedInfo(Document doc) throws XMLSecurityException {
this(doc, XMLSignature.ALGO_ID_SIGNATURE_DSA,
- Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
+ Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
}
/**
@@ -79,7 +79,7 @@ public class SignedInfo extends Manifest
* @throws XMLSecurityException
*/
public SignedInfo(Document doc, String signatureMethodURI,
- String canonicalizationMethodURI) throws XMLSecurityException {
+ String canonicalizationMethodURI) throws XMLSecurityException {
this(doc, signatureMethodURI, 0, canonicalizationMethodURI);
}
@@ -95,7 +95,7 @@ public class SignedInfo extends Manifest
* @throws XMLSecurityException
*/
public SignedInfo(Document doc, String signatureMethodURI,
- int hMACOutputLength, String canonicalizationMethodURI)
+ int hMACOutputLength, String canonicalizationMethodURI)
throws XMLSecurityException {
super(doc);
@@ -128,7 +128,7 @@ public class SignedInfo extends Manifest
* @throws XMLSecurityException
*/
public SignedInfo(Document doc, Element signatureMethodElem,
- Element canonicalizationMethodElem) throws XMLSecurityException {
+ Element canonicalizationMethodElem) throws XMLSecurityException {
super(doc);
// Check this?
@@ -137,7 +137,7 @@ public class SignedInfo extends Manifest
XMLUtils.addReturnToElement(this._constructionElement);
this._signatureAlgorithm =
- new SignatureAlgorithm(signatureMethodElem, null);
+ new SignatureAlgorithm(signatureMethodElem, null);
signatureMethod = this._signatureAlgorithm.getElement();
this._constructionElement.appendChild(signatureMethod);
@@ -180,12 +180,12 @@ public class SignedInfo extends Manifest
c14nMethod.getAttributeNS(null, Constants._ATT_ALGORITHM);
if (!(c14nMethodURI.equals(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS) ||
c14nMethodURI.equals(Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS) ||
- c14nMethodURI.equals(Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS) ||
- c14nMethodURI.equals(Canonicalizer.ALGO_ID_C14N_EXCL_WITH_COMMENTS) ||
- c14nMethodURI.equals(Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS) ||
- c14nMethodURI.equals(Canonicalizer.ALGO_ID_C14N11_WITH_COMMENTS))) {
- // the c14n is not a secure one and can rewrite the URIs or like
- // so reparse the SignedInfo to be sure
+ c14nMethodURI.equals(Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS) ||
+ c14nMethodURI.equals(Canonicalizer.ALGO_ID_C14N_EXCL_WITH_COMMENTS) ||
+ c14nMethodURI.equals(Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS) ||
+ c14nMethodURI.equals(Canonicalizer.ALGO_ID_C14N11_WITH_COMMENTS))) {
+ // the c14n is not a secure one and can rewrite the URIs or like
+ // so reparse the SignedInfo to be sure
try {
Canonicalizer c14nizer =
Canonicalizer.getInstance(c14nMethodURI);
@@ -211,7 +211,7 @@ public class SignedInfo extends Manifest
throw new XMLSecurityException("empty", ex);
}
}
- return element;
+ return element;
}
/**
@@ -274,7 +274,7 @@ public class SignedInfo extends Manifest
throws CanonicalizationException, InvalidCanonicalizerException,
XMLSecurityException {
- if (this._c14nizedBytes == null) {
+ if (this._c14nizedBytes == null) {
Canonicalizer c14nizer =
Canonicalizer.getInstance(this.getCanonicalizationMethodURI());
c14nizer.setWriter(os);
@@ -288,10 +288,10 @@ public class SignedInfo extends Manifest
}
} else {
try {
- os.write(this._c14nizedBytes);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ os.write(this._c14nizedBytes);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
}
@@ -360,7 +360,7 @@ public class SignedInfo extends Manifest
String c14nMethodURI = c14nMethod.getAttributeNS(null, Constants._ATT_ALGORITHM);
if (!(c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#") ||
- c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#WithComments"))) {
+ c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#WithComments"))) {
return null;
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignature.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignature.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignature.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignature.java Thu Jan 27 11:11:33 2011
@@ -201,10 +201,10 @@ public final class XMLSignature extends
getDefaultPrefixBindings(Constants.SignatureSpecNS);
if (xmlnsDsPrefix == null) {
this._constructionElement.setAttributeNS
- (Constants.NamespaceSpecNS, "xmlns", Constants.SignatureSpecNS);
+ (Constants.NamespaceSpecNS, "xmlns", Constants.SignatureSpecNS);
} else {
this._constructionElement.setAttributeNS
- (Constants.NamespaceSpecNS, xmlnsDsPrefix, Constants.SignatureSpecNS);
+ (Constants.NamespaceSpecNS, xmlnsDsPrefix, Constants.SignatureSpecNS);
}
XMLUtils.addReturnToElement(this._constructionElement);
@@ -242,10 +242,10 @@ public final class XMLSignature extends
getDefaultPrefixBindings(Constants.SignatureSpecNS);
if (xmlnsDsPrefix == null) {
this._constructionElement.setAttributeNS
- (Constants.NamespaceSpecNS, "xmlns", Constants.SignatureSpecNS);
+ (Constants.NamespaceSpecNS, "xmlns", Constants.SignatureSpecNS);
} else {
this._constructionElement.setAttributeNS
- (Constants.NamespaceSpecNS, xmlnsDsPrefix, Constants.SignatureSpecNS);
+ (Constants.NamespaceSpecNS, xmlnsDsPrefix, Constants.SignatureSpecNS);
}
XMLUtils.addReturnToElement(this._constructionElement);
@@ -291,7 +291,7 @@ public final class XMLSignature extends
// create a SignedInfo object from that element
this._signedInfo = new SignedInfo(signedInfoElem, BaseURI);
- // get signedInfoElem again in case it has changed
+ // get signedInfoElem again in case it has changed
signedInfoElem = XMLUtils.getNextElement(element.getFirstChild());
// check out SignatureValue child
@@ -375,13 +375,13 @@ public final class XMLSignature extends
while (signatureValueElement.hasChildNodes()) {
signatureValueElement.removeChild
- (signatureValueElement.getFirstChild());
+ (signatureValueElement.getFirstChild());
}
String base64codedValue = Base64.encode(bytes);
if (base64codedValue.length() > 76 && !XMLUtils.ignoreLineBreaks()) {
- base64codedValue = "\n" + base64codedValue + "\n";
+ base64codedValue = "\n" + base64codedValue + "\n";
}
Text t = this._doc.createTextNode(base64codedValue);
@@ -409,12 +409,12 @@ public final class XMLSignature extends
Element firstObject = XMLUtils.selectDsNode
(this._constructionElement.getFirstChild(),
Constants._TAG_OBJECT, 0);
-
+
if (firstObject != null) {
// add it before the object
this._constructionElement.insertBefore(keyInfoElement,
firstObject);
- XMLUtils.addReturnBeforeChild
+ XMLUtils.addReturnBeforeChild
(this._constructionElement, firstObject);
} else {
// add it as the last element to the signature
@@ -496,7 +496,7 @@ public final class XMLSignature extends
try {
//Create a SignatureAlgorithm object
- SignedInfo si = this.getSignedInfo();
+ SignedInfo si = this.getSignedInfo();
SignatureAlgorithm sa = si.getSignatureAlgorithm();
try {
// initialize SignatureAlgorithm for signing
@@ -615,16 +615,16 @@ public final class XMLSignature extends
OutputStream bos = new UnsyncBufferedOutputStream(so);
si.signInOctectStream(bos);
- bos.close();
- // retrieve the byte[] from the stored signature
- sigBytes = this.getSignatureValue();
- } catch (IOException ex) {
- // Impossible...but clear the verification cache anyway
- sa.clearVerificationCache();
- } catch (XMLSecurityException ex) {
- sa.clearVerificationCache();
- throw ex;
- }
+ bos.close();
+ // retrieve the byte[] from the stored signature
+ sigBytes = this.getSignatureValue();
+ } catch (IOException ex) {
+ // Impossible...but clear the verification cache anyway
+ sa.clearVerificationCache();
+ } catch (XMLSecurityException ex) {
+ sa.clearVerificationCache();
+ throw ex;
+ }
// have SignatureAlgorithm sign the input bytes and compare them to
// the bytes that were stored in the signature.
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignatureException.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignatureException.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignatureException.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignatureException.java Thu Jan 27 11:11:33 2011
@@ -31,9 +31,9 @@ import org.apache.xml.security.exception
public class XMLSignatureException extends XMLSecurityException {
/**
- *
- */
- private static final long serialVersionUID = 1L;
+ *
+ */
+ private static final long serialVersionUID = 1L;
/**
* Constructor XMLSignatureException
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignatureInput.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignatureInput.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignatureInput.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignatureInput.java Thu Jan 27 11:11:33 2011
@@ -52,7 +52,7 @@ import org.xml.sax.SAXException;
public class XMLSignatureInput implements Cloneable {
static org.apache.commons.logging.Log log =
org.apache.commons.logging.LogFactory.getLog
- (XMLSignatureInput.class.getName());
+ (XMLSignatureInput.class.getName());
/*
* The XMLSignature Input can be either:
@@ -135,7 +135,7 @@ public class XMLSignatureInput implement
* @param inputOctetStream
*/
public XMLSignatureInput(InputStream inputOctetStream) {
- this._inputOctetStreamProxy=inputOctetStream;
+ this._inputOctetStreamProxy=inputOctetStream;
}
/**
@@ -191,7 +191,7 @@ public class XMLSignatureInput implement
* @return true if so.
*/
public boolean isNeedsToBeExpanded() {
- return needsToBeExpanded;
+ return needsToBeExpanded;
}
/**
@@ -199,7 +199,7 @@ public class XMLSignatureInput implement
* @param needsToBeExpanded true if so.
*/
public void setNeedsToBeExpanded(boolean needsToBeExpanded) {
- this.needsToBeExpanded = needsToBeExpanded;
+ this.needsToBeExpanded = needsToBeExpanded;
}
/**
@@ -213,8 +213,8 @@ public class XMLSignatureInput implement
* @throws CanonicalizationException
*/
public Set getNodeSet() throws CanonicalizationException,
- ParserConfigurationException, IOException, SAXException {
- return getNodeSet(false);
+ ParserConfigurationException, IOException, SAXException {
+ return getNodeSet(false);
}
/**
@@ -232,17 +232,17 @@ public class XMLSignatureInput implement
throws ParserConfigurationException, IOException, SAXException,
CanonicalizationException {
if (_inputNodeSet != null) {
- return _inputNodeSet;
+ return _inputNodeSet;
}
- if (_inputOctetStreamProxy == null && _subNode != null) {
- if (circumvent) {
- XMLUtils.circumventBug2650(XMLUtils.getOwnerDocument(_subNode));
+ if (_inputOctetStreamProxy == null && _subNode != null) {
+ if (circumvent) {
+ XMLUtils.circumventBug2650(XMLUtils.getOwnerDocument(_subNode));
}
_inputNodeSet = new HashSet();
XMLUtils.getSet
(_subNode, _inputNodeSet, excludeNode, excludeComments);
- return _inputNodeSet;
- } else if (this.isOctetStream()) {
+ return _inputNodeSet;
+ } else if (this.isOctetStream()) {
convertToNodes();
HashSet result = new HashSet();
XMLUtils.getSet(_subNode, result, null, false);
@@ -293,14 +293,14 @@ public class XMLSignatureInput implement
InputStream is = getResetableInputStream();
if (is != null) {
// resetable can read again bytes.
- if (bytes == null) {
+ if (bytes == null) {
is.reset();
bytes=JavaUtils.getBytesFromStream(is);
- }
- return bytes;
+ }
+ return bytes;
}
Canonicalizer20010315OmitComments c14nizer =
- new Canonicalizer20010315OmitComments();
+ new Canonicalizer20010315OmitComments();
bytes = c14nizer.engineCanonicalize(this);
return bytes;
}
@@ -321,8 +321,8 @@ public class XMLSignatureInput implement
* @return true if the object has been set up with a Node set
*/
public boolean isElement() {
- return (this._inputOctetStreamProxy == null && this._subNode != null
- && this._inputNodeSet == null && !isNodeSet);
+ return (this._inputOctetStreamProxy == null && this._subNode != null
+ && this._inputNodeSet == null && !isNodeSet);
}
/**
@@ -343,7 +343,7 @@ public class XMLSignatureInput implement
* non-null OutputStream
*/
public boolean isOutputStreamSet() {
- return outputStream != null;
+ return outputStream != null;
}
/**
@@ -456,7 +456,7 @@ public class XMLSignatureInput implement
* @return Returns the excludeNode.
*/
public Node getExcludeNode() {
- return excludeNode;
+ return excludeNode;
}
/**
@@ -464,7 +464,7 @@ public class XMLSignatureInput implement
* @param excludeNode The excludeNode to set.
*/
public void setExcludeNode(Node excludeNode) {
- this.excludeNode = excludeNode;
+ this.excludeNode = excludeNode;
}
/**
@@ -472,21 +472,21 @@ public class XMLSignatureInput implement
* @return The excludeNode set.
*/
public Node getSubNode() {
- return _subNode;
+ return _subNode;
}
/**
* @return Returns the excludeComments.
*/
public boolean isExcludeComments() {
- return excludeComments;
+ return excludeComments;
}
/**
* @param excludeComments The excludeComments to set.
*/
public void setExcludeComments(boolean excludeComments) {
- this.excludeComments = excludeComments;
+ this.excludeComments = excludeComments;
}
/**
@@ -496,43 +496,43 @@ public class XMLSignatureInput implement
*/
public void updateOutputStream(OutputStream diOs)
throws CanonicalizationException, IOException {
- updateOutputStream(diOs, false);
+ updateOutputStream(diOs, false);
}
public void updateOutputStream(OutputStream diOs, boolean c14n11)
throws CanonicalizationException, IOException {
- if (diOs == outputStream) {
- return;
+ if (diOs == outputStream) {
+ return;
}
if (bytes != null) {
diOs.write(bytes);
} else if (_inputOctetStreamProxy == null) {
- CanonicalizerBase c14nizer = null;
- if (c14n11) {
+ CanonicalizerBase c14nizer = null;
+ if (c14n11) {
c14nizer = new Canonicalizer11_OmitComments();
- } else {
+ } else {
c14nizer = new Canonicalizer20010315OmitComments();
- }
+ }
c14nizer.setWriter(diOs);
c14nizer.engineCanonicalize(this);
} else {
if (_inputOctetStreamProxy instanceof FileInputStream) {
byte[] buffer = new byte[4 * 1024];
int bytesread = 0;
- while ((bytesread = _inputOctetStreamProxy.read(buffer)) != -1 ) {
- diOs.write(buffer, 0, bytesread);
- }
+ while ((bytesread = _inputOctetStreamProxy.read(buffer)) != -1 ) {
+ diOs.write(buffer, 0, bytesread);
+ }
} else {
InputStream is = getResetableInputStream();
if (bytes != null) {
// already read write it, can be rea.
- diOs.write(bytes, 0, bytes.length);
+ diOs.write(bytes, 0, bytes.length);
} else {
is.reset();
byte[] bytesT = new byte[1024];
int num = 0;
while ((num = is.read(bytesT)) > 0) {
- diOs.write(bytesT, 0, num);
+ diOs.write(bytesT, 0, num);
}
}
}
@@ -543,11 +543,11 @@ public class XMLSignatureInput implement
* @param os
*/
public void setOutputStream(OutputStream os) {
- outputStream = os;
+ outputStream = os;
}
protected InputStream getResetableInputStream() throws IOException {
- if (_inputOctetStreamProxy instanceof ByteArrayInputStream) {
+ if (_inputOctetStreamProxy instanceof ByteArrayInputStream) {
if (!_inputOctetStreamProxy.markSupported()) {
throw new RuntimeException("Accepted as Markable but not truly been"+_inputOctetStreamProxy);
}
@@ -562,9 +562,9 @@ public class XMLSignatureInput implement
if (_inputOctetStreamProxy.markSupported()) {
log.info("Mark Suported but not used as reset");
}
- bytes = JavaUtils.getBytesFromStream(_inputOctetStreamProxy);
- _inputOctetStreamProxy.close();
- _inputOctetStreamProxy = new ByteArrayInputStream(bytes);
+ bytes = JavaUtils.getBytesFromStream(_inputOctetStreamProxy);
+ _inputOctetStreamProxy.close();
+ _inputOctetStreamProxy = new ByteArrayInputStream(bytes);
return _inputOctetStreamProxy;
}
@@ -572,34 +572,34 @@ public class XMLSignatureInput implement
* @param filter
*/
public void addNodeFilter(NodeFilter filter) {
- if (isOctetStream()) {
- try {
- convertToNodes();
- } catch (Exception e) {
- throw new XMLSecurityRuntimeException("signature.XMLSignatureInput.nodesetReference",e);
- }
+ if (isOctetStream()) {
+ try {
+ convertToNodes();
+ } catch (Exception e) {
+ throw new XMLSecurityRuntimeException("signature.XMLSignatureInput.nodesetReference",e);
+ }
}
- nodeFilters.add(filter);
+ nodeFilters.add(filter);
}
/**
* @return the node filters
*/
public List getNodeFilters() {
- // TODO Auto-generated method stub
- return nodeFilters;
+ // TODO Auto-generated method stub
+ return nodeFilters;
}
/**
* @param b
*/
public void setNodeSet(boolean b) {
- isNodeSet = b;
+ isNodeSet = b;
}
-
+
void convertToNodes() throws CanonicalizationException,
- ParserConfigurationException, IOException, SAXException {
- DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
+ ParserConfigurationException, IOException, SAXException {
+ DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
dfactory.setValidating(false);
dfactory.setNamespaceAware(true);
DocumentBuilder db = dfactory.newDocumentBuilder();
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignatureInputDebugger.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignatureInputDebugger.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignatureInputDebugger.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/signature/XMLSignatureInputDebugger.java Thu Jan 27 11:11:33 2011
@@ -42,621 +42,621 @@ public class XMLSignatureInputDebugger {
- /** Field _xmlSignatureInput */
- private Set _xpathNodeSet;
+ /** Field _xmlSignatureInput */
+ private Set _xpathNodeSet;
- private Set _inclusiveNamespaces;
+ private Set _inclusiveNamespaces;
- /** Field _doc */
- private Document _doc = null;
+ /** Field _doc */
+ private Document _doc = null;
- /** Field _writer */
- private Writer _writer = null;
-
- // J-
- // public static final String HTMLPrefix = "<!DOCTYPE HTML PUBLIC
- // \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html><head><style
- // type=\"text/css\"><!-- .INCLUDED { color: #000000; background-color:
- // #FFFFFF; font-weight: bold; } .EXCLUDED { color: #666666;
- // background-color: #999999; } .INCLUDEDINCLUSIVENAMESPACE { color:
- // #0000FF; background-color: #FFFFFF; font-weight: bold; font-style:
- // italic; } .EXCLUDEDINCLUSIVENAMESPACE { color: #0000FF; background-color:
- // #999999; font-style: italic; } --> </style> </head><body
- // bgcolor=\"#999999\"><pre>";
- /** The HTML Prefix* */
- static final String HTMLPrefix = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
- + "<html>\n"
- + "<head>\n"
- + "<title>Caninical XML node set</title>\n"
- + "<style type=\"text/css\">\n"
- + "<!-- \n"
- + ".INCLUDED { \n"
- + " color: #000000; \n"
- + " background-color: \n"
- + " #FFFFFF; \n"
- + " font-weight: bold; } \n"
- + ".EXCLUDED { \n"
- + " color: #666666; \n"
- + " background-color: \n"
- + " #999999; } \n"
- + ".INCLUDEDINCLUSIVENAMESPACE { \n"
- + " color: #0000FF; \n"
- + " background-color: #FFFFFF; \n"
- + " font-weight: bold; \n"
- + " font-style: italic; } \n"
- + ".EXCLUDEDINCLUSIVENAMESPACE { \n"
- + " color: #0000FF; \n"
- + " background-color: #999999; \n"
- + " font-style: italic; } \n"
- + "--> \n"
- + "</style> \n"
- + "</head>\n"
- + "<body bgcolor=\"#999999\">\n"
- + "<h1>Explanation of the output</h1>\n"
- + "<p>The following text contains the nodeset of the given Reference before it is canonicalized. There exist four different styles to indicate how a given node is treated.</p>\n"
- + "<ul>\n"
- + "<li class=\"INCLUDED\">A node which is in the node set is labeled using the INCLUDED style.</li>\n"
- + "<li class=\"EXCLUDED\">A node which is <em>NOT</em> in the node set is labeled EXCLUDED style.</li>\n"
- + "<li class=\"INCLUDEDINCLUSIVENAMESPACE\">A namespace which is in the node set AND in the InclusiveNamespaces PrefixList is labeled using the INCLUDEDINCLUSIVENAMESPACE style.</li>\n"
- + "<li class=\"EXCLUDEDINCLUSIVENAMESPACE\">A namespace which is in NOT the node set AND in the InclusiveNamespaces PrefixList is labeled using the INCLUDEDINCLUSIVENAMESPACE style.</li>\n"
- + "</ul>\n" + "<h1>Output</h1>\n" + "<pre>\n";
-
- /** HTML Suffix * */
- static final String HTMLSuffix = "</pre></body></html>";
-
- static final String HTMLExcludePrefix = "<span class=\"EXCLUDED\">";
-
- static final String HTMLIncludePrefix = "<span class=\"INCLUDED\">";
-
- static final String HTMLIncludeOrExcludeSuffix = "</span>";
-
- static final String HTMLIncludedInclusiveNamespacePrefix = "<span class=\"INCLUDEDINCLUSIVENAMESPACE\">";
-
- static final String HTMLExcludedInclusiveNamespacePrefix = "<span class=\"EXCLUDEDINCLUSIVENAMESPACE\">";
-
- private static final int NODE_BEFORE_DOCUMENT_ELEMENT = -1;
-
- private static final int NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT = 0;
-
- private static final int NODE_AFTER_DOCUMENT_ELEMENT = 1;
-
- static final AttrCompare ATTR_COMPARE = new AttrCompare();
-
- // J+
- private XMLSignatureInputDebugger() {
- // do nothing
- }
-
- /**
- * Constructor XMLSignatureInputDebugger
- *
- * @param xmlSignatureInput the signatur to pretty print
- */
- public XMLSignatureInputDebugger(
- XMLSignatureInput xmlSignatureInput) {
-
- if (!xmlSignatureInput.isNodeSet()) {
- this._xpathNodeSet = null;
- } else {
- this._xpathNodeSet = xmlSignatureInput._inputNodeSet;
- }
- }
-
- /**
- * Constructor XMLSignatureInputDebugger
- *
- * @param xmlSignatureInput the signatur to pretty print
- * @param inclusiveNamespace
- */
- public XMLSignatureInputDebugger(
- XMLSignatureInput xmlSignatureInput, Set inclusiveNamespace) {
-
- this(xmlSignatureInput);
-
- this._inclusiveNamespaces = inclusiveNamespace;
- }
-
- /**
- * Method getHTMLRepresentation
- *
- * @return The HTML Representation.
- * @throws XMLSignatureException
- */
- public String getHTMLRepresentation() throws XMLSignatureException {
-
- if ((this._xpathNodeSet == null) || (this._xpathNodeSet.size() == 0)) {
- return HTMLPrefix + "<blink>no node set, sorry</blink>"
- + HTMLSuffix;
- }
-
- {
-
- // get only a single node as anchor to fetch the owner document
- Node n = (Node) this._xpathNodeSet.iterator().next();
-
- this._doc = XMLUtils.getOwnerDocument(n);
- }
-
- try {
- this._writer = new StringWriter();
-
- this.canonicalizeXPathNodeSet(this._doc);
- this._writer.close();
-
- return this._writer.toString();
- } catch (IOException ex) {
- throw new XMLSignatureException("empty", ex);
- } finally {
- this._xpathNodeSet = null;
- this._doc = null;
- this._writer = null;
- }
- }
-
- /**
- * Method canonicalizeXPathNodeSet
- *
- * @param currentNode
- * @throws XMLSignatureException
- * @throws IOException
- */
- private void canonicalizeXPathNodeSet(Node currentNode)
- throws XMLSignatureException, IOException {
-
- int currentNodeType = currentNode.getNodeType();
- switch (currentNodeType) {
-
- case Node.DOCUMENT_TYPE_NODE:
- default:
- break;
-
- case Node.ENTITY_NODE:
- case Node.NOTATION_NODE:
- case Node.DOCUMENT_FRAGMENT_NODE:
- case Node.ATTRIBUTE_NODE:
- throw new XMLSignatureException("empty");
- case Node.DOCUMENT_NODE:
- this._writer.write(HTMLPrefix);
-
- for (Node currentChild = currentNode.getFirstChild(); currentChild != null; currentChild = currentChild
- .getNextSibling()) {
- this.canonicalizeXPathNodeSet(currentChild);
- }
-
- this._writer.write(HTMLSuffix);
- break;
-
- case Node.COMMENT_NODE:
- if (this._xpathNodeSet.contains(currentNode)) {
- this._writer.write(HTMLIncludePrefix);
- } else {
- this._writer.write(HTMLExcludePrefix);
- }
-
- int position = getPositionRelativeToDocumentElement(currentNode);
-
- if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
- this._writer.write("\n");
- }
-
- this.outputCommentToWriter((Comment) currentNode);
-
- if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
- this._writer.write("\n");
- }
-
- this._writer.write(HTMLIncludeOrExcludeSuffix);
- break;
-
- case Node.PROCESSING_INSTRUCTION_NODE:
- if (this._xpathNodeSet.contains(currentNode)) {
- this._writer.write(HTMLIncludePrefix);
- } else {
- this._writer.write(HTMLExcludePrefix);
- }
-
- position = getPositionRelativeToDocumentElement(currentNode);
-
- if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
- this._writer.write("\n");
- }
-
- this.outputPItoWriter((ProcessingInstruction) currentNode);
-
- if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
- this._writer.write("\n");
- }
-
- this._writer.write(HTMLIncludeOrExcludeSuffix);
- break;
-
- case Node.TEXT_NODE:
- case Node.CDATA_SECTION_NODE:
- if (this._xpathNodeSet.contains(currentNode)) {
- this._writer.write(HTMLIncludePrefix);
- } else {
- this._writer.write(HTMLExcludePrefix);
- }
-
- outputTextToWriter(currentNode.getNodeValue());
-
- for (Node nextSibling = currentNode.getNextSibling(); (nextSibling != null)
- && ((nextSibling.getNodeType() == Node.TEXT_NODE) || (nextSibling
- .getNodeType() == Node.CDATA_SECTION_NODE)); nextSibling = nextSibling
- .getNextSibling()) {
-
- /*
- * The XPath data model allows to select only the first of a
- * sequence of mixed text and CDATA nodes. But we must output
- * them all, so we must search:
- *
- * @see http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6329
- */
- this.outputTextToWriter(nextSibling.getNodeValue());
- }
-
- this._writer.write(HTMLIncludeOrExcludeSuffix);
- break;
-
- case Node.ELEMENT_NODE:
- Element currentElement = (Element) currentNode;
-
- if (this._xpathNodeSet.contains(currentNode)) {
- this._writer.write(HTMLIncludePrefix);
- } else {
- this._writer.write(HTMLExcludePrefix);
- }
-
- this._writer.write("<");
- this._writer.write(currentElement.getTagName());
-
- this._writer.write(HTMLIncludeOrExcludeSuffix);
-
- // we output all Attrs which are available
- NamedNodeMap attrs = currentElement.getAttributes();
- int attrsLength = attrs.getLength();
- Object attrs2[] = new Object[attrsLength];
-
- for (int i = 0; i < attrsLength; i++) {
- attrs2[i] = attrs.item(i);
- }
-
- Arrays.sort(attrs2, ATTR_COMPARE);
- Object attrs3[] = attrs2;
-
- for (int i = 0; i < attrsLength; i++) {
- Attr a = (Attr) attrs3[i];
- boolean included = this._xpathNodeSet.contains(a);
- boolean inclusive = this._inclusiveNamespaces.contains(a
- .getName());
-
- if (included) {
- if (inclusive) {
-
- // included and inclusive
- this._writer
- .write(HTMLIncludedInclusiveNamespacePrefix);
- } else {
-
- // included and not inclusive
- this._writer.write(HTMLIncludePrefix);
- }
- } else {
- if (inclusive) {
-
- // excluded and inclusive
- this._writer
- .write(HTMLExcludedInclusiveNamespacePrefix);
- } else {
-
- // excluded and not inclusive
- this._writer.write(HTMLExcludePrefix);
- }
- }
-
- this.outputAttrToWriter(a.getNodeName(), a.getNodeValue());
-
- this._writer.write(HTMLIncludeOrExcludeSuffix);
- }
-
- if (this._xpathNodeSet.contains(currentNode)) {
- this._writer.write(HTMLIncludePrefix);
- } else {
- this._writer.write(HTMLExcludePrefix);
- }
-
- this._writer.write(">");
-
- this._writer.write(HTMLIncludeOrExcludeSuffix);
-
- // traversal
- for (Node currentChild = currentNode.getFirstChild(); currentChild != null; currentChild = currentChild
- .getNextSibling()) {
- this.canonicalizeXPathNodeSet(currentChild);
- }
-
- if (this._xpathNodeSet.contains(currentNode)) {
- this._writer.write(HTMLIncludePrefix);
- } else {
- this._writer.write(HTMLExcludePrefix);
- }
-
- this._writer.write("</");
- this._writer.write(currentElement.getTagName());
- this._writer.write(">");
-
- this._writer.write(HTMLIncludeOrExcludeSuffix);
- break;
- }
- }
-
- /**
- * Checks whether a Comment or ProcessingInstruction is before or after the
- * document element. This is needed for prepending or appending "\n"s.
- *
- * @param currentNode
- * comment or pi to check
- * @return NODE_BEFORE_DOCUMENT_ELEMENT,
- * NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT or
- * NODE_AFTER_DOCUMENT_ELEMENT
- * @see #NODE_BEFORE_DOCUMENT_ELEMENT
- * @see #NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT
- * @see #NODE_AFTER_DOCUMENT_ELEMENT
- */
- private int getPositionRelativeToDocumentElement(Node currentNode) {
-
- if (currentNode == null) {
- return NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
- }
-
- Document doc = currentNode.getOwnerDocument();
-
- if (currentNode.getParentNode() != doc) {
- return NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
- }
-
- Element documentElement = doc.getDocumentElement();
-
- if (documentElement == null) {
- return NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
- }
-
- if (documentElement == currentNode) {
- return NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
- }
-
- for (Node x = currentNode; x != null; x = x.getNextSibling()) {
- if (x == documentElement) {
- return NODE_BEFORE_DOCUMENT_ELEMENT;
- }
- }
-
- return NODE_AFTER_DOCUMENT_ELEMENT;
- }
-
- /**
- * Normalizes an {@link Attr}ibute value
- *
- * The string value of the node is modified by replacing
- * <UL>
- * <LI>all ampersands (&) with <CODE>&amp;</CODE></LI>
- * <LI>all open angle brackets (<) with <CODE>&lt;</CODE></LI>
- * <LI>all quotation mark characters with <CODE>&quot;</CODE></LI>
- * <LI>and the whitespace characters <CODE>#x9</CODE>, #xA, and #xD,
- * with character references. The character references are written in
- * uppercase hexadecimal with no leading zeroes (for example, <CODE>#xD</CODE>
- * is represented by the character reference <CODE>&#xD;</CODE>)</LI>
- * </UL>
- *
- * @param name
- * @param value
- * @throws IOException
- */
- private void outputAttrToWriter(String name, String value)
- throws IOException {
-
- this._writer.write(" ");
- this._writer.write(name);
- this._writer.write("=\"");
-
- int length = value.length();
-
- for (int i = 0; i < length; i++) {
- char c = value.charAt(i);
-
- switch (c) {
-
- case '&':
- this._writer.write("&amp;");
- break;
-
- case '<':
- this._writer.write("&lt;");
- break;
-
- case '"':
- this._writer.write("&quot;");
- break;
-
- case 0x09: // '\t'
- this._writer.write("&#x9;");
- break;
-
- case 0x0A: // '\n'
- this._writer.write("&#xA;");
- break;
-
- case 0x0D: // '\r'
- this._writer.write("&#xD;");
- break;
-
- default:
- this._writer.write(c);
- break;
- }
- }
-
- this._writer.write("\"");
- }
-
- /**
- * Normalizes a {@link org.w3c.dom.Comment} value
- *
- * @param currentPI
- * @throws IOException
- */
- private void outputPItoWriter(ProcessingInstruction currentPI)
- throws IOException {
-
- if (currentPI == null) {
- return;
- }
-
- this._writer.write("<?");
-
- String target = currentPI.getTarget();
- int length = target.length();
-
- for (int i = 0; i < length; i++) {
- char c = target.charAt(i);
-
- switch (c) {
-
- case 0x0D:
- this._writer.write("&#xD;");
- break;
-
- case ' ':
- this._writer.write("·");
- break;
-
- case '\n':
- this._writer.write("¶\n");
- break;
-
- default:
- this._writer.write(c);
- break;
- }
- }
-
- String data = currentPI.getData();
-
- length = data.length();
-
- if (length > 0) {
- this._writer.write(" ");
-
- for (int i = 0; i < length; i++) {
- char c = data.charAt(i);
-
- switch (c) {
-
- case 0x0D:
- this._writer.write("&#xD;");
- break;
-
- default:
- this._writer.write(c);
- break;
- }
- }
- }
-
- this._writer.write("?>");
- }
-
- /**
- * Method outputCommentToWriter
- *
- * @param currentComment
- * @throws IOException
- */
- private void outputCommentToWriter(Comment currentComment)
- throws IOException {
-
- if (currentComment == null) {
- return;
- }
-
- this._writer.write("<!--");
-
- String data = currentComment.getData();
- int length = data.length();
-
- for (int i = 0; i < length; i++) {
- char c = data.charAt(i);
-
- switch (c) {
-
- case 0x0D:
- this._writer.write("&#xD;");
- break;
-
- case ' ':
- this._writer.write("·");
- break;
-
- case '\n':
- this._writer.write("¶\n");
- break;
-
- default:
- this._writer.write(c);
- break;
- }
- }
-
- this._writer.write("-->");
- }
-
- /**
- * Method outputTextToWriter
- *
- * @param text
- * @throws IOException
- */
- private void outputTextToWriter(String text) throws IOException {
-
- if (text == null) {
- return;
- }
-
- int length = text.length();
-
- for (int i = 0; i < length; i++) {
- char c = text.charAt(i);
-
- switch (c) {
-
- case '&':
- this._writer.write("&amp;");
- break;
-
- case '<':
- this._writer.write("&lt;");
- break;
-
- case '>':
- this._writer.write("&gt;");
- break;
-
- case 0xD:
- this._writer.write("&#xD;");
- break;
-
- case ' ':
- this._writer.write("·");
- break;
-
- case '\n':
- this._writer.write("¶\n");
- break;
-
- default:
- this._writer.write(c);
- break;
- }
- }
- }
+ /** Field _writer */
+ private Writer _writer = null;
+
+ // J-
+ // public static final String HTMLPrefix = "<!DOCTYPE HTML PUBLIC
+ // \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html><head><style
+ // type=\"text/css\"><!-- .INCLUDED { color: #000000; background-color:
+ // #FFFFFF; font-weight: bold; } .EXCLUDED { color: #666666;
+ // background-color: #999999; } .INCLUDEDINCLUSIVENAMESPACE { color:
+ // #0000FF; background-color: #FFFFFF; font-weight: bold; font-style:
+ // italic; } .EXCLUDEDINCLUSIVENAMESPACE { color: #0000FF; background-color:
+ // #999999; font-style: italic; } --> </style> </head><body
+ // bgcolor=\"#999999\"><pre>";
+ /** The HTML Prefix* */
+ static final String HTMLPrefix = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
+ + "<html>\n"
+ + "<head>\n"
+ + "<title>Caninical XML node set</title>\n"
+ + "<style type=\"text/css\">\n"
+ + "<!-- \n"
+ + ".INCLUDED { \n"
+ + " color: #000000; \n"
+ + " background-color: \n"
+ + " #FFFFFF; \n"
+ + " font-weight: bold; } \n"
+ + ".EXCLUDED { \n"
+ + " color: #666666; \n"
+ + " background-color: \n"
+ + " #999999; } \n"
+ + ".INCLUDEDINCLUSIVENAMESPACE { \n"
+ + " color: #0000FF; \n"
+ + " background-color: #FFFFFF; \n"
+ + " font-weight: bold; \n"
+ + " font-style: italic; } \n"
+ + ".EXCLUDEDINCLUSIVENAMESPACE { \n"
+ + " color: #0000FF; \n"
+ + " background-color: #999999; \n"
+ + " font-style: italic; } \n"
+ + "--> \n"
+ + "</style> \n"
+ + "</head>\n"
+ + "<body bgcolor=\"#999999\">\n"
+ + "<h1>Explanation of the output</h1>\n"
+ + "<p>The following text contains the nodeset of the given Reference before it is canonicalized. There exist four different styles to indicate how a given node is treated.</p>\n"
+ + "<ul>\n"
+ + "<li class=\"INCLUDED\">A node which is in the node set is labeled using the INCLUDED style.</li>\n"
+ + "<li class=\"EXCLUDED\">A node which is <em>NOT</em> in the node set is labeled EXCLUDED style.</li>\n"
+ + "<li class=\"INCLUDEDINCLUSIVENAMESPACE\">A namespace which is in the node set AND in the InclusiveNamespaces PrefixList is labeled using the INCLUDEDINCLUSIVENAMESPACE style.</li>\n"
+ + "<li class=\"EXCLUDEDINCLUSIVENAMESPACE\">A namespace which is in NOT the node set AND in the InclusiveNamespaces PrefixList is labeled using the INCLUDEDINCLUSIVENAMESPACE style.</li>\n"
+ + "</ul>\n" + "<h1>Output</h1>\n" + "<pre>\n";
+
+ /** HTML Suffix * */
+ static final String HTMLSuffix = "</pre></body></html>";
+
+ static final String HTMLExcludePrefix = "<span class=\"EXCLUDED\">";
+
+ static final String HTMLIncludePrefix = "<span class=\"INCLUDED\">";
+
+ static final String HTMLIncludeOrExcludeSuffix = "</span>";
+
+ static final String HTMLIncludedInclusiveNamespacePrefix = "<span class=\"INCLUDEDINCLUSIVENAMESPACE\">";
+
+ static final String HTMLExcludedInclusiveNamespacePrefix = "<span class=\"EXCLUDEDINCLUSIVENAMESPACE\">";
+
+ private static final int NODE_BEFORE_DOCUMENT_ELEMENT = -1;
+
+ private static final int NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT = 0;
+
+ private static final int NODE_AFTER_DOCUMENT_ELEMENT = 1;
+
+ static final AttrCompare ATTR_COMPARE = new AttrCompare();
+
+ // J+
+ private XMLSignatureInputDebugger() {
+ // do nothing
+ }
+
+ /**
+ * Constructor XMLSignatureInputDebugger
+ *
+ * @param xmlSignatureInput the signatur to pretty print
+ */
+ public XMLSignatureInputDebugger(
+ XMLSignatureInput xmlSignatureInput) {
+
+ if (!xmlSignatureInput.isNodeSet()) {
+ this._xpathNodeSet = null;
+ } else {
+ this._xpathNodeSet = xmlSignatureInput._inputNodeSet;
+ }
+ }
+
+ /**
+ * Constructor XMLSignatureInputDebugger
+ *
+ * @param xmlSignatureInput the signatur to pretty print
+ * @param inclusiveNamespace
+ */
+ public XMLSignatureInputDebugger(
+ XMLSignatureInput xmlSignatureInput, Set inclusiveNamespace) {
+
+ this(xmlSignatureInput);
+
+ this._inclusiveNamespaces = inclusiveNamespace;
+ }
+
+ /**
+ * Method getHTMLRepresentation
+ *
+ * @return The HTML Representation.
+ * @throws XMLSignatureException
+ */
+ public String getHTMLRepresentation() throws XMLSignatureException {
+
+ if ((this._xpathNodeSet == null) || (this._xpathNodeSet.size() == 0)) {
+ return HTMLPrefix + "<blink>no node set, sorry</blink>"
+ + HTMLSuffix;
+ }
+
+ {
+
+ // get only a single node as anchor to fetch the owner document
+ Node n = (Node) this._xpathNodeSet.iterator().next();
+
+ this._doc = XMLUtils.getOwnerDocument(n);
+ }
+
+ try {
+ this._writer = new StringWriter();
+
+ this.canonicalizeXPathNodeSet(this._doc);
+ this._writer.close();
+
+ return this._writer.toString();
+ } catch (IOException ex) {
+ throw new XMLSignatureException("empty", ex);
+ } finally {
+ this._xpathNodeSet = null;
+ this._doc = null;
+ this._writer = null;
+ }
+ }
+
+ /**
+ * Method canonicalizeXPathNodeSet
+ *
+ * @param currentNode
+ * @throws XMLSignatureException
+ * @throws IOException
+ */
+ private void canonicalizeXPathNodeSet(Node currentNode)
+ throws XMLSignatureException, IOException {
+
+ int currentNodeType = currentNode.getNodeType();
+ switch (currentNodeType) {
+
+ case Node.DOCUMENT_TYPE_NODE:
+ default:
+ break;
+
+ case Node.ENTITY_NODE:
+ case Node.NOTATION_NODE:
+ case Node.DOCUMENT_FRAGMENT_NODE:
+ case Node.ATTRIBUTE_NODE:
+ throw new XMLSignatureException("empty");
+ case Node.DOCUMENT_NODE:
+ this._writer.write(HTMLPrefix);
+
+ for (Node currentChild = currentNode.getFirstChild(); currentChild != null; currentChild = currentChild
+ .getNextSibling()) {
+ this.canonicalizeXPathNodeSet(currentChild);
+ }
+
+ this._writer.write(HTMLSuffix);
+ break;
+
+ case Node.COMMENT_NODE:
+ if (this._xpathNodeSet.contains(currentNode)) {
+ this._writer.write(HTMLIncludePrefix);
+ } else {
+ this._writer.write(HTMLExcludePrefix);
+ }
+
+ int position = getPositionRelativeToDocumentElement(currentNode);
+
+ if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
+ this._writer.write("\n");
+ }
+
+ this.outputCommentToWriter((Comment) currentNode);
+
+ if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
+ this._writer.write("\n");
+ }
+
+ this._writer.write(HTMLIncludeOrExcludeSuffix);
+ break;
+
+ case Node.PROCESSING_INSTRUCTION_NODE:
+ if (this._xpathNodeSet.contains(currentNode)) {
+ this._writer.write(HTMLIncludePrefix);
+ } else {
+ this._writer.write(HTMLExcludePrefix);
+ }
+
+ position = getPositionRelativeToDocumentElement(currentNode);
+
+ if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
+ this._writer.write("\n");
+ }
+
+ this.outputPItoWriter((ProcessingInstruction) currentNode);
+
+ if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
+ this._writer.write("\n");
+ }
+
+ this._writer.write(HTMLIncludeOrExcludeSuffix);
+ break;
+
+ case Node.TEXT_NODE:
+ case Node.CDATA_SECTION_NODE:
+ if (this._xpathNodeSet.contains(currentNode)) {
+ this._writer.write(HTMLIncludePrefix);
+ } else {
+ this._writer.write(HTMLExcludePrefix);
+ }
+
+ outputTextToWriter(currentNode.getNodeValue());
+
+ for (Node nextSibling = currentNode.getNextSibling(); (nextSibling != null)
+ && ((nextSibling.getNodeType() == Node.TEXT_NODE) || (nextSibling
+ .getNodeType() == Node.CDATA_SECTION_NODE)); nextSibling = nextSibling
+ .getNextSibling()) {
+
+ /*
+ * The XPath data model allows to select only the first of a
+ * sequence of mixed text and CDATA nodes. But we must output
+ * them all, so we must search:
+ *
+ * @see http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6329
+ */
+ this.outputTextToWriter(nextSibling.getNodeValue());
+ }
+
+ this._writer.write(HTMLIncludeOrExcludeSuffix);
+ break;
+
+ case Node.ELEMENT_NODE:
+ Element currentElement = (Element) currentNode;
+
+ if (this._xpathNodeSet.contains(currentNode)) {
+ this._writer.write(HTMLIncludePrefix);
+ } else {
+ this._writer.write(HTMLExcludePrefix);
+ }
+
+ this._writer.write("<");
+ this._writer.write(currentElement.getTagName());
+
+ this._writer.write(HTMLIncludeOrExcludeSuffix);
+
+ // we output all Attrs which are available
+ NamedNodeMap attrs = currentElement.getAttributes();
+ int attrsLength = attrs.getLength();
+ Object attrs2[] = new Object[attrsLength];
+
+ for (int i = 0; i < attrsLength; i++) {
+ attrs2[i] = attrs.item(i);
+ }
+
+ Arrays.sort(attrs2, ATTR_COMPARE);
+ Object attrs3[] = attrs2;
+
+ for (int i = 0; i < attrsLength; i++) {
+ Attr a = (Attr) attrs3[i];
+ boolean included = this._xpathNodeSet.contains(a);
+ boolean inclusive = this._inclusiveNamespaces.contains(a
+ .getName());
+
+ if (included) {
+ if (inclusive) {
+
+ // included and inclusive
+ this._writer
+ .write(HTMLIncludedInclusiveNamespacePrefix);
+ } else {
+
+ // included and not inclusive
+ this._writer.write(HTMLIncludePrefix);
+ }
+ } else {
+ if (inclusive) {
+
+ // excluded and inclusive
+ this._writer
+ .write(HTMLExcludedInclusiveNamespacePrefix);
+ } else {
+
+ // excluded and not inclusive
+ this._writer.write(HTMLExcludePrefix);
+ }
+ }
+
+ this.outputAttrToWriter(a.getNodeName(), a.getNodeValue());
+
+ this._writer.write(HTMLIncludeOrExcludeSuffix);
+ }
+
+ if (this._xpathNodeSet.contains(currentNode)) {
+ this._writer.write(HTMLIncludePrefix);
+ } else {
+ this._writer.write(HTMLExcludePrefix);
+ }
+
+ this._writer.write(">");
+
+ this._writer.write(HTMLIncludeOrExcludeSuffix);
+
+ // traversal
+ for (Node currentChild = currentNode.getFirstChild(); currentChild != null; currentChild = currentChild
+ .getNextSibling()) {
+ this.canonicalizeXPathNodeSet(currentChild);
+ }
+
+ if (this._xpathNodeSet.contains(currentNode)) {
+ this._writer.write(HTMLIncludePrefix);
+ } else {
+ this._writer.write(HTMLExcludePrefix);
+ }
+
+ this._writer.write("</");
+ this._writer.write(currentElement.getTagName());
+ this._writer.write(">");
+
+ this._writer.write(HTMLIncludeOrExcludeSuffix);
+ break;
+ }
+ }
+
+ /**
+ * Checks whether a Comment or ProcessingInstruction is before or after the
+ * document element. This is needed for prepending or appending "\n"s.
+ *
+ * @param currentNode
+ * comment or pi to check
+ * @return NODE_BEFORE_DOCUMENT_ELEMENT,
+ * NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT or
+ * NODE_AFTER_DOCUMENT_ELEMENT
+ * @see #NODE_BEFORE_DOCUMENT_ELEMENT
+ * @see #NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT
+ * @see #NODE_AFTER_DOCUMENT_ELEMENT
+ */
+ private int getPositionRelativeToDocumentElement(Node currentNode) {
+
+ if (currentNode == null) {
+ return NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
+ }
+
+ Document doc = currentNode.getOwnerDocument();
+
+ if (currentNode.getParentNode() != doc) {
+ return NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
+ }
+
+ Element documentElement = doc.getDocumentElement();
+
+ if (documentElement == null) {
+ return NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
+ }
+
+ if (documentElement == currentNode) {
+ return NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
+ }
+
+ for (Node x = currentNode; x != null; x = x.getNextSibling()) {
+ if (x == documentElement) {
+ return NODE_BEFORE_DOCUMENT_ELEMENT;
+ }
+ }
+
+ return NODE_AFTER_DOCUMENT_ELEMENT;
+ }
+
+ /**
+ * Normalizes an {@link Attr}ibute value
+ *
+ * The string value of the node is modified by replacing
+ * <UL>
+ * <LI>all ampersands (&) with <CODE>&amp;</CODE></LI>
+ * <LI>all open angle brackets (<) with <CODE>&lt;</CODE></LI>
+ * <LI>all quotation mark characters with <CODE>&quot;</CODE></LI>
+ * <LI>and the whitespace characters <CODE>#x9</CODE>, #xA, and #xD,
+ * with character references. The character references are written in
+ * uppercase hexadecimal with no leading zeroes (for example, <CODE>#xD</CODE>
+ * is represented by the character reference <CODE>&#xD;</CODE>)</LI>
+ * </UL>
+ *
+ * @param name
+ * @param value
+ * @throws IOException
+ */
+ private void outputAttrToWriter(String name, String value)
+ throws IOException {
+
+ this._writer.write(" ");
+ this._writer.write(name);
+ this._writer.write("=\"");
+
+ int length = value.length();
+
+ for (int i = 0; i < length; i++) {
+ char c = value.charAt(i);
+
+ switch (c) {
+
+ case '&':
+ this._writer.write("&amp;");
+ break;
+
+ case '<':
+ this._writer.write("&lt;");
+ break;
+
+ case '"':
+ this._writer.write("&quot;");
+ break;
+
+ case 0x09: // '\t'
+ this._writer.write("&#x9;");
+ break;
+
+ case 0x0A: // '\n'
+ this._writer.write("&#xA;");
+ break;
+
+ case 0x0D: // '\r'
+ this._writer.write("&#xD;");
+ break;
+
+ default:
+ this._writer.write(c);
+ break;
+ }
+ }
+
+ this._writer.write("\"");
+ }
+
+ /**
+ * Normalizes a {@link org.w3c.dom.Comment} value
+ *
+ * @param currentPI
+ * @throws IOException
+ */
+ private void outputPItoWriter(ProcessingInstruction currentPI)
+ throws IOException {
+
+ if (currentPI == null) {
+ return;
+ }
+
+ this._writer.write("<?");
+
+ String target = currentPI.getTarget();
+ int length = target.length();
+
+ for (int i = 0; i < length; i++) {
+ char c = target.charAt(i);
+
+ switch (c) {
+
+ case 0x0D:
+ this._writer.write("&#xD;");
+ break;
+
+ case ' ':
+ this._writer.write("·");
+ break;
+
+ case '\n':
+ this._writer.write("¶\n");
+ break;
+
+ default:
+ this._writer.write(c);
+ break;
+ }
+ }
+
+ String data = currentPI.getData();
+
+ length = data.length();
+
+ if (length > 0) {
+ this._writer.write(" ");
+
+ for (int i = 0; i < length; i++) {
+ char c = data.charAt(i);
+
+ switch (c) {
+
+ case 0x0D:
+ this._writer.write("&#xD;");
+ break;
+
+ default:
+ this._writer.write(c);
+ break;
+ }
+ }
+ }
+
+ this._writer.write("?>");
+ }
+
+ /**
+ * Method outputCommentToWriter
+ *
+ * @param currentComment
+ * @throws IOException
+ */
+ private void outputCommentToWriter(Comment currentComment)
+ throws IOException {
+
+ if (currentComment == null) {
+ return;
+ }
+
+ this._writer.write("<!--");
+
+ String data = currentComment.getData();
+ int length = data.length();
+
+ for (int i = 0; i < length; i++) {
+ char c = data.charAt(i);
+
+ switch (c) {
+
+ case 0x0D:
+ this._writer.write("&#xD;");
+ break;
+
+ case ' ':
+ this._writer.write("·");
+ break;
+
+ case '\n':
+ this._writer.write("¶\n");
+ break;
+
+ default:
+ this._writer.write(c);
+ break;
+ }
+ }
+
+ this._writer.write("-->");
+ }
+
+ /**
+ * Method outputTextToWriter
+ *
+ * @param text
+ * @throws IOException
+ */
+ private void outputTextToWriter(String text) throws IOException {
+
+ if (text == null) {
+ return;
+ }
+
+ int length = text.length();
+
+ for (int i = 0; i < length; i++) {
+ char c = text.charAt(i);
+
+ switch (c) {
+
+ case '&':
+ this._writer.write("&amp;");
+ break;
+
+ case '<':
+ this._writer.write("&lt;");
+ break;
+
+ case '>':
+ this._writer.write("&gt;");
+ break;
+
+ case 0xD:
+ this._writer.write("&#xD;");
+ break;
+
+ case ' ':
+ this._writer.write("·");
+ break;
+
+ case '\n':
+ this._writer.write("¶\n");
+ break;
+
+ default:
+ this._writer.write(c);
+ break;
+ }
+ }
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/InvalidTransformException.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/InvalidTransformException.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/InvalidTransformException.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/InvalidTransformException.java Thu Jan 27 11:11:33 2011
@@ -29,9 +29,9 @@ import org.apache.xml.security.exception
public class InvalidTransformException extends XMLSecurityException {
/**
- *
- */
- private static final long serialVersionUID = 1L;
+ *
+ */
+ private static final long serialVersionUID = 1L;
/**
* Constructor InvalidTransformException
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transform.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transform.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transform.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transform.java Thu Jan 27 11:11:33 2011
@@ -92,9 +92,9 @@ public final class Transform extends Sig
}
if (log.isDebugEnabled()) {
- log.debug("Create URI \"" + algorithmURI + "\" class \""
+ log.debug("Create URI \"" + algorithmURI + "\" class \""
+ transformSpi.getClass() + "\"");
- log.debug("The NodeList is " + contextNodes);
+ log.debug("The NodeList is " + contextNodes);
}
// give it to the current document
@@ -136,7 +136,7 @@ public final class Transform extends Sig
if (transformSpi == null) {
Object exArgs[] = { algorithmURI };
throw new InvalidTransformException(
- "signature.Transform.UnknownTransform", exArgs);
+ "signature.Transform.UnknownTransform", exArgs);
}
}
@@ -236,9 +236,9 @@ public final class Transform extends Sig
}
try {
- transformClassHash.put
+ transformClassHash.put
(algorithmURI, ClassLoaderUtils.loadClass(implementingClass, Transform.class));
- } catch (ClassNotFoundException e) {
+ } catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
@@ -306,15 +306,15 @@ public final class Transform extends Sig
XMLSignatureInput result = null;
try {
- result = transformSpi.enginePerformTransform(input, os, this);
+ result = transformSpi.enginePerformTransform(input, os, this);
} catch (ParserConfigurationException ex) {
- Object exArgs[] = { this.getURI(), "ParserConfigurationException" };
- throw new CanonicalizationException(
- "signature.Transform.ErrorDuringTransform", exArgs, ex);
+ Object exArgs[] = { this.getURI(), "ParserConfigurationException" };
+ throw new CanonicalizationException(
+ "signature.Transform.ErrorDuringTransform", exArgs, ex);
} catch (SAXException ex) {
- Object exArgs[] = { this.getURI(), "SAXException" };
- throw new CanonicalizationException(
- "signature.Transform.ErrorDuringTransform", exArgs, ex);
+ Object exArgs[] = { this.getURI(), "SAXException" };
+ throw new CanonicalizationException(
+ "signature.Transform.ErrorDuringTransform", exArgs, ex);
}
return result;
@@ -333,26 +333,26 @@ public final class Transform extends Sig
private static TransformSpi getTransformSpi(String URI)
throws InvalidTransformException {
try {
- Object value = transformSpiHash.get(URI);
- if (value != null) {
- return (TransformSpi) value;
- }
- Class cl = (Class) transformClassHash.get(URI);
- if (cl != null) {
- TransformSpi tr = (TransformSpi) cl.newInstance();
- transformSpiHash.put(URI, tr);
- return tr;
- }
- } catch (InstantiationException ex) {
- Object exArgs[] = { URI };
+ Object value = transformSpiHash.get(URI);
+ if (value != null) {
+ return (TransformSpi) value;
+ }
+ Class cl = (Class) transformClassHash.get(URI);
+ if (cl != null) {
+ TransformSpi tr = (TransformSpi) cl.newInstance();
+ transformSpiHash.put(URI, tr);
+ return tr;
+ }
+ } catch (InstantiationException ex) {
+ Object exArgs[] = { URI };
throw new InvalidTransformException(
"signature.Transform.UnknownTransform", exArgs, ex);
- } catch (IllegalAccessException ex) {
- Object exArgs[] = { URI };
+ } catch (IllegalAccessException ex) {
+ Object exArgs[] = { URI };
throw new InvalidTransformException(
"signature.Transform.UnknownTransform", exArgs, ex);
- }
- return null;
+ }
+ return null;
}
/** @inheritDoc */
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/TransformSpi.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/TransformSpi.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/TransformSpi.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/TransformSpi.java Thu Jan 27 11:11:33 2011
@@ -92,16 +92,16 @@ public abstract class TransformSpi {
CanonicalizationException, InvalidCanonicalizerException,
TransformationException, ParserConfigurationException,
SAXException {
- //Default implementation overide with a much better
- try {
- TransformSpi tmp = (TransformSpi) getClass().newInstance();
- tmp.setTransform(_transformObject);
- return tmp.enginePerformTransform(input);
- } catch (InstantiationException e) {
- throw new TransformationException("",e);
- } catch (IllegalAccessException e) {
- throw new TransformationException("",e);
- }
+ //Default implementation overide with a much better
+ try {
+ TransformSpi tmp = (TransformSpi) getClass().newInstance();
+ tmp.setTransform(_transformObject);
+ return tmp.enginePerformTransform(input);
+ } catch (InstantiationException e) {
+ throw new TransformationException("",e);
+ } catch (IllegalAccessException e) {
+ throw new TransformationException("",e);
+ }
}
/**
@@ -122,7 +122,7 @@ public abstract class TransformSpi {
CanonicalizationException, InvalidCanonicalizerException,
TransformationException, ParserConfigurationException,
SAXException {
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException();
}
/**
* Returns the URI representation of <code>Transformation algorithm</code>
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/TransformationException.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/TransformationException.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/TransformationException.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/TransformationException.java Thu Jan 27 11:11:33 2011
@@ -29,9 +29,9 @@ import org.apache.xml.security.exception
public class TransformationException extends XMLSecurityException {
/**
- *
- */
- private static final long serialVersionUID = 1L;
+ *
+ */
+ private static final long serialVersionUID = 1L;
/**
* Constructor TransformationException
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transforms.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transforms.java?rev=1064079&r1=1064078&r2=1064079&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transforms.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/Transforms.java Thu Jan 27 11:11:33 2011
@@ -52,46 +52,46 @@ public class Transforms extends Signatur
org.apache.commons.logging.LogFactory.getLog(Transforms.class.getName());
/** Canonicalization - Required Canonical XML (omits comments) */
public static final String TRANSFORM_C14N_OMIT_COMMENTS
- = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+ = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
/** Canonicalization - Recommended Canonical XML with Comments */
public static final String TRANSFORM_C14N_WITH_COMMENTS
- = Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS;
+ = Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS;
/** Canonicalization - Required Canonical XML 1.1 (omits comments) */
public static final String TRANSFORM_C14N11_OMIT_COMMENTS
- = Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS;
+ = Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS;
/** Canonicalization - Recommended Canonical XML 1.1 with Comments */
public static final String TRANSFORM_C14N11_WITH_COMMENTS
- = Canonicalizer.ALGO_ID_C14N11_WITH_COMMENTS;
+ = Canonicalizer.ALGO_ID_C14N11_WITH_COMMENTS;
/** Canonicalization - Required Exclusive Canonicalization (omits comments) */
public static final String TRANSFORM_C14N_EXCL_OMIT_COMMENTS
- = Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS;
+ = Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS;
/** Canonicalization - Recommended Exclusive Canonicalization with Comments */
public static final String TRANSFORM_C14N_EXCL_WITH_COMMENTS
- = Canonicalizer.ALGO_ID_C14N_EXCL_WITH_COMMENTS;
+ = Canonicalizer.ALGO_ID_C14N_EXCL_WITH_COMMENTS;
/** Transform - Optional XSLT */
public static final String TRANSFORM_XSLT
- = "http://www.w3.org/TR/1999/REC-xslt-19991116";
+ = "http://www.w3.org/TR/1999/REC-xslt-19991116";
/** Transform - Required base64 decoding */
public static final String TRANSFORM_BASE64_DECODE
- = Constants.SignatureSpecNS + "base64";
+ = Constants.SignatureSpecNS + "base64";
/** Transform - Recommended XPath */
public static final String TRANSFORM_XPATH
- = "http://www.w3.org/TR/1999/REC-xpath-19991116";
+ = "http://www.w3.org/TR/1999/REC-xpath-19991116";
/** Transform - Required Enveloped Signature */
public static final String TRANSFORM_ENVELOPED_SIGNATURE
- = Constants.SignatureSpecNS + "enveloped-signature";
+ = Constants.SignatureSpecNS + "enveloped-signature";
/** Transform - XPointer */
public static final String TRANSFORM_XPOINTER
- = "http://www.w3.org/TR/2001/WD-xptr-20010108";
+ = "http://www.w3.org/TR/2001/WD-xptr-20010108";
/** Transform - XPath Filter v2.0 */
public static final String TRANSFORM_XPATH2FILTER04
- = "http://www.w3.org/2002/04/xmldsig-filter2";
+ = "http://www.w3.org/2002/04/xmldsig-filter2";
/** Transform - XPath Filter */
public static final String TRANSFORM_XPATH2FILTER
- = "http://www.w3.org/2002/06/xmldsig-filter2";
+ = "http://www.w3.org/2002/06/xmldsig-filter2";
/** Transform - XPath Filter CHGP private */
public static final String TRANSFORM_XPATHFILTERCHGP
- = "http://www.nue.et-inf.uni-siegen.de/~geuer-pollmann/#xpathFilter";
+ = "http://www.nue.et-inf.uni-siegen.de/~geuer-pollmann/#xpathFilter";
Element []transforms;
@@ -152,10 +152,10 @@ public class Transforms extends Signatur
try {
if (log.isDebugEnabled())
- log.debug("Transforms.addTransform(" + transformURI + ")");
+ log.debug("Transforms.addTransform(" + transformURI + ")");
Transform transform =
- Transform.getInstance(this._doc, transformURI);
+ Transform.getInstance(this._doc, transformURI);
this.addTransform(transform);
} catch (InvalidTransformException ex) {
@@ -178,10 +178,10 @@ public class Transforms extends Signatur
try {
if (log.isDebugEnabled())
- log.debug("Transforms.addTransform(" + transformURI + ")");
+ log.debug("Transforms.addTransform(" + transformURI + ")");
Transform transform =
- Transform.getInstance(this._doc, transformURI, contextElement);
+ Transform.getInstance(this._doc, transformURI, contextElement);
this.addTransform(transform);
} catch (InvalidTransformException ex) {
@@ -204,7 +204,7 @@ public class Transforms extends Signatur
try {
Transform transform =
- Transform.getInstance(this._doc, transformURI, contextNodes);
+ Transform.getInstance(this._doc, transformURI, contextNodes);
this.addTransform(transform);
} catch (InvalidTransformException ex) {
throw new TransformationException("empty", ex);
@@ -218,7 +218,7 @@ public class Transforms extends Signatur
*/
private void addTransform(Transform transform) {
if (log.isDebugEnabled())
- log.debug("Transforms.addTransform(" + transform.getURI() + ")");
+ log.debug("Transforms.addTransform(" + transform.getURI() + ")");
Element transformElement = transform.getElement();
@@ -250,25 +250,25 @@ public class Transforms extends Signatur
*/
public XMLSignatureInput performTransforms(
XMLSignatureInput xmlSignatureInput, OutputStream os)
- throws TransformationException {
+ throws TransformationException {
- try {
+ try {
int last=this.getLength()-1;
for (int i = 0; i < last; i++) {
Transform t = this.item(i);
if (log.isDebugEnabled()) {
- log.debug("Perform the (" + i + ")th " + t.getURI()
- + " transform");
+ log.debug("Perform the (" + i + ")th " + t.getURI()
+ + " transform");
}
- xmlSignatureInput = t.performTransform(xmlSignatureInput);
+ xmlSignatureInput = t.performTransform(xmlSignatureInput);
}
if (last>=0) {
- Transform t = this.item(last);
+ Transform t = this.item(last);
xmlSignatureInput = t.performTransform(xmlSignatureInput, os);
}
return xmlSignatureInput;
- } catch (IOException ex) {
+ } catch (IOException ex) {
throw new TransformationException("empty", ex);
} catch (CanonicalizationException ex) {
throw new TransformationException("empty", ex);
@@ -286,7 +286,7 @@ public class Transforms extends Signatur
{
if (transforms == null) {
transforms = XMLUtils.selectDsNodes
- (this._constructionElement.getFirstChild(), "Transform");
+ (this._constructionElement.getFirstChild(), "Transform");
}
return transforms.length;
}
@@ -300,16 +300,16 @@ public class Transforms extends Signatur
* @throws TransformationException
*/
public Transform item(int i) throws TransformationException {
-
- try {
- if (transforms == null) {
- transforms = XMLUtils.selectDsNodes
- (this._constructionElement.getFirstChild(), "Transform");
- }
- return new Transform(transforms[i], this._baseURI);
- } catch (XMLSecurityException ex) {
- throw new TransformationException("empty", ex);
- }
+
+ try {
+ if (transforms == null) {
+ transforms = XMLUtils.selectDsNodes
+ (this._constructionElement.getFirstChild(), "Transform");
+ }
+ return new Transform(transforms[i], this._baseURI);
+ } catch (XMLSecurityException ex) {
+ throw new TransformationException("empty", ex);
+ }
}
/** @inheritDoc */