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/02/02 12:10:00 UTC
svn commit: r1066412 [2/2] - in /santuario/xml-security-java/trunk:
samples/org/apache/xml/security/samples/
src/main/java/org/apache/xml/security/algorithms/
src/main/java/org/apache/xml/security/encryption/
src/main/java/org/apache/xml/security/keys/...
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=1066412&r1=1066411&r2=1066412&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 Wed Feb 2 11:09:58 2011
@@ -200,28 +200,28 @@ public final class XMLSignature extends
String xmlnsDsPrefix =
getDefaultPrefixBindings(Constants.SignatureSpecNS);
if (xmlnsDsPrefix == null) {
- this._constructionElement.setAttributeNS
+ this.constructionElement.setAttributeNS
(Constants.NamespaceSpecNS, "xmlns", Constants.SignatureSpecNS);
} else {
- this._constructionElement.setAttributeNS
+ this.constructionElement.setAttributeNS
(Constants.NamespaceSpecNS, xmlnsDsPrefix, Constants.SignatureSpecNS);
}
- XMLUtils.addReturnToElement(this._constructionElement);
+ XMLUtils.addReturnToElement(this.constructionElement);
- this._baseURI = BaseURI;
+ this.baseURI = BaseURI;
this._signedInfo = new SignedInfo
- (this._doc, SignatureMethodURI, HMACOutputLength,
+ (this.doc, SignatureMethodURI, HMACOutputLength,
CanonicalizationMethodURI);
- this._constructionElement.appendChild(this._signedInfo.getElement());
- XMLUtils.addReturnToElement(this._constructionElement);
+ this.constructionElement.appendChild(this._signedInfo.getElement());
+ XMLUtils.addReturnToElement(this.constructionElement);
// create an empty SignatureValue; this is filled by setSignatureValueElement
signatureValueElement = XMLUtils.createElementInSignatureSpace
- (this._doc, Constants._TAG_SIGNATUREVALUE);
+ (this.doc, Constants._TAG_SIGNATUREVALUE);
- this._constructionElement.appendChild(signatureValueElement);
- XMLUtils.addReturnToElement(this._constructionElement);
+ this.constructionElement.appendChild(signatureValueElement);
+ XMLUtils.addReturnToElement(this.constructionElement);
}
/**
@@ -241,27 +241,27 @@ public final class XMLSignature extends
String xmlnsDsPrefix =
getDefaultPrefixBindings(Constants.SignatureSpecNS);
if (xmlnsDsPrefix == null) {
- this._constructionElement.setAttributeNS
+ this.constructionElement.setAttributeNS
(Constants.NamespaceSpecNS, "xmlns", Constants.SignatureSpecNS);
} else {
- this._constructionElement.setAttributeNS
+ this.constructionElement.setAttributeNS
(Constants.NamespaceSpecNS, xmlnsDsPrefix, Constants.SignatureSpecNS);
}
- XMLUtils.addReturnToElement(this._constructionElement);
+ XMLUtils.addReturnToElement(this.constructionElement);
- this._baseURI = BaseURI;
+ this.baseURI = BaseURI;
this._signedInfo = new SignedInfo
- (this._doc, SignatureMethodElem, CanonicalizationMethodElem);
+ (this.doc, SignatureMethodElem, CanonicalizationMethodElem);
- this._constructionElement.appendChild(this._signedInfo.getElement());
- XMLUtils.addReturnToElement(this._constructionElement);
+ this.constructionElement.appendChild(this._signedInfo.getElement());
+ XMLUtils.addReturnToElement(this.constructionElement);
// create an empty SignatureValue; this is filled by setSignatureValueElement
signatureValueElement = XMLUtils.createElementInSignatureSpace
- (this._doc, Constants._TAG_SIGNATUREVALUE);
+ (this.doc, Constants._TAG_SIGNATUREVALUE);
- this._constructionElement.appendChild(signatureValueElement);
- XMLUtils.addReturnToElement(this._constructionElement);
+ this.constructionElement.appendChild(signatureValueElement);
+ XMLUtils.addReturnToElement(this.constructionElement);
}
/**
@@ -327,8 +327,8 @@ public final class XMLSignature extends
*/
public void setId(String id) {
if (id != null) {
- this._constructionElement.setAttributeNS(null, Constants._ATT_ID, id);
- IdResolver.registerElementById(this._constructionElement, id);
+ this.constructionElement.setAttributeNS(null, Constants._ATT_ID, id);
+ IdResolver.registerElementById(this.constructionElement, id);
}
}
@@ -338,7 +338,7 @@ public final class XMLSignature extends
* @return the <code>Id</code> attribute
*/
public String getId() {
- return this._constructionElement.getAttributeNS(null, Constants._ATT_ID);
+ return this.constructionElement.getAttributeNS(null, Constants._ATT_ID);
}
/**
@@ -384,7 +384,7 @@ public final class XMLSignature extends
base64codedValue = "\n" + base64codedValue + "\n";
}
- Text t = this._doc.createTextNode(base64codedValue);
+ Text t = this.doc.createTextNode(base64codedValue);
signatureValueElement.appendChild(t);
}
@@ -402,24 +402,24 @@ public final class XMLSignature extends
if (this._state == MODE_SIGN && this._keyInfo == null) {
// create the KeyInfo
- this._keyInfo = new KeyInfo(this._doc);
+ this._keyInfo = new KeyInfo(this.doc);
// get the Element from KeyInfo
Element keyInfoElement = this._keyInfo.getElement();
Element firstObject = XMLUtils.selectDsNode
- (this._constructionElement.getFirstChild(),
+ (this.constructionElement.getFirstChild(),
Constants._TAG_OBJECT, 0);
if (firstObject != null) {
// add it before the object
- this._constructionElement.insertBefore(keyInfoElement,
+ this.constructionElement.insertBefore(keyInfoElement,
firstObject);
XMLUtils.addReturnBeforeChild
- (this._constructionElement, firstObject);
+ (this.constructionElement, firstObject);
} else {
// add it as the last element to the signature
- this._constructionElement.appendChild(keyInfoElement);
- XMLUtils.addReturnToElement(this._constructionElement);
+ this.constructionElement.appendChild(keyInfoElement);
+ XMLUtils.addReturnToElement(this.constructionElement);
}
}
@@ -443,8 +443,8 @@ public final class XMLSignature extends
// "signature.operationOnlyBeforeSign");
//}
- this._constructionElement.appendChild(object.getElement());
- XMLUtils.addReturnToElement(this._constructionElement);
+ this.constructionElement.appendChild(object.getElement());
+ XMLUtils.addReturnToElement(this.constructionElement);
//} catch (XMLSecurityException ex) {
// throw new XMLSignatureException("empty", ex);
//}
@@ -461,10 +461,10 @@ public final class XMLSignature extends
public ObjectContainer getObjectItem(int i) {
Element objElem = XMLUtils.selectDsNode
- (this._constructionElement.getFirstChild(), Constants._TAG_OBJECT, i);
+ (this.constructionElement.getFirstChild(), Constants._TAG_OBJECT, i);
try {
- return new ObjectContainer(objElem, this._baseURI);
+ return new ObjectContainer(objElem, this.baseURI);
} catch (XMLSecurityException ex) {
return null;
}
@@ -657,7 +657,7 @@ public final class XMLSignature extends
public void addDocument(String referenceURI, Transforms trans,
String digestURI, String ReferenceId, String ReferenceType)
throws XMLSignatureException {
- this._signedInfo.addDocument(this._baseURI, referenceURI, trans,
+ this._signedInfo.addDocument(this.baseURI, referenceURI, trans,
digestURI, ReferenceId, ReferenceType);
}
@@ -672,7 +672,7 @@ public final class XMLSignature extends
*/
public void addDocument(String referenceURI, Transforms trans,
String digestURI) throws XMLSignatureException {
- this._signedInfo.addDocument(this._baseURI, referenceURI, trans,
+ this._signedInfo.addDocument(this.baseURI, referenceURI, trans,
digestURI, null, null);
}
@@ -686,7 +686,7 @@ public final class XMLSignature extends
*/
public void addDocument(String referenceURI, Transforms trans)
throws XMLSignatureException {
- this._signedInfo.addDocument(this._baseURI, referenceURI, trans,
+ this._signedInfo.addDocument(this.baseURI, referenceURI, trans,
Constants.ALGO_ID_DIGEST_SHA1, null, null);
}
@@ -698,7 +698,7 @@ public final class XMLSignature extends
* @throws XMLSignatureException
*/
public void addDocument(String referenceURI) throws XMLSignatureException {
- this._signedInfo.addDocument(this._baseURI, referenceURI, null,
+ this._signedInfo.addDocument(this.baseURI, referenceURI, null,
Constants.ALGO_ID_DIGEST_SHA1, null, null);
}
@@ -712,7 +712,7 @@ public final class XMLSignature extends
*/
public void addKeyInfo(X509Certificate cert) throws XMLSecurityException {
- X509Data x509data = new X509Data(this._doc);
+ X509Data x509data = new X509Data(this.doc);
x509data.addCertificate(cert);
this.getKeyInfo().add(x509data);
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=1066412&r1=1066411&r2=1066412&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 Wed Feb 2 11:09:58 2011
@@ -47,8 +47,8 @@ public class XMLSignatureInputDebugger {
private Set _inclusiveNamespaces;
- /** Field _doc */
- private Document _doc = null;
+ /** Field doc */
+ private Document doc = null;
/** Field _writer */
private Writer _writer = null;
@@ -174,13 +174,13 @@ public class XMLSignatureInputDebugger {
// get only a single node as anchor to fetch the owner document
Node n = (Node) this._xpathNodeSet.iterator().next();
- this._doc = XMLUtils.getOwnerDocument(n);
+ this.doc = XMLUtils.getOwnerDocument(n);
}
try {
this._writer = new StringWriter();
- this.canonicalizeXPathNodeSet(this._doc);
+ this.canonicalizeXPathNodeSet(this.doc);
this._writer.close();
return this._writer.toString();
@@ -188,7 +188,7 @@ public class XMLSignatureInputDebugger {
throw new XMLSignatureException("empty", ex);
} finally {
this._xpathNodeSet = null;
- this._doc = null;
+ this.doc = null;
this._writer = null;
}
}
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=1066412&r1=1066411&r2=1066412&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 Wed Feb 2 11:09:58 2011
@@ -81,7 +81,7 @@ public final class Transform extends Sig
super(doc);
- this._constructionElement.setAttributeNS
+ this.constructionElement.setAttributeNS
(null, Constants._ATT_ALGORITHM, algorithmURI);
transformSpi = getTransformSpi(algorithmURI);
@@ -100,7 +100,7 @@ public final class Transform extends Sig
// give it to the current document
if (contextNodes != null) {
for (int i = 0; i < contextNodes.getLength(); i++) {
- this._constructionElement.appendChild
+ this.constructionElement.appendChild
(contextNodes.item(i).cloneNode(true));
}
}
@@ -249,7 +249,7 @@ public final class Transform extends Sig
* @return the URI representation of Transformation algorithm
*/
public String getURI() {
- return this._constructionElement.getAttributeNS
+ return this.constructionElement.getAttributeNS
(null, Constants._ATT_ALGORITHM);
}
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=1066412&r1=1066411&r2=1066412&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 Wed Feb 2 11:09:58 2011
@@ -105,7 +105,7 @@ public class Transforms extends Signatur
*/
public Transforms(Document doc) {
super(doc);
- XMLUtils.addReturnToElement(this._constructionElement);
+ XMLUtils.addReturnToElement(this.constructionElement);
}
/**
@@ -155,7 +155,7 @@ public class Transforms extends Signatur
log.debug("Transforms.addTransform(" + transformURI + ")");
Transform transform =
- Transform.getInstance(this._doc, transformURI);
+ Transform.getInstance(this.doc, transformURI);
this.addTransform(transform);
} catch (InvalidTransformException ex) {
@@ -181,7 +181,7 @@ public class Transforms extends Signatur
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);
@@ -222,8 +222,8 @@ public class Transforms extends Signatur
Element transformElement = transform.getElement();
- this._constructionElement.appendChild(transformElement);
- XMLUtils.addReturnToElement(this._constructionElement);
+ this.constructionElement.appendChild(transformElement);
+ XMLUtils.addReturnToElement(this.constructionElement);
}
/**
@@ -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;
}
@@ -304,9 +304,9 @@ public class Transforms extends Signatur
try {
if (transforms == null) {
transforms = XMLUtils.selectDsNodes
- (this._constructionElement.getFirstChild(), "Transform");
+ (this.constructionElement.getFirstChild(), "Transform");
}
- return new Transform(transforms[i], this._baseURI);
+ return new Transform(transforms[i], this.baseURI);
} catch (XMLSecurityException ex) {
throw new TransformationException("empty", ex);
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/InclusiveNamespaces.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/InclusiveNamespaces.java?rev=1066412&r1=1066411&r2=1066412&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/InclusiveNamespaces.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/InclusiveNamespaces.java Wed Feb 2 11:09:58 2011
@@ -90,7 +90,7 @@ public class InclusiveNamespaces extends
}
}
- this._constructionElement
+ this.constructionElement
.setAttributeNS(null, InclusiveNamespaces._ATT_EC_PREFIXLIST,
sb.toString().trim());
}
@@ -101,7 +101,7 @@ public class InclusiveNamespaces extends
* @return The Inclusive Namespace string
*/
public String getInclusiveNamespaces() {
- return this._constructionElement
+ return this.constructionElement
.getAttributeNS(null, InclusiveNamespaces._ATT_EC_PREFIXLIST);
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer.java?rev=1066412&r1=1066411&r2=1066412&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer.java Wed Feb 2 11:09:58 2011
@@ -92,9 +92,9 @@ public class XPath2FilterContainer exten
super(doc);
- this._constructionElement
+ this.constructionElement
.setAttributeNS(null, XPath2FilterContainer._ATT_FILTER, filterType);
- this._constructionElement.appendChild(doc.createTextNode(xpath2filter));
+ this.constructionElement.appendChild(doc.createTextNode(xpath2filter));
}
/**
@@ -109,7 +109,7 @@ public class XPath2FilterContainer exten
super(element, BaseURI);
- String filterStr = this._constructionElement.getAttributeNS(null,
+ String filterStr = this.constructionElement.getAttributeNS(null,
XPath2FilterContainer._ATT_FILTER);
if (!filterStr
@@ -231,7 +231,7 @@ public class XPath2FilterContainer exten
*/
public boolean isIntersect() {
- return this._constructionElement
+ return this.constructionElement
.getAttributeNS(null, XPath2FilterContainer._ATT_FILTER)
.equals(XPath2FilterContainer._ATT_FILTER_VALUE_INTERSECT);
}
@@ -243,7 +243,7 @@ public class XPath2FilterContainer exten
*/
public boolean isSubtract() {
- return this._constructionElement
+ return this.constructionElement
.getAttributeNS(null, XPath2FilterContainer._ATT_FILTER)
.equals(XPath2FilterContainer._ATT_FILTER_VALUE_SUBTRACT);
}
@@ -255,7 +255,7 @@ public class XPath2FilterContainer exten
*/
public boolean isUnion() {
- return this._constructionElement
+ return this.constructionElement
.getAttributeNS(null, XPath2FilterContainer._ATT_FILTER)
.equals(XPath2FilterContainer._ATT_FILTER_VALUE_UNION);
}
@@ -279,7 +279,7 @@ public class XPath2FilterContainer exten
*/
public Node getXPathFilterTextNode() {
- NodeList children = this._constructionElement.getChildNodes();
+ NodeList children = this.constructionElement.getChildNodes();
int length = children.getLength();
for (int i = 0; i < length; i++) {
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer04.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer04.java?rev=1066412&r1=1066411&r2=1066412&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer04.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer04.java Wed Feb 2 11:09:58 2011
@@ -79,16 +79,16 @@ public class XPath2FilterContainer04 ext
super(doc);
- this._constructionElement.setAttributeNS(null, XPath2FilterContainer04._ATT_FILTER,
+ this.constructionElement.setAttributeNS(null, XPath2FilterContainer04._ATT_FILTER,
filterType);
if ((xpath2filter.length() > 2)
&& (!Character.isWhitespace(xpath2filter.charAt(0)))) {
- XMLUtils.addReturnToElement(this._constructionElement);
- this._constructionElement.appendChild(doc.createTextNode(xpath2filter));
- XMLUtils.addReturnToElement(this._constructionElement);
+ XMLUtils.addReturnToElement(this.constructionElement);
+ this.constructionElement.appendChild(doc.createTextNode(xpath2filter));
+ XMLUtils.addReturnToElement(this.constructionElement);
} else {
- this._constructionElement
+ this.constructionElement
.appendChild(doc.createTextNode(xpath2filter));
}
}
@@ -106,7 +106,7 @@ public class XPath2FilterContainer04 ext
super(element, BaseURI);
String filterStr =
- this._constructionElement
+ this.constructionElement
.getAttributeNS(null, XPath2FilterContainer04._ATT_FILTER);
if (!filterStr
@@ -192,7 +192,7 @@ public class XPath2FilterContainer04 ext
*/
public boolean isIntersect() {
- return this._constructionElement
+ return this.constructionElement
.getAttributeNS(null, XPath2FilterContainer04._ATT_FILTER)
.equals(XPath2FilterContainer04._ATT_FILTER_VALUE_INTERSECT);
}
@@ -204,7 +204,7 @@ public class XPath2FilterContainer04 ext
*/
public boolean isSubtract() {
- return this._constructionElement
+ return this.constructionElement
.getAttributeNS(null, XPath2FilterContainer04._ATT_FILTER)
.equals(XPath2FilterContainer04._ATT_FILTER_VALUE_SUBTRACT);
}
@@ -216,7 +216,7 @@ public class XPath2FilterContainer04 ext
*/
public boolean isUnion() {
- return this._constructionElement
+ return this.constructionElement
.getAttributeNS(null, XPath2FilterContainer04._ATT_FILTER)
.equals(XPath2FilterContainer04._ATT_FILTER_VALUE_UNION);
}
@@ -239,7 +239,7 @@ public class XPath2FilterContainer04 ext
* @return the first Text node which contains information from the XPath 2 Filter String
*/
public Node getXPathFilterTextNode() {
- NodeList children = this._constructionElement.getChildNodes();
+ NodeList children = this.constructionElement.getChildNodes();
int length = children.getLength();
for (int i = 0; i < length; i++) {
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathContainer.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathContainer.java?rev=1066412&r1=1066411&r2=1066412&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathContainer.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathContainer.java Wed Feb 2 11:09:58 2011
@@ -51,16 +51,16 @@ public class XPathContainer extends Sign
*/
public void setXPath(String xpath) {
- if (this._constructionElement.getChildNodes() != null) {
- NodeList nl = this._constructionElement.getChildNodes();
+ if (this.constructionElement.getChildNodes() != null) {
+ NodeList nl = this.constructionElement.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
- this._constructionElement.removeChild(nl.item(i));
+ this.constructionElement.removeChild(nl.item(i));
}
}
- Text xpathText = this._doc.createTextNode(xpath);
- this._constructionElement.appendChild(xpathText);
+ Text xpathText = this.doc.createTextNode(xpath);
+ this.constructionElement.appendChild(xpathText);
}
/**
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathFilterCHGPContainer.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathFilterCHGPContainer.java?rev=1066412&r1=1066411&r2=1066412&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathFilterCHGPContainer.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/params/XPathFilterCHGPContainer.java Wed Feb 2 11:09:58 2011
@@ -83,10 +83,10 @@ public class XPathFilterCHGPContainer ex
super(doc);
if (includeSlashPolicy) {
- this._constructionElement
+ this.constructionElement
.setAttributeNS(null, XPathFilterCHGPContainer._ATT_INCLUDESLASH, "true");
} else {
- this._constructionElement
+ this.constructionElement
.setAttributeNS(null, XPathFilterCHGPContainer._ATT_INCLUDESLASH, "false");
}
@@ -98,10 +98,10 @@ public class XPathFilterCHGPContainer ex
._TAG_INCLUDE_BUT_SEARCH);
includeButSearchElem
- .appendChild(this._doc
+ .appendChild(this.doc
.createTextNode(indentXPathText(includeButSearch)));
- XMLUtils.addReturnToElement(this._constructionElement);
- this._constructionElement.appendChild(includeButSearchElem);
+ XMLUtils.addReturnToElement(this.constructionElement);
+ this.constructionElement.appendChild(includeButSearchElem);
}
if ((excludeButSearch != null)
@@ -112,10 +112,10 @@ public class XPathFilterCHGPContainer ex
._TAG_EXCLUDE_BUT_SEARCH);
excludeButSearchElem
- .appendChild(this._doc
+ .appendChild(this.doc
.createTextNode(indentXPathText(excludeButSearch)));
- XMLUtils.addReturnToElement(this._constructionElement);
- this._constructionElement.appendChild(excludeButSearchElem);
+ XMLUtils.addReturnToElement(this.constructionElement);
+ this.constructionElement.appendChild(excludeButSearchElem);
}
if ((exclude != null) && (exclude.trim().length() > 0)) {
@@ -124,12 +124,12 @@ public class XPathFilterCHGPContainer ex
XPathFilterCHGPContainer._TAG_EXCLUDE);
excludeElem
- .appendChild(this._doc.createTextNode(indentXPathText(exclude)));
- XMLUtils.addReturnToElement(this._constructionElement);
- this._constructionElement.appendChild(excludeElem);
+ .appendChild(this.doc.createTextNode(indentXPathText(exclude)));
+ XMLUtils.addReturnToElement(this.constructionElement);
+ this.constructionElement.appendChild(excludeElem);
}
- XMLUtils.addReturnToElement(this._constructionElement);
+ XMLUtils.addReturnToElement(this.constructionElement);
}
/**
@@ -204,7 +204,7 @@ public class XPathFilterCHGPContainer ex
return "";
}
- Element xElem = XMLUtils.selectNode(this._constructionElement.getFirstChild(), this.getBaseNamespace(),
+ Element xElem = XMLUtils.selectNode(this.constructionElement.getFirstChild(), this.getBaseNamespace(),
type,0);
return XMLUtils.getFullTextChildrenFromElement(xElem);
@@ -244,7 +244,7 @@ public class XPathFilterCHGPContainer ex
*/
public boolean getIncludeSlashPolicy() {
- return this._constructionElement
+ return this.constructionElement
.getAttributeNS(null, XPathFilterCHGPContainer._ATT_INCLUDESLASH)
.equals("true");
}
@@ -264,7 +264,7 @@ public class XPathFilterCHGPContainer ex
return null;
}
- return XMLUtils.selectNodeText(this._constructionElement.getFirstChild(), this.getBaseNamespace(),
+ return XMLUtils.selectNodeText(this.constructionElement.getFirstChild(), this.getBaseNamespace(),
type,0);
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/ElementProxy.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/ElementProxy.java?rev=1066412&r1=1066411&r2=1066412&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/ElementProxy.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/ElementProxy.java Wed Feb 2 11:09:58 2011
@@ -16,10 +16,9 @@
*/
package org.apache.xml.security.utils;
-
-
import java.math.BigInteger;
import java.util.HashMap;
+import java.util.Map;
import org.apache.xml.security.exceptions.Base64DecodingException;
import org.apache.xml.security.exceptions.XMLSecurityException;
@@ -30,7 +29,6 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
-
/**
* This is the base class to all Objects which have a direct 1:1 mapping to an
* Element in a particular namespace.
@@ -39,466 +37,444 @@ import org.w3c.dom.Text;
*/
public abstract class ElementProxy {
- /** {@link org.apache.commons.logging} logging facility */
+ /** {@link org.apache.commons.logging} logging facility */
static org.apache.commons.logging.Log log =
org.apache.commons.logging.LogFactory.getLog(ElementProxy.class.getName());
-
- /**
- * Returns the namespace of the Elements of the sub-class.
- *
- * @return the namespace of the Elements of the sub-class.
- */
- public abstract String getBaseNamespace();
-
- /**
- * Returns the localname of the Elements of the sub-class.
- *
- * @return the localname of the Elements of the sub-class.
- */
- public abstract String getBaseLocalName();
-
- /** Field _constructionElement */
- protected Element _constructionElement = null;
-
- /** Field _baseURI */
- protected String _baseURI = null;
-
- /** Field _doc */
- protected Document _doc = null;
-
- /**
- * Constructor ElementProxy
- *
- */
- public ElementProxy() {
- }
-
- /**
- * Constructor ElementProxy
- *
- * @param doc
- */
- public ElementProxy(Document doc) {
- if (doc == null) {
- throw new RuntimeException("Document is null");
- }
-
- this._doc = doc;
- this._constructionElement = createElementForFamilyLocal(this._doc,
- this.getBaseNamespace(), this.getBaseLocalName());
- }
- protected Element createElementForFamilyLocal(Document doc, String namespace,
- String localName) {
- Element result = null;
- if (namespace == null) {
- result = doc.createElementNS(null, localName);
- } else {
- String baseName=this.getBaseNamespace();
- String prefix=ElementProxy.getDefaultPrefix(baseName);
- if ((prefix == null) || (prefix.length() == 0)) {
- result = doc.createElementNS(namespace, localName);
-
- result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns",
- namespace);
- } else {
- String tagName=null;
- String defaultPrefixNaming=ElementProxy.getDefaultPrefixBindings(baseName);
- StringBuffer sb=new StringBuffer(prefix);
- sb.append(':');
- sb.append(localName);
- tagName=sb.toString();
- result = doc.createElementNS(namespace, tagName );
-
- result.setAttributeNS(Constants.NamespaceSpecNS, defaultPrefixNaming,
- namespace);
- }
- }
- return result;
-}
+ /** Field constructionElement */
+ protected Element constructionElement = null;
- /**
- * This method creates an Element in a given namespace with a given localname.
- * It uses the {@link ElementProxy#getDefaultPrefix} method to decide whether
- * a particular prefix is bound to that namespace.
- * <BR />
- * This method was refactored out of the constructor.
- *
- * @param doc
- * @param namespace
- * @param localName
- * @return The element created.
- */
- public static Element createElementForFamily(Document doc, String namespace,
- String localName) {
- //Element nscontext = XMLUtils.createDSctx(doc, "x", namespace);
- Element result = null;
- String prefix = ElementProxy.getDefaultPrefix(namespace);
-
- if (namespace == null) {
- result = doc.createElementNS(null, localName);
- } else {
- if ((prefix == null) || (prefix.length() == 0)) {
- result = doc.createElementNS(namespace, localName);
-
- result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns",
- namespace);
- } else {
- result = doc.createElementNS(namespace, prefix + ":" + localName);
-
- result.setAttributeNS(Constants.NamespaceSpecNS, ElementProxy.getDefaultPrefixBindings(namespace),
- namespace);
- }
- }
-
- return result;
- }
-
- /**
- * Method setElement
- *
- * @param element
- * @param BaseURI
- * @throws XMLSecurityException
- */
- public void setElement(Element element, String BaseURI)
- throws XMLSecurityException {
-
- if (element == null) {
- throw new XMLSecurityException("ElementProxy.nullElement");
- }
-
- if (log.isDebugEnabled()) {
- log.debug("setElement(" + element.getTagName() + ", \"" + BaseURI + "\"");
- }
-
- this._doc = element.getOwnerDocument();
- this._constructionElement = element;
- this._baseURI = BaseURI;
- }
-
- /**
- * Constructor ElementProxy
- *
- * @param element
- * @param BaseURI
- * @throws XMLSecurityException
- */
- public ElementProxy(Element element, String BaseURI)
- throws XMLSecurityException {
- if (element == null) {
- throw new XMLSecurityException("ElementProxy.nullElement");
- }
-
- if (log.isDebugEnabled()) {
- log.debug("setElement(\"" + element.getTagName() + "\", \"" + BaseURI
- + "\")");
- }
-
- this._doc = element.getOwnerDocument();
- this._constructionElement = element;
- this._baseURI = BaseURI;
-
- this.guaranteeThatElementInCorrectSpace();
- }
-
- /**
- * Returns the Element which was constructed by the Object.
- *
- * @return the Element which was constructed by the Object.
- */
- public final Element getElement() {
- return this._constructionElement;
- }
-
- /**
- * Returns the Element plus a leading and a trailing CarriageReturn Text node.
- *
- * @return the Element which was constructed by the Object.
- */
- public final NodeList getElementPlusReturns() {
-
- HelperNodeList nl = new HelperNodeList();
-
- nl.appendChild(this._doc.createTextNode("\n"));
- nl.appendChild(this.getElement());
- nl.appendChild(this._doc.createTextNode("\n"));
-
- return nl;
- }
-
- /**
- * Method getDocument
- *
- * @return the Document where this element is contained.
- */
- public Document getDocument() {
- return this._doc;
- }
-
- /**
- * Method getBaseURI
- *
- * @return the base uri of the namespace of this element
- */
- public String getBaseURI() {
- return this._baseURI;
- }
-
- /**
- * Method guaranteeThatElementInCorrectSpace
- *
- * @throws XMLSecurityException
- */
- void guaranteeThatElementInCorrectSpace()
- throws XMLSecurityException {
-
- String expectedLocalName = this.getBaseLocalName();
- String expectedNamespaceUri = this.getBaseNamespace();
-
- String actualLocalName = this._constructionElement.getLocalName();
- String actualNamespaceUri = this._constructionElement.getNamespaceURI();
-
- if(!expectedNamespaceUri.equals(actualNamespaceUri) && !expectedLocalName.equals(actualLocalName)) {
- Object exArgs[] = { actualNamespaceUri +":"+ actualLocalName,
- expectedNamespaceUri +":"+ expectedLocalName};
- throw new XMLSecurityException("xml.WrongElement", exArgs);
- }
-
- }
-
- /**
- * Method setVal
- *
- * @param bi
- * @param localname
- */
- public void addBigIntegerElement(BigInteger bi, String localname) {
-
- if (bi != null) {
- Element e = XMLUtils.createElementInSignatureSpace(this._doc,
- localname);
-
- Base64.fillElementWithBigInteger(e, bi);
- this._constructionElement.appendChild(e);
- XMLUtils.addReturnToElement(this._constructionElement);
- }
- }
-
- /**
- * Method addBase64Element
- *
- * @param bytes
- * @param localname
- */
- public void addBase64Element(byte[] bytes, String localname) {
-
- if (bytes != null) {
-
- Element e = Base64.encodeToElement(this._doc, localname, bytes);
-
- this._constructionElement.appendChild(e);
- if (!XMLUtils.ignoreLineBreaks()) {
- this._constructionElement.appendChild(this._doc.createTextNode("\n"));
- }
- }
- }
-
- /**
- * Method addTextElement
- *
- * @param text
- * @param localname
- */
- public void addTextElement(String text, String localname) {
-
- Element e = XMLUtils.createElementInSignatureSpace(this._doc, localname);
- Text t = this._doc.createTextNode(text);
-
- e.appendChild(t);
- this._constructionElement.appendChild(e);
- XMLUtils.addReturnToElement(this._constructionElement);
- }
-
- /**
- * Method addBase64Text
- *
- * @param bytes
- */
- public void addBase64Text(byte[] bytes) {
-
- if (bytes != null) {
- Text t = XMLUtils.ignoreLineBreaks()
- ? this._doc.createTextNode(Base64.encode(bytes))
- : this._doc.createTextNode("\n" + Base64.encode(bytes) + "\n");
- this._constructionElement.appendChild(t);
- }
- }
-
- /**
- * Method addText
- *
- * @param text
- */
- public void addText(String text) {
-
- if (text != null) {
- Text t = this._doc.createTextNode(text);
-
- this._constructionElement.appendChild(t);
- }
- }
-
- /**
- * Method getVal
- *
- * @param localname
- * @param namespace
- * @return The biginter contained in the given element
- * @throws Base64DecodingException
- */
- public BigInteger getBigIntegerFromChildElement(
- String localname, String namespace) throws Base64DecodingException {
-
- return Base64.decodeBigIntegerFromText(
- XMLUtils.selectNodeText(this._constructionElement.getFirstChild(),
- namespace,localname,0));
-
- }
-
- /**
- * Method getBytesFromChildElement
- * @deprecated
- * @param localname
- * @param namespace
- * @return the bytes
- * @throws XMLSecurityException
- */
- public byte[] getBytesFromChildElement(String localname, String namespace)
- throws XMLSecurityException {
-
- Element e =
- XMLUtils.selectNode(
- this._constructionElement.getFirstChild(),
- namespace,
- localname,
- 0);
-
- return Base64.decode(e);
- }
-
- /**
- * Method getTextFromChildElement
- *
- * @param localname
- * @param namespace
- * @return the Text of the textNode
- */
- public String getTextFromChildElement(String localname, String namespace) {
-
- Text t =
- (Text) XMLUtils.selectNode(
- this._constructionElement.getFirstChild(),
- namespace,
- localname,
- 0).getFirstChild();
-
- return t.getData();
- }
-
- /**
- * Method getBytesFromTextChild
- *
- * @return The base64 bytes from the text children of this element
- * @throws XMLSecurityException
- */
- public byte[] getBytesFromTextChild() throws XMLSecurityException {
- return Base64.decode
- (XMLUtils.getFullTextChildrenFromElement(this._constructionElement));
- }
-
- /**
- * Method getTextFromTextChild
- *
- * @return the Text obtained by concatenating all the text nodes of this
- * element
- */
- public String getTextFromTextChild() {
- return XMLUtils.getFullTextChildrenFromElement(this._constructionElement);
- }
-
- /**
- * Method length
- *
- * @param namespace
- * @param localname
- * @return the number of elements {namespace}:localname under this element
- */
- public int length(String namespace, String localname) {
- int number=0;
- Node sibling=this._constructionElement.getFirstChild();
- while (sibling!=null) {
- if (localname.equals(sibling.getLocalName())
- &&
- namespace.equals(sibling.getNamespaceURI())) {
- number++;
- }
- sibling=sibling.getNextSibling();
+ /** Field baseURI */
+ protected String baseURI = null;
+
+ /** Field doc */
+ protected Document doc = null;
+
+ /** Field prefixMappings */
+ static Map<String, String> prefixMappings = new HashMap<String, String>();
+ static Map<String, String> prefixMappingsBindings = new HashMap<String, String>();
+
+ /**
+ * Constructor ElementProxy
+ *
+ */
+ public ElementProxy() {
+ }
+
+ /**
+ * Constructor ElementProxy
+ *
+ * @param doc
+ */
+ public ElementProxy(Document doc) {
+ if (doc == null) {
+ throw new RuntimeException("Document is null");
+ }
+
+ this.doc = doc;
+ this.constructionElement =
+ createElementForFamilyLocal(this.doc, this.getBaseNamespace(), this.getBaseLocalName());
+ }
+
+ /**
+ * Constructor ElementProxy
+ *
+ * @param element
+ * @param BaseURI
+ * @throws XMLSecurityException
+ */
+ public ElementProxy(Element element, String BaseURI) throws XMLSecurityException {
+ if (element == null) {
+ throw new XMLSecurityException("ElementProxy.nullElement");
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("setElement(\"" + element.getTagName() + "\", \"" + BaseURI + "\")");
+ }
+
+ this.doc = element.getOwnerDocument();
+ this.constructionElement = element;
+ this.baseURI = BaseURI;
+
+ this.guaranteeThatElementInCorrectSpace();
+ }
+
+ /**
+ * Returns the namespace of the Elements of the sub-class.
+ *
+ * @return the namespace of the Elements of the sub-class.
+ */
+ public abstract String getBaseNamespace();
+
+ /**
+ * Returns the localname of the Elements of the sub-class.
+ *
+ * @return the localname of the Elements of the sub-class.
+ */
+ public abstract String getBaseLocalName();
+
+
+ protected Element createElementForFamilyLocal(
+ Document doc, String namespace, String localName
+ ) {
+ Element result = null;
+ if (namespace == null) {
+ result = doc.createElementNS(null, localName);
+ } else {
+ String baseName = this.getBaseNamespace();
+ String prefix = ElementProxy.getDefaultPrefix(baseName);
+ if ((prefix == null) || (prefix.length() == 0)) {
+ result = doc.createElementNS(namespace, localName);
+
+ result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns", namespace);
+ } else {
+ String tagName = null;
+ String defaultPrefixNaming = ElementProxy.getDefaultPrefixBindings(baseName);
+ StringBuilder sb = new StringBuilder(prefix);
+ sb.append(':');
+ sb.append(localName);
+ tagName = sb.toString();
+ result = doc.createElementNS(namespace, tagName);
+
+ result.setAttributeNS(Constants.NamespaceSpecNS, defaultPrefixNaming, namespace);
+ }
+ }
+ return result;
+ }
+
+
+ /**
+ * This method creates an Element in a given namespace with a given localname.
+ * It uses the {@link ElementProxy#getDefaultPrefix} method to decide whether
+ * a particular prefix is bound to that namespace.
+ * <BR />
+ * This method was refactored out of the constructor.
+ *
+ * @param doc
+ * @param namespace
+ * @param localName
+ * @return The element created.
+ */
+ public static Element createElementForFamily(Document doc, String namespace, String localName) {
+ Element result = null;
+ String prefix = ElementProxy.getDefaultPrefix(namespace);
+
+ if (namespace == null) {
+ result = doc.createElementNS(null, localName);
+ } else {
+ if ((prefix == null) || (prefix.length() == 0)) {
+ result = doc.createElementNS(namespace, localName);
+ result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns", namespace);
+ } else {
+ result = doc.createElementNS(namespace, prefix + ":" + localName);
+
+ result.setAttributeNS(
+ Constants.NamespaceSpecNS,
+ ElementProxy.getDefaultPrefixBindings(namespace),
+ namespace
+ );
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Method setElement
+ *
+ * @param element
+ * @param BaseURI
+ * @throws XMLSecurityException
+ */
+ public void setElement(Element element, String BaseURI) throws XMLSecurityException {
+ if (element == null) {
+ throw new XMLSecurityException("ElementProxy.nullElement");
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("setElement(" + element.getTagName() + ", \"" + BaseURI + "\"");
+ }
+
+ this.doc = element.getOwnerDocument();
+ this.constructionElement = element;
+ this.baseURI = BaseURI;
+ }
+
+
+ /**
+ * Returns the Element which was constructed by the Object.
+ *
+ * @return the Element which was constructed by the Object.
+ */
+ public final Element getElement() {
+ return this.constructionElement;
+ }
+
+ /**
+ * Returns the Element plus a leading and a trailing CarriageReturn Text node.
+ *
+ * @return the Element which was constructed by the Object.
+ */
+ public final NodeList getElementPlusReturns() {
+
+ HelperNodeList nl = new HelperNodeList();
+
+ nl.appendChild(this.doc.createTextNode("\n"));
+ nl.appendChild(this.getElement());
+ nl.appendChild(this.doc.createTextNode("\n"));
+
+ return nl;
+ }
+
+ /**
+ * Method getDocument
+ *
+ * @return the Document where this element is contained.
+ */
+ public Document getDocument() {
+ return this.doc;
+ }
+
+ /**
+ * Method getBaseURI
+ *
+ * @return the base uri of the namespace of this element
+ */
+ public String getBaseURI() {
+ return this.baseURI;
+ }
+
+ /**
+ * Method guaranteeThatElementInCorrectSpace
+ *
+ * @throws XMLSecurityException
+ */
+ void guaranteeThatElementInCorrectSpace() throws XMLSecurityException {
+
+ String expectedLocalName = this.getBaseLocalName();
+ String expectedNamespaceUri = this.getBaseNamespace();
+
+ String actualLocalName = this.constructionElement.getLocalName();
+ String actualNamespaceUri = this.constructionElement.getNamespaceURI();
+
+ if(!expectedNamespaceUri.equals(actualNamespaceUri)
+ && !expectedLocalName.equals(actualLocalName)) {
+ Object exArgs[] = { actualNamespaceUri + ":" + actualLocalName,
+ expectedNamespaceUri + ":" + expectedLocalName};
+ throw new XMLSecurityException("xml.WrongElement", exArgs);
+ }
+ }
+
+ /**
+ * Method addBigIntegerElement
+ *
+ * @param bi
+ * @param localname
+ */
+ public void addBigIntegerElement(BigInteger bi, String localname) {
+ if (bi != null) {
+ Element e = XMLUtils.createElementInSignatureSpace(this.doc, localname);
+
+ Base64.fillElementWithBigInteger(e, bi);
+ this.constructionElement.appendChild(e);
+ XMLUtils.addReturnToElement(this.constructionElement);
+ }
+ }
+
+ /**
+ * Method addBase64Element
+ *
+ * @param bytes
+ * @param localname
+ */
+ public void addBase64Element(byte[] bytes, String localname) {
+ if (bytes != null) {
+ Element e = Base64.encodeToElement(this.doc, localname, bytes);
+
+ this.constructionElement.appendChild(e);
+ if (!XMLUtils.ignoreLineBreaks()) {
+ this.constructionElement.appendChild(this.doc.createTextNode("\n"));
+ }
+ }
+ }
+
+ /**
+ * Method addTextElement
+ *
+ * @param text
+ * @param localname
+ */
+ public void addTextElement(String text, String localname) {
+ Element e = XMLUtils.createElementInSignatureSpace(this.doc, localname);
+ Text t = this.doc.createTextNode(text);
+
+ e.appendChild(t);
+ this.constructionElement.appendChild(e);
+ XMLUtils.addReturnToElement(this.constructionElement);
+ }
+
+ /**
+ * Method addBase64Text
+ *
+ * @param bytes
+ */
+ public void addBase64Text(byte[] bytes) {
+ if (bytes != null) {
+ Text t = XMLUtils.ignoreLineBreaks()
+ ? this.doc.createTextNode(Base64.encode(bytes))
+ : this.doc.createTextNode("\n" + Base64.encode(bytes) + "\n");
+ this.constructionElement.appendChild(t);
+ }
+ }
+
+ /**
+ * Method addText
+ *
+ * @param text
+ */
+ public void addText(String text) {
+ if (text != null) {
+ Text t = this.doc.createTextNode(text);
+
+ this.constructionElement.appendChild(t);
+ }
+ }
+
+ /**
+ * Method getVal
+ *
+ * @param localname
+ * @param namespace
+ * @return The biginteger contained in the given element
+ * @throws Base64DecodingException
+ */
+ public BigInteger getBigIntegerFromChildElement(
+ String localname, String namespace
+ ) throws Base64DecodingException {
+ return Base64.decodeBigIntegerFromText(
+ XMLUtils.selectNodeText(
+ this.constructionElement.getFirstChild(), namespace, localname, 0
+ )
+ );
+ }
+
+ /**
+ * Method getBytesFromChildElement
+ * @deprecated
+ * @param localname
+ * @param namespace
+ * @return the bytes
+ * @throws XMLSecurityException
+ */
+ public byte[] getBytesFromChildElement(String localname, String namespace)
+ throws XMLSecurityException {
+ Element e =
+ XMLUtils.selectNode(
+ this.constructionElement.getFirstChild(), namespace, localname, 0
+ );
+
+ return Base64.decode(e);
+ }
+
+ /**
+ * Method getTextFromChildElement
+ *
+ * @param localname
+ * @param namespace
+ * @return the Text of the textNode
+ */
+ public String getTextFromChildElement(String localname, String namespace) {
+ Text t =
+ (Text) XMLUtils.selectNode(
+ this.constructionElement.getFirstChild(),
+ namespace,
+ localname,
+ 0
+ ).getFirstChild();
+
+ return t.getData();
+ }
+
+ /**
+ * Method getBytesFromTextChild
+ *
+ * @return The base64 bytes from the text children of this element
+ * @throws XMLSecurityException
+ */
+ public byte[] getBytesFromTextChild() throws XMLSecurityException {
+ return Base64.decode(XMLUtils.getFullTextChildrenFromElement(this.constructionElement));
+ }
+
+ /**
+ * Method getTextFromTextChild
+ *
+ * @return the Text obtained by concatenating all the text nodes of this
+ * element
+ */
+ public String getTextFromTextChild() {
+ return XMLUtils.getFullTextChildrenFromElement(this.constructionElement);
+ }
+
+ /**
+ * Method length
+ *
+ * @param namespace
+ * @param localname
+ * @return the number of elements {namespace}:localname under this element
+ */
+ public int length(String namespace, String localname) {
+ int number = 0;
+ Node sibling = this.constructionElement.getFirstChild();
+ while (sibling != null) {
+ if (localname.equals(sibling.getLocalName())
+ && namespace.equals(sibling.getNamespaceURI())) {
+ number++;
}
- return number;
- }
+ sibling = sibling.getNextSibling();
+ }
+ return number;
+ }
+
+ /**
+ * Adds an xmlns: definition to the Element. This can be called as follows:
+ *
+ * <PRE>
+ * // set namespace with ds prefix
+ * xpathContainer.setXPathNamespaceContext("ds", "http://www.w3.org/2000/09/xmldsig#");
+ * xpathContainer.setXPathNamespaceContext("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#");
+ * </PRE>
+ *
+ * @param prefix
+ * @param uri
+ * @throws XMLSecurityException
+ */
+ public void setXPathNamespaceContext(String prefix, String uri)
+ throws XMLSecurityException {
+ String ns;
+
+ if ((prefix == null) || (prefix.length() == 0)) {
+ throw new XMLSecurityException("defaultNamespaceCannotBeSetHere");
+ } else if (prefix.equals("xmlns")) {
+ throw new XMLSecurityException("defaultNamespaceCannotBeSetHere");
+ } else if (prefix.startsWith("xmlns:")) {
+ ns = prefix;//"xmlns:" + prefix.substring("xmlns:".length());
+ } else {
+ ns = "xmlns:" + prefix;
+ }
+
+ Attr a = this.constructionElement.getAttributeNodeNS(Constants.NamespaceSpecNS, ns);
+
+ if (a != null) {
+ if (!a.getNodeValue().equals(uri)) {
+ Object exArgs[] = { ns, this.constructionElement.getAttributeNS(null, ns) };
+
+ throw new XMLSecurityException("namespacePrefixAlreadyUsedByOtherURI", exArgs);
+ }
+ return;
+ }
- /**
- * Adds an xmlns: definition to the Element. This can be called as follows:
- *
- * <PRE>
- * // set namespace with ds prefix
- * xpathContainer.setXPathNamespaceContext("ds", "http://www.w3.org/2000/09/xmldsig#");
- * xpathContainer.setXPathNamespaceContext("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#");
- * </PRE>
- *
- * @param prefix
- * @param uri
- * @throws XMLSecurityException
- */
- public void setXPathNamespaceContext(String prefix, String uri)
- throws XMLSecurityException {
-
- String ns;
-
- if ((prefix == null) || (prefix.length() == 0)) {
- throw new XMLSecurityException("defaultNamespaceCannotBeSetHere");
- } else if (prefix.equals("xmlns")) {
- throw new XMLSecurityException("defaultNamespaceCannotBeSetHere");
- } else if (prefix.startsWith("xmlns:")) {
- ns = prefix;//"xmlns:" + prefix.substring("xmlns:".length());
- } else {
- ns = "xmlns:" + prefix;
- }
-
-
-
- Attr a = this._constructionElement.getAttributeNodeNS(Constants.NamespaceSpecNS, ns);
-
- if (a != null) {
- if (!a.getNodeValue().equals(uri)) {
- Object exArgs[] = { ns,
- this._constructionElement.getAttributeNS(null,
- ns) };
-
- throw new XMLSecurityException("namespacePrefixAlreadyUsedByOtherURI",
- exArgs);
- }
- return;
- }
-
- this._constructionElement.setAttributeNS(Constants.NamespaceSpecNS, ns,
- uri);
- }
-
- /** Field _prefixMappings */
- static HashMap _prefixMappings = new HashMap();
- static HashMap _prefixMappingsBindings = new HashMap();
+ this.constructionElement.setAttributeNS(Constants.NamespaceSpecNS, ns, uri);
+ }
/**
* Method setDefaultPrefix
@@ -509,29 +485,29 @@ public abstract class ElementProxy {
*/
public static void setDefaultPrefix(String namespace, String prefix)
throws XMLSecurityException {
-
- if (ElementProxy._prefixMappings.containsValue(prefix)) {
-
- Object storedNamespace=ElementProxy._prefixMappings.get(namespace);
- if (!storedNamespace.equals(prefix)) {
- Object exArgs[] = { prefix, namespace, storedNamespace };
+ if (ElementProxy.prefixMappings.containsValue(prefix)) {
+ String storedPrefix = ElementProxy.prefixMappings.get(namespace);
+ if (!storedPrefix.equals(prefix)) {
+ Object exArgs[] = { prefix, namespace, storedPrefix };
throw new XMLSecurityException("prefix.AlreadyAssigned", exArgs);
}
}
+
if (Constants.SignatureSpecNS.equals(namespace)) {
- XMLUtils.dsPrefix=prefix;
+ XMLUtils.dsPrefix = prefix;
}
if (EncryptionConstants.EncryptionSpecNS.equals(namespace)) {
- XMLUtils.xencPrefix=prefix;
+ XMLUtils.xencPrefix = prefix;
}
- ElementProxy._prefixMappings.put(namespace, prefix.intern());
+ ElementProxy.prefixMappings.put(namespace, prefix.intern());
+
if (prefix.length() == 0) {
- ElementProxy._prefixMappingsBindings.put(namespace, "xmlns");
+ ElementProxy.prefixMappingsBindings.put(namespace, "xmlns");
} else {
- ElementProxy._prefixMappingsBindings.put(namespace, ("xmlns:"+prefix).intern());
+ ElementProxy.prefixMappingsBindings.put(namespace, ("xmlns:" + prefix).intern());
}
- }
+ }
/**
* Method getDefaultPrefix
@@ -540,10 +516,10 @@ public abstract class ElementProxy {
* @return the default prefix bind to this element.
*/
public static String getDefaultPrefix(String namespace) {
- return (String) ElementProxy._prefixMappings.get(namespace);
+ return ElementProxy.prefixMappings.get(namespace);
}
public static String getDefaultPrefixBindings(String namespace) {
- return (String) ElementProxy._prefixMappingsBindings.get(namespace);
+ return ElementProxy.prefixMappingsBindings.get(namespace);
}
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/EncryptionConstants.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/EncryptionConstants.java?rev=1066412&r1=1066411&r2=1066412&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/EncryptionConstants.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/EncryptionConstants.java Wed Feb 2 11:09:58 2011
@@ -16,161 +16,197 @@
*/
package org.apache.xml.security.utils;
-
-
import org.apache.xml.security.exceptions.XMLSecurityException;
-
/**
*
* @author $Author$
*/
public class EncryptionConstants {
- //J-
- // Attributes that exist in XML Signature in the same way
+ // Attributes that exist in XML Signature in the same way
/** Tag of Attr Algorithm **/
- public static final String _ATT_ALGORITHM = Constants._ATT_ALGORITHM;
- /** Tag of Attr Id**/
- public static final String _ATT_ID = Constants._ATT_ID;
- /** Tag of Attr Target **/
- public static final String _ATT_TARGET = Constants._ATT_TARGET;
- /** Tag of Attr Type **/
- public static final String _ATT_TYPE = Constants._ATT_TYPE;
- /** Tag of Attr URI **/
- public static final String _ATT_URI = Constants._ATT_URI;
-
- // Attributes new in XML Encryption
- /** Tag of Attr encoding **/
- public static final String _ATT_ENCODING = "Encoding";
- /** Tag of Attr recipient **/
- public static final String _ATT_RECIPIENT = "Recipient";
- /** Tag of Attr mimetype **/
- public static final String _ATT_MIMETYPE = "MimeType";
-
- /** Tag of Element CarriedKeyName **/
- public static final String _TAG_CARRIEDKEYNAME = "CarriedKeyName";
- /** Tag of Element CipherData **/
- public static final String _TAG_CIPHERDATA = "CipherData";
- /** Tag of Element CipherReference **/
- public static final String _TAG_CIPHERREFERENCE = "CipherReference";
- /** Tag of Element CipherValue **/
- public static final String _TAG_CIPHERVALUE = "CipherValue";
- /** Tag of Element DataReference **/
- public static final String _TAG_DATAREFERENCE = "DataReference";
- /** Tag of Element EncryptedData **/
- public static final String _TAG_ENCRYPTEDDATA = "EncryptedData";
- /** Tag of Element EncryptedKey **/
- public static final String _TAG_ENCRYPTEDKEY = "EncryptedKey";
- /** Tag of Element EncryptionMethod **/
- public static final String _TAG_ENCRYPTIONMETHOD = "EncryptionMethod";
- /** Tag of Element EncryptionProperties **/
- public static final String _TAG_ENCRYPTIONPROPERTIES = "EncryptionProperties";
- /** Tag of Element EncryptionProperty **/
- public static final String _TAG_ENCRYPTIONPROPERTY = "EncryptionProperty";
- /** Tag of Element KeyReference **/
- public static final String _TAG_KEYREFERENCE = "KeyReference";
- /** Tag of Element KeySize **/
- public static final String _TAG_KEYSIZE = "KeySize";
- /** Tag of Element OAEPparams **/
- public static final String _TAG_OAEPPARAMS = "OAEPparams";
- /** Tag of Element ReferenceList **/
- public static final String _TAG_REFERENCELIST = "ReferenceList";
- /** Tag of Element Transforms **/
- public static final String _TAG_TRANSFORMS = "Transforms";
- /** Tag of Element AgreementMethod **/
- public static final String _TAG_AGREEMENTMETHOD = "AgreementMethod";
- /** Tag of Element KA-Nonce **/
- public static final String _TAG_KA_NONCE = "KA-Nonce";
- /** Tag of Element OriginatorKeyInfo **/
- public static final String _TAG_ORIGINATORKEYINFO = "OriginatorKeyInfo";
- /** Tag of Element RecipientKeyInfo **/
- public static final String _TAG_RECIPIENTKEYINFO = "RecipientKeyInfo";
-
- /** Field ENCRYPTIONSPECIFICATION_URL */
- public static final String ENCRYPTIONSPECIFICATION_URL = "http://www.w3.org/TR/2001/WD-xmlenc-core-20010626/";
-
- /** The namespace of the <A HREF="http://www.w3.org/TR/2001/WD-xmlenc-core-20010626/">XML Encryption Syntax and Processing</A> */
- public static final String EncryptionSpecNS = "http://www.w3.org/2001/04/xmlenc#";
-
- /** URI for content*/
- public static final String TYPE_CONTENT = EncryptionSpecNS + "Content";
- /** URI for element*/
- public static final String TYPE_ELEMENT = EncryptionSpecNS + "Element";
- /** URI for mediatype*/
- public static final String TYPE_MEDIATYPE = "http://www.isi.edu/in-notes/iana/assignments/media-types/"; // + "*/*";
-
- /** Block Encryption - REQUIRED TRIPLEDES */
- public static final String ALGO_ID_BLOCKCIPHER_TRIPLEDES = EncryptionConstants.EncryptionSpecNS + "tripledes-cbc";
- /** Block Encryption - REQUIRED AES-128 */
- public static final String ALGO_ID_BLOCKCIPHER_AES128 = EncryptionConstants.EncryptionSpecNS + "aes128-cbc";
- /** Block Encryption - REQUIRED AES-256 */
- public static final String ALGO_ID_BLOCKCIPHER_AES256 = EncryptionConstants.EncryptionSpecNS + "aes256-cbc";
- /** Block Encryption - OPTIONAL AES-192 */
- public static final String ALGO_ID_BLOCKCIPHER_AES192 = EncryptionConstants.EncryptionSpecNS + "aes192-cbc";
-
- /** Key Transport - REQUIRED RSA-v1.5*/
- public static final String ALGO_ID_KEYTRANSPORT_RSA15 = EncryptionConstants.EncryptionSpecNS + "rsa-1_5";
- /** Key Transport - REQUIRED RSA-OAEP */
- public static final String ALGO_ID_KEYTRANSPORT_RSAOAEP = EncryptionConstants.EncryptionSpecNS + "rsa-oaep-mgf1p";
-
- /** Key Agreement - OPTIONAL Diffie-Hellman */
- public static final String ALGO_ID_KEYAGREEMENT_DH = EncryptionConstants.EncryptionSpecNS + "dh";
-
- /** Symmetric Key Wrap - REQUIRED TRIPLEDES KeyWrap */
- public static final String ALGO_ID_KEYWRAP_TRIPLEDES = EncryptionConstants.EncryptionSpecNS + "kw-tripledes";
- /** Symmetric Key Wrap - REQUIRED AES-128 KeyWrap */
- public static final String ALGO_ID_KEYWRAP_AES128 = EncryptionConstants.EncryptionSpecNS + "kw-aes128";
- /** Symmetric Key Wrap - REQUIRED AES-256 KeyWrap */
- public static final String ALGO_ID_KEYWRAP_AES256 = EncryptionConstants.EncryptionSpecNS + "kw-aes256";
- /** Symmetric Key Wrap - OPTIONAL AES-192 KeyWrap */
- public static final String ALGO_ID_KEYWRAP_AES192 = EncryptionConstants.EncryptionSpecNS + "kw-aes192";
-
- /*
- // Message Digest - REQUIRED SHA1
- public static final String ALGO_ID_DIGEST_SHA160 = Constants.ALGO_ID_DIGEST_SHA1;
- // Message Digest - RECOMMENDED SHA256
- public static final String ALGO_ID_DIGEST_SHA256 = EncryptionConstants.EncryptionSpecNS + "sha256";
- // Message Digest - OPTIONAL SHA512
- public static final String ALGO_ID_DIGEST_SHA512 = EncryptionConstants.EncryptionSpecNS + "sha512";
- // Message Digest - OPTIONAL RIPEMD-160
- public static final String ALGO_ID_DIGEST_RIPEMD160 = EncryptionConstants.EncryptionSpecNS + "ripemd160";
- */
-
- /** Message Authentication - RECOMMENDED XML Digital Signature */
- public static final String ALGO_ID_AUTHENTICATION_XMLSIGNATURE = "http://www.w3.org/TR/2001/CR-xmldsig-core-20010419/";
-
- /** Canonicalization - OPTIONAL Canonical XML with Comments */
- public static final String ALGO_ID_C14N_WITHCOMMENTS = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments";
- /** Canonicalization - OPTIONAL Canonical XML (omits comments) */
- public static final String ALGO_ID_C14N_OMITCOMMENTS = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
-
- /** Encoding - REQUIRED base64 */
- public static final String ALGO_ID_ENCODING_BASE64 = "http://www.w3.org/2000/09/xmldsig#base64";
- //J+
-
- private EncryptionConstants() {
- // we don't allow instantiation
- }
-
- /**
- * Method setEncryptionSpecNSprefix
- *
- * @param newPrefix
- * @throws XMLSecurityException
- */
- public static void setEncryptionSpecNSprefix(String newPrefix)
- throws XMLSecurityException {
- ElementProxy.setDefaultPrefix(EncryptionConstants.EncryptionSpecNS,
- newPrefix);
- }
-
- /**
- * Method getEncryptionSpecNSprefix
- *
- * @return the prefix for this node.
- */
- public static String getEncryptionSpecNSprefix() {
- return ElementProxy
- .getDefaultPrefix(EncryptionConstants.EncryptionSpecNS);
- }
+ public static final String _ATT_ALGORITHM = Constants._ATT_ALGORITHM;
+
+ /** Tag of Attr Id**/
+ public static final String _ATT_ID = Constants._ATT_ID;
+
+ /** Tag of Attr Target **/
+ public static final String _ATT_TARGET = Constants._ATT_TARGET;
+
+ /** Tag of Attr Type **/
+ public static final String _ATT_TYPE = Constants._ATT_TYPE;
+
+ /** Tag of Attr URI **/
+ public static final String _ATT_URI = Constants._ATT_URI;
+
+ // Attributes new in XML Encryption
+ /** Tag of Attr encoding **/
+ public static final String _ATT_ENCODING = "Encoding";
+
+ /** Tag of Attr recipient **/
+ public static final String _ATT_RECIPIENT = "Recipient";
+
+ /** Tag of Attr mimetype **/
+ public static final String _ATT_MIMETYPE = "MimeType";
+
+ /** Tag of Element CarriedKeyName **/
+ public static final String _TAG_CARRIEDKEYNAME = "CarriedKeyName";
+
+ /** Tag of Element CipherData **/
+ public static final String _TAG_CIPHERDATA = "CipherData";
+
+ /** Tag of Element CipherReference **/
+ public static final String _TAG_CIPHERREFERENCE = "CipherReference";
+
+ /** Tag of Element CipherValue **/
+ public static final String _TAG_CIPHERVALUE = "CipherValue";
+
+ /** Tag of Element DataReference **/
+ public static final String _TAG_DATAREFERENCE = "DataReference";
+
+ /** Tag of Element EncryptedData **/
+ public static final String _TAG_ENCRYPTEDDATA = "EncryptedData";
+
+ /** Tag of Element EncryptedKey **/
+ public static final String _TAG_ENCRYPTEDKEY = "EncryptedKey";
+
+ /** Tag of Element EncryptionMethod **/
+ public static final String _TAG_ENCRYPTIONMETHOD = "EncryptionMethod";
+
+ /** Tag of Element EncryptionProperties **/
+ public static final String _TAG_ENCRYPTIONPROPERTIES = "EncryptionProperties";
+
+ /** Tag of Element EncryptionProperty **/
+ public static final String _TAG_ENCRYPTIONPROPERTY = "EncryptionProperty";
+
+ /** Tag of Element KeyReference **/
+ public static final String _TAG_KEYREFERENCE = "KeyReference";
+
+ /** Tag of Element KeySize **/
+ public static final String _TAG_KEYSIZE = "KeySize";
+
+ /** Tag of Element OAEPparams **/
+ public static final String _TAG_OAEPPARAMS = "OAEPparams";
+
+ /** Tag of Element ReferenceList **/
+ public static final String _TAG_REFERENCELIST = "ReferenceList";
+
+ /** Tag of Element Transforms **/
+ public static final String _TAG_TRANSFORMS = "Transforms";
+
+ /** Tag of Element AgreementMethod **/
+ public static final String _TAG_AGREEMENTMETHOD = "AgreementMethod";
+
+ /** Tag of Element KA-Nonce **/
+ public static final String _TAG_KA_NONCE = "KA-Nonce";
+
+ /** Tag of Element OriginatorKeyInfo **/
+ public static final String _TAG_ORIGINATORKEYINFO = "OriginatorKeyInfo";
+
+ /** Tag of Element RecipientKeyInfo **/
+ public static final String _TAG_RECIPIENTKEYINFO = "RecipientKeyInfo";
+
+ /** Field ENCRYPTIONSPECIFICATION_URL */
+ public static final String ENCRYPTIONSPECIFICATION_URL =
+ "http://www.w3.org/TR/2001/WD-xmlenc-core-20010626/";
+
+ /** The namespace of the
+ * <A HREF="http://www.w3.org/TR/2001/WD-xmlenc-core-20010626/">
+ * XML Encryption Syntax and Processing</A> */
+ public static final String EncryptionSpecNS =
+ "http://www.w3.org/2001/04/xmlenc#";
+
+ /** URI for content*/
+ public static final String TYPE_CONTENT = EncryptionSpecNS + "Content";
+
+ /** URI for element*/
+ public static final String TYPE_ELEMENT = EncryptionSpecNS + "Element";
+
+ /** URI for mediatype*/
+ public static final String TYPE_MEDIATYPE =
+ "http://www.isi.edu/in-notes/iana/assignments/media-types/";
+
+ /** Block Encryption - REQUIRED TRIPLEDES */
+ public static final String ALGO_ID_BLOCKCIPHER_TRIPLEDES =
+ EncryptionConstants.EncryptionSpecNS + "tripledes-cbc";
+
+ /** Block Encryption - REQUIRED AES-128 */
+ public static final String ALGO_ID_BLOCKCIPHER_AES128 =
+ EncryptionConstants.EncryptionSpecNS + "aes128-cbc";
+
+ /** Block Encryption - REQUIRED AES-256 */
+ public static final String ALGO_ID_BLOCKCIPHER_AES256 =
+ EncryptionConstants.EncryptionSpecNS + "aes256-cbc";
+
+ /** Block Encryption - OPTIONAL AES-192 */
+ public static final String ALGO_ID_BLOCKCIPHER_AES192 =
+ EncryptionConstants.EncryptionSpecNS + "aes192-cbc";
+
+ /** Key Transport - REQUIRED RSA-v1.5*/
+ public static final String ALGO_ID_KEYTRANSPORT_RSA15 =
+ EncryptionConstants.EncryptionSpecNS + "rsa-1_5";
+
+ /** Key Transport - REQUIRED RSA-OAEP */
+ public static final String ALGO_ID_KEYTRANSPORT_RSAOAEP =
+ EncryptionConstants.EncryptionSpecNS + "rsa-oaep-mgf1p";
+
+ /** Key Agreement - OPTIONAL Diffie-Hellman */
+ public static final String ALGO_ID_KEYAGREEMENT_DH =
+ EncryptionConstants.EncryptionSpecNS + "dh";
+
+ /** Symmetric Key Wrap - REQUIRED TRIPLEDES KeyWrap */
+ public static final String ALGO_ID_KEYWRAP_TRIPLEDES =
+ EncryptionConstants.EncryptionSpecNS + "kw-tripledes";
+
+ /** Symmetric Key Wrap - REQUIRED AES-128 KeyWrap */
+ public static final String ALGO_ID_KEYWRAP_AES128 =
+ EncryptionConstants.EncryptionSpecNS + "kw-aes128";
+
+ /** Symmetric Key Wrap - REQUIRED AES-256 KeyWrap */
+ public static final String ALGO_ID_KEYWRAP_AES256 =
+ EncryptionConstants.EncryptionSpecNS + "kw-aes256";
+
+ /** Symmetric Key Wrap - OPTIONAL AES-192 KeyWrap */
+ public static final String ALGO_ID_KEYWRAP_AES192 =
+ EncryptionConstants.EncryptionSpecNS + "kw-aes192";
+
+ /** Message Authentication - RECOMMENDED XML Digital Signature */
+ public static final String ALGO_ID_AUTHENTICATION_XMLSIGNATURE =
+ "http://www.w3.org/TR/2001/CR-xmldsig-core-20010419/";
+
+ /** Canonicalization - OPTIONAL Canonical XML with Comments */
+ public static final String ALGO_ID_C14N_WITHCOMMENTS =
+ "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments";
+
+ /** Canonicalization - OPTIONAL Canonical XML (omits comments) */
+ public static final String ALGO_ID_C14N_OMITCOMMENTS =
+ "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
+
+ /** Encoding - REQUIRED base64 */
+ public static final String ALGO_ID_ENCODING_BASE64 =
+ "http://www.w3.org/2000/09/xmldsig#base64";
+
+ private EncryptionConstants() {
+ // we don't allow instantiation
+ }
+
+ /**
+ * Method setEncryptionSpecNSprefix
+ *
+ * @param newPrefix
+ * @throws XMLSecurityException
+ */
+ public static void setEncryptionSpecNSprefix(String newPrefix)
+ throws XMLSecurityException {
+ ElementProxy.setDefaultPrefix(EncryptionConstants.EncryptionSpecNS, newPrefix);
+ }
+
+ /**
+ * Method getEncryptionSpecNSprefix
+ *
+ * @return the prefix for this node.
+ */
+ public static String getEncryptionSpecNSprefix() {
+ return ElementProxy.getDefaultPrefix(EncryptionConstants.EncryptionSpecNS);
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/EncryptionElementProxy.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/EncryptionElementProxy.java?rev=1066412&r1=1066411&r2=1066412&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/EncryptionElementProxy.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/EncryptionElementProxy.java Wed Feb 2 11:09:58 2011
@@ -17,12 +17,10 @@
package org.apache.xml.security.utils;
-
import org.apache.xml.security.exceptions.XMLSecurityException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-
/**
* This is the base object for all objects which map directly to an Element from
* the xenc spec.
@@ -31,29 +29,29 @@ import org.w3c.dom.Element;
*/
public abstract class EncryptionElementProxy extends ElementProxy {
- /**
- * Constructor EncryptionElementProxy
- *
- * @param doc
- */
- public EncryptionElementProxy(Document doc) {
- super(doc);
- }
-
- /**
- * Constructor EncryptionElementProxy
- *
- * @param element
- * @param BaseURI
- * @throws XMLSecurityException
- */
- public EncryptionElementProxy(Element element, String BaseURI)
- throws XMLSecurityException {
- super(element, BaseURI);
- }
-
- /** @inheritDoc */
- public final String getBaseNamespace() {
- return EncryptionConstants.EncryptionSpecNS;
- }
+ /**
+ * Constructor EncryptionElementProxy
+ *
+ * @param doc
+ */
+ public EncryptionElementProxy(Document doc) {
+ super(doc);
+ }
+
+ /**
+ * Constructor EncryptionElementProxy
+ *
+ * @param element
+ * @param BaseURI
+ * @throws XMLSecurityException
+ */
+ public EncryptionElementProxy(Element element, String BaseURI)
+ throws XMLSecurityException {
+ super(element, BaseURI);
+ }
+
+ /** @inheritDoc */
+ public final String getBaseNamespace() {
+ return EncryptionConstants.EncryptionSpecNS;
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/HelperNodeList.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/HelperNodeList.java?rev=1066412&r1=1066411&r2=1066412&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/HelperNodeList.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/HelperNodeList.java Wed Feb 2 11:09:58 2011
@@ -18,81 +18,77 @@
package org.apache.xml.security.utils;
import java.util.ArrayList;
+import java.util.List;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
- *
* @author Christian Geuer-Pollmann
- *
*/
public class HelperNodeList implements NodeList {
- /** Field nodes */
- ArrayList nodes = new ArrayList(20);
- boolean _allNodesMustHaveSameParent = false;
-
- /**
- *
- */
- public HelperNodeList() {
- this(false);
- }
-
-
- /**
- * @param allNodesMustHaveSameParent
- */
- public HelperNodeList(boolean allNodesMustHaveSameParent) {
- this._allNodesMustHaveSameParent = allNodesMustHaveSameParent;
- }
-
- /**
- * Method item
- *
- * @param index
- * @return node with inde i
- */
- public Node item(int index) {
-
- // log.debug("item(" + index + ") of " + this.getLength() + " nodes");
-
- return (Node) nodes.get(index);
- }
-
- /**
- * Method getLength
- *
- * @return length of the list
- */
- public int getLength() {
- return nodes.size();
- }
-
- /**
- * Method appendChild
- *
- * @param node
- * @throws IllegalArgumentException
- */
- public void appendChild(Node node) throws IllegalArgumentException {
- if (this._allNodesMustHaveSameParent && this.getLength() > 0) {
- if (this.item(0).getParentNode() != node.getParentNode()) {
- throw new IllegalArgumentException("Nodes have not the same Parent");
- }
- }
- nodes.add(node);
- }
-
- /**
- * @return the document that contains this nodelist
- */
- public Document getOwnerDocument() {
- if (this.getLength() == 0) {
- return null;
- }
- return XMLUtils.getOwnerDocument(this.item(0));
- }
+ /** Field nodes */
+ List<Node> nodes = new ArrayList<Node>(20);
+ boolean allNodesMustHaveSameParent = false;
+
+ /**
+ *
+ */
+ public HelperNodeList() {
+ this(false);
+ }
+
+
+ /**
+ * @param allNodesMustHaveSameParent
+ */
+ public HelperNodeList(boolean allNodesMustHaveSameParent) {
+ this.allNodesMustHaveSameParent = allNodesMustHaveSameParent;
+ }
+
+ /**
+ * Method item
+ *
+ * @param index
+ * @return node with index i
+ */
+ public Node item(int index) {
+ return nodes.get(index);
+ }
+
+ /**
+ * Method getLength
+ *
+ * @return length of the list
+ */
+ public int getLength() {
+ return nodes.size();
+ }
+
+ /**
+ * Method appendChild
+ *
+ * @param node
+ * @throws IllegalArgumentException
+ */
+ public void appendChild(Node node) throws IllegalArgumentException {
+ if (this.allNodesMustHaveSameParent && this.getLength() > 0) {
+ if (this.item(0).getParentNode() != node.getParentNode()) {
+ throw new IllegalArgumentException("Nodes have not the same Parent");
+ }
+ }
+ nodes.add(node);
+ }
+
+ /**
+ * @return the document that contains this nodelist
+ */
+ public Document getOwnerDocument() {
+ if (this.getLength() == 0) {
+ return null;
+ }
+ return XMLUtils.getOwnerDocument(this.item(0));
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/IgnoreAllErrorHandler.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/IgnoreAllErrorHandler.java?rev=1066412&r1=1066411&r2=1066412&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/IgnoreAllErrorHandler.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/IgnoreAllErrorHandler.java Wed Feb 2 11:09:58 2011
@@ -16,64 +16,60 @@
*/
package org.apache.xml.security.utils;
-
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
-
/**
- * This {@link org.xml.sax.ErrorHandler} does absulutely nothing but logging
+ * This {@link org.xml.sax.ErrorHandler} does absolutely nothing but log
* the events.
*
* @author Christian Geuer-Pollmann
*/
public class IgnoreAllErrorHandler implements ErrorHandler {
- /** {@link org.apache.commons.logging} logging facility */
- static org.apache.commons.logging.Log log =
- org.apache.commons.logging.LogFactory.getLog(
- IgnoreAllErrorHandler.class.getName());
-
- /** Field throwExceptions */
- static final boolean warnOnExceptions = System.getProperty(
- "org.apache.xml.security.test.warn.on.exceptions", "false").equals("true");
-
- /** Field throwExceptions */
- static final boolean throwExceptions = System.getProperty(
- "org.apache.xml.security.test.throw.exceptions", "false").equals("true");
-
-
- /** @inheritDoc */
- public void warning(SAXParseException ex) throws SAXException {
- if (IgnoreAllErrorHandler.warnOnExceptions) {
- log.warn("", ex);
- }
- if (IgnoreAllErrorHandler.throwExceptions) {
- throw ex;
- }
+ /** {@link org.apache.commons.logging} logging facility */
+ static org.apache.commons.logging.Log log =
+ org.apache.commons.logging.LogFactory.getLog(IgnoreAllErrorHandler.class.getName());
+
+ /** Field throwExceptions */
+ static final boolean warnOnExceptions =
+ System.getProperty("org.apache.xml.security.test.warn.on.exceptions", "false").equals("true");
+
+ /** Field throwExceptions */
+ static final boolean throwExceptions =
+ System.getProperty("org.apache.xml.security.test.throw.exceptions", "false").equals("true");
+
+
+ /** @inheritDoc */
+ public void warning(SAXParseException ex) throws SAXException {
+ if (IgnoreAllErrorHandler.warnOnExceptions) {
+ log.warn("", ex);
+ }
+ if (IgnoreAllErrorHandler.throwExceptions) {
+ throw ex;
}
+ }
- /** @inheritDoc */
- public void error(SAXParseException ex) throws SAXException {
- if (IgnoreAllErrorHandler.warnOnExceptions) {
- log.error("", ex);
- }
- if (IgnoreAllErrorHandler.throwExceptions) {
- throw ex;
- }
+ /** @inheritDoc */
+ public void error(SAXParseException ex) throws SAXException {
+ if (IgnoreAllErrorHandler.warnOnExceptions) {
+ log.error("", ex);
}
+ if (IgnoreAllErrorHandler.throwExceptions) {
+ throw ex;
+ }
+ }
-
- /** @inheritDoc */
- public void fatalError(SAXParseException ex) throws SAXException {
- if (IgnoreAllErrorHandler.warnOnExceptions) {
- log.warn("", ex);
- }
- if (IgnoreAllErrorHandler.throwExceptions) {
- throw ex;
- }
+ /** @inheritDoc */
+ public void fatalError(SAXParseException ex) throws SAXException {
+ if (IgnoreAllErrorHandler.warnOnExceptions) {
+ log.warn("", ex);
+ }
+ if (IgnoreAllErrorHandler.throwExceptions) {
+ throw ex;
}
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/SignatureElementProxy.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/SignatureElementProxy.java?rev=1066412&r1=1066411&r2=1066412&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/SignatureElementProxy.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/SignatureElementProxy.java Wed Feb 2 11:09:58 2011
@@ -42,8 +42,8 @@ public abstract class SignatureElementPr
throw new RuntimeException("Document is null");
}
- this._doc = doc;
- this._constructionElement = XMLUtils.createElementInSignatureSpace(this._doc,
+ this.doc = doc;
+ this.constructionElement = XMLUtils.createElementInSignatureSpace(this.doc,
this.getBaseLocalName());
}