You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2013/08/14 12:05:56 UTC

svn commit: r1513794 - /webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/transform/STRTransformUtil.java

Author: coheigea
Date: Wed Aug 14 10:05:56 2013
New Revision: 1513794

URL: http://svn.apache.org/r1513794
Log:
[WSS-474] - Missing the 'EncodingType' attribute in element built by STRTransformUtil#createBSTX509
 - Thanks to Alessio Soldano.

Modified:
    webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/transform/STRTransformUtil.java

Modified: webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/transform/STRTransformUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/transform/STRTransformUtil.java?rev=1513794&r1=1513793&r2=1513794&view=diff
==============================================================================
--- webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/transform/STRTransformUtil.java (original)
+++ webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/transform/STRTransformUtil.java Wed Aug 14 10:05:56 2013
@@ -81,7 +81,7 @@ public final class STRTransformUtil {
             if (certs == null || certs.length == 0 || certs[0] == null) {
                 throw new WSSecurityException(WSSecurityException.FAILED_CHECK);
             }
-            return createBSTX509(doc, certs[0], secRef.getElement());
+            return createBSTX509(doc, certs[0], secRef.getElement(), secRef.getKeyIdentifierEncodingType());
         }
         //
         // third case: KeyIdentifier. For SKI, lookup in keystore, wrap in
@@ -108,6 +108,12 @@ public final class STRTransformUtil {
     
     public static Element createBSTX509(Document doc, X509Certificate cert, Element secRefE) 
         throws WSSecurityException {
+        return createBSTX509(doc, cert, secRefE, null);
+    }
+    
+    public static Element createBSTX509(Document doc, X509Certificate cert, Element secRefE, 
+                                        String secRefEncType) 
+        throws WSSecurityException {
         byte data[];
         try {
             data = cert.getEncoded();
@@ -124,6 +130,9 @@ public final class STRTransformUtil {
         WSSecurityUtil.setNamespace(elem, WSConstants.WSSE_NS, prefix);
         // elem.setAttributeNS(WSConstants.XMLNS_NS, "xmlns", "");
         elem.setAttributeNS(null, "ValueType", X509Security.X509_V3_TYPE);
+        if (secRefEncType != null) {
+            elem.setAttributeNS(null, "EncodingType", secRefEncType);
+        }
         Text certText = doc.createTextNode(Base64.encode(data)); // no line wrap
         elem.appendChild(certText);
         return elem;