Index: src/org/apache/xml/security/utils/XMLUtils.java
===================================================================
--- src/org/apache/xml/security/utils/XMLUtils.java (revision 765942)
+++ src/org/apache/xml/security/utils/XMLUtils.java (working copy)
@@ -256,7 +256,36 @@
return doc.createElementNS(Constants.SignatureSpecNS, namePrefix);
}
+ static String xencPrefix=null;
/**
+ * Creates an Element in the XML Encryption specification namespace.
+ *
+ * @param doc the factory Document
+ * @param elementName the local name of the Element
+ * @return the Element
+ */
+ public static Element createElementInEncryptionSpace(Document doc,
+ String elementName) {
+
+ if (doc == null) {
+ throw new RuntimeException("Document is null");
+ }
+
+ if ((xencPrefix == null) || (xencPrefix.length() == 0)) {
+ return doc.createElementNS(EncryptionConstants.EncryptionSpecNS, elementName);
+ }
+ String namePrefix=(String) namePrefixes.get(elementName);
+ if (namePrefix==null) {
+ StringBuffer tag=new StringBuffer(xencPrefix);
+ tag.append(':');
+ tag.append(elementName);
+ namePrefix=tag.toString();
+ namePrefixes.put(elementName,namePrefix);
+ }
+ return doc.createElementNS(EncryptionConstants.EncryptionSpecNS, namePrefix);
+ }
+
+ /**
* Returns true if the element is in XML Signature namespace and the local
* name equals the supplied one.
*
Index: src/org/apache/xml/security/utils/ElementProxy.java
===================================================================
--- src/org/apache/xml/security/utils/ElementProxy.java (revision 765942)
+++ src/org/apache/xml/security/utils/ElementProxy.java (working copy)
@@ -514,6 +514,9 @@
if (Constants.SignatureSpecNS.equals(namespace)) {
XMLUtils.dsPrefix=prefix;
}
+ if (EncryptionConstants.EncryptionSpecNS.equals(namespace)) {
+ XMLUtils.xencPrefix=prefix;
+ }
ElementProxy._prefixMappings.put(namespace, prefix.intern());
if (prefix.length() == 0) {
ElementProxy._prefixMappingsBindings.put(namespace, "xmlns");
Index: src/org/apache/xml/security/encryption/XMLCipher.java
===================================================================
--- src/org/apache/xml/security/encryption/XMLCipher.java (revision 765942)
+++ src/org/apache/xml/security/encryption/XMLCipher.java (working copy)
@@ -1281,7 +1281,7 @@
String jceKeyAlgorithm =
JCEMapper.getJCEKeyAlgorithmFromURI(algorithm);
- System.out.println("keyAlg:"+jceKeyAlgorithm);
+ logger.debug("JCE Key Algorithm: " + jceKeyAlgorithm);
Cipher c;
if (_contextCipher == null) {
@@ -1290,7 +1290,6 @@
String jceAlgorithm =
JCEMapper.translateURItoJCEID(
encryptedKey.getEncryptionMethod().getAlgorithm());
- System.out.println("jcekeyAlg:"+jceAlgorithm);
logger.debug("JCE Algorithm = " + jceAlgorithm);
@@ -1481,7 +1480,7 @@
String jceAlgorithm =
JCEMapper.translateURItoJCEID(encryptedData.getEncryptionMethod().getAlgorithm());
- System.out.println("alg:"+jceAlgorithm);
+ logger.debug("JCE Algorithm = " + jceAlgorithm);
Cipher c;
try {
@@ -2478,7 +2477,6 @@
EncryptionConstants.EncryptionSpecNS,
EncryptionConstants._TAG_OAEPPARAMS).item(0);
if (null != oaepParamsElement) {
- System.out.println("OAEPParams");
result.setOAEPparams(
oaepParamsElement.getNodeValue().getBytes());
}
@@ -2812,17 +2810,16 @@
//
//
Element toElement() {
- Element result = ElementProxy.createElementForFamily(
+ Element result =
+ XMLUtils.createElementInEncryptionSpace(
_contextDocument,
- EncryptionConstants.EncryptionSpecNS,
EncryptionConstants._TAG_AGREEMENTMETHOD);
result.setAttributeNS(
null, EncryptionConstants._ATT_ALGORITHM, algorithmURI);
if (null != kaNonce) {
result.appendChild(
- ElementProxy.createElementForFamily(
+ XMLUtils.createElementInEncryptionSpace(
_contextDocument,
- EncryptionConstants.EncryptionSpecNS,
EncryptionConstants._TAG_KA_NONCE)).appendChild(
_contextDocument.createTextNode(new String(kaNonce)));
}
@@ -2912,10 +2909,8 @@
//
//
Element toElement() {
- Element result = ElementProxy.createElementForFamily(
- _contextDocument,
- EncryptionConstants.EncryptionSpecNS,
- EncryptionConstants._TAG_CIPHERDATA);
+ Element result = XMLUtils.createElementInEncryptionSpace(
+ _contextDocument, EncryptionConstants._TAG_CIPHERDATA);
if (cipherType == VALUE_TYPE) {
result.appendChild(
((CipherValueImpl) cipherValue).toElement());
@@ -2987,10 +2982,8 @@
//
//
Element toElement() {
- Element result = ElementProxy.createElementForFamily(
- _contextDocument,
- EncryptionConstants.EncryptionSpecNS,
- EncryptionConstants._TAG_CIPHERREFERENCE);
+ Element result = XMLUtils.createElementInEncryptionSpace(
+ _contextDocument, EncryptionConstants._TAG_CIPHERREFERENCE);
result.setAttributeNS(
null, EncryptionConstants._ATT_URI, referenceURI);
if (null != referenceTransforms) {
@@ -3033,9 +3026,8 @@
}
Element toElement() {
- Element result = ElementProxy.createElementForFamily(
- _contextDocument, EncryptionConstants.EncryptionSpecNS,
- EncryptionConstants._TAG_CIPHERVALUE);
+ Element result = XMLUtils.createElementInEncryptionSpace(
+ _contextDocument, EncryptionConstants._TAG_CIPHERVALUE);
result.appendChild(_contextDocument.createTextNode(
cipherValue));
@@ -3491,23 +3483,20 @@
//
//
Element toElement() {
- Element result = ElementProxy.createElementForFamily(
- _contextDocument, EncryptionConstants.EncryptionSpecNS,
- EncryptionConstants._TAG_ENCRYPTIONMETHOD);
+ Element result = XMLUtils.createElementInEncryptionSpace(
+ _contextDocument, EncryptionConstants._TAG_ENCRYPTIONMETHOD);
result.setAttributeNS(null, EncryptionConstants._ATT_ALGORITHM,
algorithm);
if (keySize > 0) {
result.appendChild(
- ElementProxy.createElementForFamily(_contextDocument,
- EncryptionConstants.EncryptionSpecNS,
+ XMLUtils.createElementInEncryptionSpace(_contextDocument,
EncryptionConstants._TAG_KEYSIZE).appendChild(
_contextDocument.createTextNode(
String.valueOf(keySize))));
}
if (null != oaepParams) {
result.appendChild(
- ElementProxy.createElementForFamily(_contextDocument,
- EncryptionConstants.EncryptionSpecNS,
+ XMLUtils.createElementInEncryptionSpace(_contextDocument,
EncryptionConstants._TAG_OAEPPARAMS).appendChild(
_contextDocument.createTextNode(
new String(oaepParams))));
@@ -3567,9 +3556,8 @@
//
//
Element toElement() {
- Element result = ElementProxy.createElementForFamily(
- _contextDocument, EncryptionConstants.EncryptionSpecNS,
- EncryptionConstants._TAG_ENCRYPTIONPROPERTIES);
+ Element result = XMLUtils.createElementInEncryptionSpace(
+ _contextDocument, EncryptionConstants._TAG_ENCRYPTIONPROPERTIES);
if (null != id) {
result.setAttributeNS(null, EncryptionConstants._ATT_ID, id);
}
@@ -3669,9 +3657,8 @@
//
//
Element toElement() {
- Element result = ElementProxy.createElementForFamily(
- _contextDocument, EncryptionConstants.EncryptionSpecNS,
- EncryptionConstants._TAG_ENCRYPTIONPROPERTY);
+ Element result = XMLUtils.createElementInEncryptionSpace(
+ _contextDocument, EncryptionConstants._TAG_ENCRYPTIONPROPERTY);
if (null != target) {
result.setAttributeNS(null, EncryptionConstants._ATT_TARGET,
target);