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 2015/12/19 12:11:55 UTC

svn commit: r1720895 [12/34] - in /webservices/wss4j/branches/2_1_x-fixes: bindings/src/main/java/org/apache/wss4j/binding/wss10/ bindings/src/main/java/org/apache/wss4j/binding/wss11/ bindings/src/main/java/org/apache/wss4j/binding/wssc13/ bindings/sr...

Modified: webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java?rev=1720895&r1=1720894&r2=1720895&view=diff
==============================================================================
--- webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java (original)
+++ webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java Sat Dec 19 11:11:50 2015
@@ -45,38 +45,38 @@ import org.w3c.dom.Element;
  * Base class for DerivedKey encryption and signature
  */
 public abstract class WSSecDerivedKeyBase extends WSSecSignatureBase {
-    
-    private static final org.slf4j.Logger LOG = 
+
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(WSSecDerivedKeyBase.class);
-    
+
     protected Document document;
-    
+
     /**
      * DerivedKeyToken of this builder
      */
     private DerivedKeyToken dkt;
-    
+
     /**
      * Session key used as the secret in key derivation
      */
     private byte[] ephemeralKey;
-     
+
     /**
      * Client's label value
      */
     private String clientLabel = ConversationConstants.DEFAULT_LABEL;
-    
+
     /**
      * Service's label value
      */
     private String serviceLabel = ConversationConstants.DEFAULT_LABEL;
-    
+
     /**
-     * The Token identifier of the token that the <code>DerivedKeyToken</code> 
+     * The Token identifier of the token that the <code>DerivedKeyToken</code>
      * is (or to be) derived from.
      */
     private String tokenIdentifier;
-    
+
     /**
      * True if the tokenIdentifier is a direct reference to a key identifier
      * instead of a URI to a key
@@ -87,28 +87,28 @@ public abstract class WSSecDerivedKeyBas
      * The wsse:SecurityTokenReference element to be used
      */
     private Element strElem;
-    
+
     /**
      * wsu:Id of the wsc:DerivedKeyToken
      */
     private String dktId;
-    
+
     /**
      * Raw bytes of the derived key
      */
-    private byte[] derivedKeyBytes; 
-    
+    private byte[] derivedKeyBytes;
+
     private int wscVersion = ConversationConstants.DEFAULT_VERSION;
-    
+
     private String customValueType;
     private X509Certificate useThisCert;
     private Crypto crypto;
-    
+
     public WSSecDerivedKeyBase() {
         super();
         setKeyIdentifierType(0);
     }
-    
+
     /**
      * The derived key will change depending on the sig/encr algorithm.
      * Therefore the child classes are expected to provide this value.
@@ -116,7 +116,7 @@ public abstract class WSSecDerivedKeyBas
      * @throws WSSecurityException
      */
     protected abstract int getDerivedKeyLength() throws WSSecurityException;
-    
+
     /**
      * @param ephemeralKey The ephemeralKey to set.
      */
@@ -124,7 +124,7 @@ public abstract class WSSecDerivedKeyBas
         this.ephemeralKey = ephemeralKey;
         this.tokenIdentifier = tokenIdentifier;
     }
-    
+
     /**
      * @param ephemeralKey The ephemeralKey to set.
      */
@@ -132,14 +132,14 @@ public abstract class WSSecDerivedKeyBas
         this.ephemeralKey = ephemeralKey;
         this.strElem = strElem;
     }
-    
+
     /**
      * @return Returns the tokenIdentifier.
      */
     public String getTokenIdentifier() {
         return tokenIdentifier;
     }
-    
+
     /**
      * Set the X509 Certificate to use
      * @param cer the X509 Certificate to use
@@ -147,23 +147,23 @@ public abstract class WSSecDerivedKeyBas
     public void setX509Certificate(X509Certificate cer) {
         this.useThisCert = cer;
     }
-    
+
     /**
      * Get the id generated during <code>prepare()</code>.
-     * 
+     *
      * Returns the the value of wsu:Id attribute of the DerivedKeyToken element.
-     * 
+     *
      * @return Return the wsu:Id of this token or null if <code>prepare()</code>
      *         was not called before.
      */
     public String getId() {
         return dktId;
     }
-    
+
     /**
      * Set the label value of the client.
      * @param clientLabel
-     */    
+     */
     public void setClientLabel(String clientLabel) {
         this.clientLabel = clientLabel;
     }
@@ -178,20 +178,20 @@ public abstract class WSSecDerivedKeyBas
 
     /**
      * Initialize a WSSec Derived key.
-     * 
+     *
      * The method prepares and initializes a WSSec derived key structure after the
      * relevant information was set. This method also creates and initializes the
      * derived token using the ephemeral key. After preparation references
      * can be added, encrypted and signed as required.
-     * 
+     *
      * This method does not add any element to the security header. This must be
      * done explicitly.
-     * 
+     *
      * @param doc The unsigned SOAP envelope as <code>Document</code>
      * @throws WSSecurityException
      */
     public void prepare(Document doc) throws WSSecurityException {
-        
+
         document = doc;
 
         // Create the derived keys
@@ -202,51 +202,51 @@ public abstract class WSSecDerivedKeyBas
         String labelText = clientLabel + serviceLabel;
         label = labelText.getBytes(StandardCharsets.UTF_8);
         byte[] nonce = WSSecurityUtil.generateNonce(16);
-        
+
         byte[] seed = new byte[label.length + nonce.length];
         System.arraycopy(label, 0, seed, 0, label.length);
         System.arraycopy(nonce, 0, seed, label.length, nonce.length);
-        
-        DerivationAlgorithm algo = 
+
+        DerivationAlgorithm algo =
             AlgoFactory.getInstance(ConversationConstants.DerivationAlgorithm.P_SHA_1);
-        
+
         if (ephemeralKey == null || ephemeralKey.length == 0) {
             LOG.debug("No ephemeral key is supplied for id: " + tokenIdentifier);
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE);
         }
-        
+
         derivedKeyBytes = algo.createKey(ephemeralKey, seed, offset, length);
-        
+
         // Add the DKTs
         dkt = new DerivedKeyToken(wscVersion, document);
         dktId = getIdAllocator().createId("DK-", dkt);
-        
+
         dkt.setOffset(offset);
         dkt.setLength(length);
         dkt.setNonce(Base64.encode(nonce));
         dkt.setID(dktId);
-        
+
         if (strElem == null) {
             SecurityTokenReference secRef = new SecurityTokenReference(document);
             String strUri = getIdAllocator().createSecureId("STR-", secRef);
             secRef.setID(strUri);
-            
+
             X509Certificate[] certs = getSigningCerts();
-            
+
             switch (keyIdentifierType) {
-    
+
             case WSConstants.X509_KEY_IDENTIFIER:
                 secRef.setKeyIdentifier(certs[0]);
                 break;
-    
+
             case WSConstants.SKI_KEY_IDENTIFIER:
                 secRef.setKeyIdentifierSKI(certs[0], crypto);
                 break;
-    
+
             case WSConstants.THUMBPRINT_IDENTIFIER:
                 secRef.setKeyIdentifierThumb(certs[0]);
                 break;
-                
+
             case WSConstants.CUSTOM_KEY_IDENTIFIER:
                 secRef.setKeyIdentifier(customValueType, tokenIdentifier);
                 if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customValueType)) {
@@ -259,7 +259,7 @@ public abstract class WSSecDerivedKeyBas
                 break;
             default:
                 Reference ref = new Reference(document);
-                
+
                 if (tokenIdDirectId) {
                     ref.setURI(tokenIdentifier);
                 } else {
@@ -267,7 +267,7 @@ public abstract class WSSecDerivedKeyBas
                 }
                 if (customValueType != null && !"".equals(customValueType)) {
                     ref.setValueType(customValueType);
-                } 
+                }
                 if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customValueType)) {
                     secRef.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
                     ref.setValueType(customValueType);
@@ -284,12 +284,12 @@ public abstract class WSSecDerivedKeyBas
                     ref.setValueType(customValueType);
                 } else if (!WSConstants.WSS_USERNAME_TOKEN_VALUE_TYPE.equals(customValueType)) {
                     secRef.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
-                } 
+                }
 
                 secRef.setReference(ref);
             }
-            
-            dkt.setSecurityTokenReference(secRef); 
+
+            dkt.setSecurityTokenReference(secRef);
         } else {
             dkt.setSecurityTokenReference(strElem);
         }
@@ -299,11 +299,11 @@ public abstract class WSSecDerivedKeyBas
     /**
      * Prepend the DerivedKey element to the elements already in the Security
      * header.
-     * 
+     *
      * The method can be called any time after <code>prepare()</code>. This
      * allows to insert the DerivedKey element at any position in the Security
      * header.
-     * 
+     *
      * @param secHeader The security header that holds the Signature element.
      */
     public void prependDKElementToHeader(WSSecHeader secHeader) {
@@ -311,7 +311,7 @@ public abstract class WSSecDerivedKeyBas
             secHeader.getSecurityHeader(), dkt.getElement()
         );
     }
-    
+
     public void appendDKElementToHeader(WSSecHeader secHeader) {
         Element secHeaderElement = secHeader.getSecurityHeader();
         secHeaderElement.appendChild(dkt.getElement());
@@ -323,11 +323,11 @@ public abstract class WSSecDerivedKeyBas
     public void setWscVersion(int wscVersion) {
         this.wscVersion = wscVersion;
     }
-    
+
     public int getWscVersion() {
         return wscVersion;
     }
-    
+
     public Element getdktElement() {
         return dkt.getElement();
     }
@@ -335,11 +335,11 @@ public abstract class WSSecDerivedKeyBas
     public void setCustomValueType(String customValueType) {
         this.customValueType = customValueType;
     }
-    
+
     public void setTokenIdDirectId(boolean b) {
         tokenIdDirectId = b;
     }
-    
+
     /**
      * Set up the X509 Certificate(s) for signing.
      */
@@ -368,11 +368,11 @@ public abstract class WSSecDerivedKeyBas
         }
         return certs;
     }
-    
+
     public void setCrypto(Crypto crypto) {
         this.crypto = crypto;
     }
-    
+
     protected SecretKey getDerivedKey(String algorithm) {
         return KeyUtils.prepareSecretKey(algorithm, derivedKeyBytes);
     }

Modified: webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java?rev=1720895&r1=1720894&r2=1720895&view=diff
==============================================================================
--- webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java (original)
+++ webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java Sat Dec 19 11:11:50 2015
@@ -75,20 +75,20 @@ import org.w3c.dom.NodeList;
  * and adds the encryption data.
  */
 public class WSSecEncrypt extends WSSecEncryptedKey {
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(WSSecEncrypt.class);
-    
+
     /**
      * SecurityTokenReference to be inserted into EncryptedData/keyInfo element.
      */
     private SecurityTokenReference securityTokenReference;
 
     /**
-     * Indicates whether to encrypt the symmetric key into an EncryptedKey 
+     * Indicates whether to encrypt the symmetric key into an EncryptedKey
      * or not.
      */
     private boolean encryptSymmKey = true;
-    
+
     /**
      * Custom reference value
      */
@@ -98,25 +98,25 @@ public class WSSecEncrypt extends WSSecE
      * True if the encKeyId is a direct reference to a key identifier instead of a URI to a key
      */
     private boolean encKeyIdDirectId;
-    
+
     private boolean embedEncryptedKey;
 
     private List<Element> attachmentEncryptedDataElements;
- 
+
     public WSSecEncrypt() {
         super();
     }
-    
+
     /**
      * Initialize a WSSec Encrypt.
-     * 
+     *
      * The method prepares and initializes a WSSec Encrypt structure after the
      * relevant information was set. After preparation of the token references
      * can be added and encrypted.
-     * 
+     *
      * This method does not add any element to the security header. This must be
      * done explicitly.
-     * 
+     *
      * @param doc The SOAP envelope as <code>Document</code>
      * @param crypto An instance of the Crypto API to handle keystore and certificates
      * @throws WSSecurityException
@@ -130,14 +130,14 @@ public class WSSecEncrypt extends WSSecE
         //
         if (symmetricKey == null) {
             if (getEphemeralKey() != null) {
-                symmetricKey = 
+                symmetricKey =
                     KeyUtils.prepareSecretKey(getSymmetricEncAlgorithm(), getEphemeralKey());
             } else {
                 KeyGenerator keyGen = KeyUtils.getKeyGenerator(getSymmetricEncAlgorithm());
                 symmetricKey = keyGen.generateKey();
             }
         }
-        
+
         //
         // Get the certificate that contains the public key for the public key
         // algorithm that will encrypt the generated symmetric (session) key.
@@ -169,17 +169,17 @@ public class WSSecEncrypt extends WSSecE
             encryptedEphemeralKey = symmetricKey.getEncoded();
         }
     }
-    
+
 
     /**
      * Builds the SOAP envelope with encrypted Body and adds encrypted key.
-     * 
+     *
      * This is a convenience method and for backward compatibility. The method
      * calls the single function methods in order to perform a <i>one shot
      * encryption</i>. This method is compatible with the build method of the
      * previous version with the exception of the additional WSSecHeader
      * parameter.
-     * 
+     *
      * @param doc the SOAP envelope as <code>Document</code> with plain text Body
      * @param crypto an instance of the Crypto API to handle keystore and Certificates
      * @param secHeader the security header element to hold the encrypted key element.
@@ -191,17 +191,17 @@ public class WSSecEncrypt extends WSSecE
         doDebug = LOG.isDebugEnabled();
 
         prepare(doc, crypto);
-        
+
         if (doDebug) {
             LOG.debug("Beginning Encryption...");
         }
-        
+
         Element refs = encrypt();
 
         addAttachmentEncryptedDataElements(secHeader);
         if (getEncryptedKeyElement() != null) {
             addInternalRefElement(refs);
-            prependToHeader(secHeader); 
+            prependToHeader(secHeader);
         } else {
             addExternalRefElement(refs, secHeader);
         }
@@ -212,38 +212,38 @@ public class WSSecEncrypt extends WSSecE
         LOG.debug("Encryption complete.");
         return doc;
     }
-    
+
     public Element encrypt() throws WSSecurityException {
         if (getParts().isEmpty()) {
             getParts().add(WSSecurityUtil.getDefaultEncryptionPart(document));
         }
-        
+
         return encryptForRef(null, getParts());
     }
-    
+
     /**
      * Encrypt one or more parts or elements of the message.
-     * 
+     *
      * This method takes a vector of <code>WSEncryptionPart</code> object that
      * contain information about the elements to encrypt. The method call the
      * encryption method, takes the reference information generated during
      * encryption and add this to the <code>xenc:Reference</code> element.
      * This method can be called after <code>prepare()</code> and can be
      * called multiple times to encrypt a number of parts or elements.
-     * 
+     *
      * The method generates a <code>xenc:Reference</code> element that <i>must</i>
      * be added to this token. See <code>addInternalRefElement()</code>.
-     * 
+     *
      * If the <code>dataRef</code> parameter is <code>null</code> the method
      * creates and initializes a new Reference element.
-     * 
+     *
      * @param dataRef A <code>xenc:Reference</code> element or <code>null</code>
      * @param references A list containing WSEncryptionPart objects
      * @return Returns the updated <code>xenc:Reference</code> element
      * @throws WSSecurityException
      */
     public Element encryptForRef(
-        Element dataRef, 
+        Element dataRef,
         List<WSEncryptionPart> references
     ) throws WSSecurityException {
         KeyInfo keyInfo = createKeyInfo();
@@ -251,18 +251,18 @@ public class WSSecEncrypt extends WSSecE
         //this occurs e.g. with a kerberos session-key. It doesn't matter for the bouncy-castle provider
         //so create a new secretKeySpec to make everybody happy.
         SecretKeySpec secretKeySpec = new SecretKeySpec(symmetricKey.getEncoded(), symmetricKey.getAlgorithm());
-        List<String> encDataRefs = 
+        List<String> encDataRefs =
             doEncryption(
-                document, getIdAllocator(), keyInfo, secretKeySpec, getSymmetricEncAlgorithm(), references, 
+                document, getIdAllocator(), keyInfo, secretKeySpec, getSymmetricEncAlgorithm(), references,
                     callbackLookup, attachmentCallbackHandler, attachmentEncryptedDataElements,
                     storeBytesInAttachment
             );
         if (encDataRefs.isEmpty()) {
             return null;
         }
-        
+
         if (dataRef == null) {
-            dataRef = 
+            dataRef =
                 document.createElementNS(
                     WSConstants.ENC_NS,
                     WSConstants.ENC_PREFIX + ":ReferenceList"
@@ -282,11 +282,11 @@ public class WSSecEncrypt extends WSSecE
 
     /**
      * Adds the internal Reference element to this Encrypt data.
-     * 
+     *
      * The reference element <i>must</i> be created by the
      * <code>encryptForInternalRef()</code> method. The reference element is
      * added to the <code>EncryptedKey</code> element of this encrypt block.
-     * 
+     *
      * @param dataRef The internal <code>enc:Reference</code> element
      */
     public void addInternalRefElement(Element dataRef) {
@@ -297,11 +297,11 @@ public class WSSecEncrypt extends WSSecE
 
     /**
      * Adds (prepends) the external Reference element to the Security header.
-     * 
+     *
      * The reference element <i>must</i> be created by the
      * <code>encryptForExternalRef() </code> method. The method prepends the
      * reference element in the SecurityHeader.
-     * 
+     *
      * @param dataRef The external <code>enc:Reference</code> element
      * @param secHeader The security header.
      */
@@ -385,7 +385,7 @@ public class WSSecEncrypt extends WSSecE
             if (callbackLookup == null) {
                 callbackLookup = new DOMCallbackLookup(doc);
             }
-            List<Element> elementsToEncrypt = 
+            List<Element> elementsToEncrypt =
                 WSSecurityUtil.findElements(encPart, callbackLookup, doc);
             if (elementsToEncrypt == null || elementsToEncrypt.size() == 0) {
                 if (!encPart.isRequired()) {
@@ -400,7 +400,7 @@ public class WSSecEncrypt extends WSSecE
             if (storeBytesInAttachment) {
                 for (Element elementToEncrypt : elementsToEncrypt) {
                     try {
-                        String id = 
+                        String id =
                             encryptElementInAttachment(doc, idAllocator, keyInfo, secretKey, encryptionAlgorithm,
                                           attachmentCallbackHandler, encPart, elementToEncrypt);
                         encPart.setEncId(id);
@@ -413,7 +413,7 @@ public class WSSecEncrypt extends WSSecE
                 }
             } else {
                 for (Element elementToEncrypt : elementsToEncrypt) {
-                    String id = 
+                    String id =
                         encryptElement(doc, elementToEncrypt, encPart.getEncModifier(), idAllocator, xmlCipher,
                                        secretKey, keyInfo);
                     encPart.setEncId(id);
@@ -430,7 +430,7 @@ public class WSSecEncrypt extends WSSecE
 
         return encDataRef;
     }
-    
+
     private static String encryptElementInAttachment(
         Document doc,
         WsuIdAllocator idAllocator,
@@ -441,16 +441,16 @@ public class WSSecEncrypt extends WSSecE
         WSEncryptionPart encryptionPart,
         Element elementToEncrypt
    ) throws Exception {
-        
+
         String type = EncryptionConstants.TYPE_ELEMENT;
         if ("Content".equals(encryptionPart.getEncModifier())) {
             type = EncryptionConstants.TYPE_CONTENT;
         }
-        
+
         final String attachmentId = idAllocator.createId("", doc);
         String encEncryptedDataId = idAllocator.createId("ED-", attachmentId);
-        
-        if ("Header".equals(encryptionPart.getEncModifier()) 
+
+        if ("Header".equals(encryptionPart.getEncModifier())
             && elementToEncrypt.getParentNode().equals(WSSecurityUtil.getSOAPHeader(doc))) {
             createEncryptedHeaderElement(doc, elementToEncrypt, idAllocator);
         }
@@ -480,7 +480,7 @@ public class WSSecEncrypt extends WSSecE
         AbstractSerializer serializer = new TransformSerializer();
         serializer.setCanonicalizer(Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_PHYSICAL));
         serializer.setSecureValidation(true);
-        
+
         byte[] serializedOctets = null;
         if (type.equals(EncryptionConstants.TYPE_CONTENT)) {
             NodeList children = elementToEncrypt.getChildNodes();
@@ -492,7 +492,7 @@ public class WSSecEncrypt extends WSSecE
         } else {
             serializedOctets = serializer.serializeToByteArray(elementToEncrypt);
         }
-        
+
         byte[] encryptedBytes = null;
         try {
             encryptedBytes = cipher.doFinal(serializedOctets);
@@ -507,7 +507,7 @@ public class WSSecEncrypt extends WSSecE
         byte[] finalEncryptedBytes = new byte[iv.length + encryptedBytes.length];
         System.arraycopy(iv, 0, finalEncryptedBytes, 0, iv.length);
         System.arraycopy(encryptedBytes, 0, finalEncryptedBytes, iv.length, encryptedBytes.length);
-        
+
         if ("Content".equals(encryptionPart.getEncModifier())) {
             Node child = elementToEncrypt.getFirstChild();
             while (child != null) {
@@ -519,13 +519,13 @@ public class WSSecEncrypt extends WSSecE
         } else {
             elementToEncrypt.getParentNode().replaceChild(encryptedData, elementToEncrypt);
         }
-        
-        WSSecurityUtil.storeBytesInAttachment(cipherValue, doc, attachmentId, 
+
+        WSSecurityUtil.storeBytesInAttachment(cipherValue, doc, attachmentId,
                                               finalEncryptedBytes, attachmentCallbackHandler);
 
         return encEncryptedDataId;
     }
-    
+
     private static void encryptAttachment(
         Document doc,
         WsuIdAllocator idAllocator,
@@ -620,8 +620,8 @@ public class WSSecEncrypt extends WSSecE
             }
         }
     }
-    
-    private static Cipher createCipher(String encryptionAlgorithm, SecretKey secretKey) 
+
+    private static Cipher createCipher(String encryptionAlgorithm, SecretKey secretKey)
         throws WSSecurityException {
         String jceAlgorithm = JCEMapper.translateURItoJCEID(encryptionAlgorithm);
         try {
@@ -662,11 +662,11 @@ public class WSSecEncrypt extends WSSecE
         //
         String xencEncryptedDataId = idAllocator.createId("ED-", elementToEncrypt);
         try {
-            if ("Header".equals(modifier) 
+            if ("Header".equals(modifier)
                 && elementToEncrypt.getParentNode().equals(WSSecurityUtil.getSOAPHeader(doc))) {
                 createEncryptedHeaderElement(doc, elementToEncrypt, idAllocator);
             }
-            
+
             xmlCipher.init(XMLCipher.ENCRYPT_MODE, secretKey);
             EncryptedData encData = xmlCipher.getEncryptedData();
             encData.setId(xencEncryptedDataId);
@@ -679,18 +679,18 @@ public class WSSecEncrypt extends WSSecE
             );
         }
     }
-    
+
     private static void createEncryptedHeaderElement(
         Document doc,
         Element elementToEncrypt,
         WsuIdAllocator idAllocator
     ) {
-        Element elem = 
+        Element elem =
             doc.createElementNS(
                 WSConstants.WSSE11_NS, "wsse11:" + WSConstants.ENCRYPTED_HEADER
             );
         XMLUtils.setNamespace(elem, WSConstants.WSSE11_NS, WSConstants.WSSE11_PREFIX);
-        String wsuPrefix = 
+        String wsuPrefix =
             XMLUtils.setNamespace(elem, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
         String headerId = idAllocator.createId("EH-", elementToEncrypt);
         elem.setAttributeNS(
@@ -704,25 +704,25 @@ public class WSSecEncrypt extends WSSecE
         Node parent = elementToEncrypt.getParentNode();
         elementToEncrypt = (Element)parent.replaceChild(elem, elementToEncrypt);
         elem.appendChild(elementToEncrypt);
-        
+
         NamedNodeMap map = elementToEncrypt.getAttributes();
         for (int i = 0; i < map.getLength(); i++) {
             Attr attr = (Attr)map.item(i);
             if (WSConstants.URI_SOAP11_ENV.equals(attr.getNamespaceURI())
                 || WSConstants.URI_SOAP12_ENV.equals(attr.getNamespaceURI())) {
-                String soapEnvPrefix = 
+                String soapEnvPrefix =
                     XMLUtils.setNamespace(
                         elem, attr.getNamespaceURI(), WSConstants.DEFAULT_SOAP_PREFIX
                     );
                 elem.setAttributeNS(
-                    attr.getNamespaceURI(), 
-                    soapEnvPrefix + ":" + attr.getLocalName(), 
+                    attr.getNamespaceURI(),
+                    soapEnvPrefix + ":" + attr.getLocalName(),
                     attr.getValue()
                 );
             }
         }
     }
-    
+
     /**
      * Create a KeyInfo object
      */
@@ -773,7 +773,7 @@ public class WSSecEncrypt extends WSSecE
             if (encKeyIdDirectId) {
                 ref.setURI(getId());
             } else {
-                ref.setURI("#" + getId());                    
+                ref.setURI("#" + getId());
             }
             if (customReferenceValue != null) {
                 ref.setValueType(customReferenceValue);
@@ -797,18 +797,18 @@ public class WSSecEncrypt extends WSSecE
             secToken.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
             keyInfo.addUnknownElement(secToken.getElement());
         }
-        
+
         Element keyInfoElement = keyInfo.getElement();
         keyInfoElement.setAttributeNS(
             WSConstants.XMLNS_NS, "xmlns:" + WSConstants.SIG_PREFIX, WSConstants.SIG_NS
         );
-        
+
         return keyInfo;
     }
 
     /**
      * Create DOM subtree for <code>xenc:EncryptedKey</code>
-     * 
+     *
      * @param doc the SOAP envelope parent document
      * @param referenceList
      * @param encDataRefs
@@ -816,11 +816,11 @@ public class WSSecEncrypt extends WSSecE
      */
     public static Element createDataRefList(
         Document doc,
-        Element referenceList, 
+        Element referenceList,
         List<String> encDataRefs
     ) {
         for (String dataReferenceUri : encDataRefs) {
-            Element dataReference = 
+            Element dataReference =
                 doc.createElementNS(
                     WSConstants.ENC_NS, WSConstants.ENC_PREFIX + ":DataReference"
                 );
@@ -847,23 +847,23 @@ public class WSSecEncrypt extends WSSecE
     public boolean isEncryptSymmKey() {
         return encryptSymmKey;
     }
-    
+
     public void setEncryptSymmKey(boolean encryptSymmKey) {
         this.encryptSymmKey = encryptSymmKey;
     }
-    
+
     public void setCustomReferenceValue(String customReferenceValue) {
         this.customReferenceValue = customReferenceValue;
     }
-    
+
     public void setEncKeyIdDirectId(boolean b) {
         encKeyIdDirectId = b;
     }
-    
+
     public void setEmbedEncryptedKey(boolean embedEncryptedKey) {
         this.embedEncryptedKey = embedEncryptedKey;
     }
-    
+
     public boolean isEmbedEncryptedKey() {
         return embedEncryptedKey;
     }

Modified: webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncryptedKey.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncryptedKey.java?rev=1720895&r1=1720894&r2=1720895&view=diff
==============================================================================
--- webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncryptedKey.java (original)
+++ webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncryptedKey.java Sat Dec 19 11:11:50 2015
@@ -53,7 +53,7 @@ import org.w3c.dom.Text;
 
 /**
  * Builder class to build an EncryptedKey.
- * 
+ *
  * This is especially useful in the case where the same
  * <code>EncryptedKey</code> has to be used to sign and encrypt the message In
  * such a situation this builder will add the <code>EncryptedKey</code> to the
@@ -62,11 +62,11 @@ import org.w3c.dom.Text;
  */
 public class WSSecEncryptedKey extends WSSecBase {
 
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(WSSecEncryptedKey.class);
 
     protected Document document;
-    
+
     /**
      * Encrypted bytes of the ephemeral key
      */
@@ -76,7 +76,7 @@ public class WSSecEncryptedKey extends W
      * Session key used as the secret in key derivation
      */
     private byte[] ephemeralKey;
-    
+
     /**
      * Symmetric key used in the EncryptedKey.
      */
@@ -86,12 +86,12 @@ public class WSSecEncryptedKey extends W
      * Algorithm used to encrypt the ephemeral key
      */
     private String keyEncAlgo = WSConstants.KEYTRANSPORT_RSAOEP;
-    
+
     /**
      * Algorithm to be used with the ephemeral key
      */
     private String symEncAlgo = WSConstants.AES_128;
-    
+
     /**
      * Digest Algorithm to be used with RSA-OAEP. The default is SHA-1 (which is not
      * written out unless it is explicitly configured).
@@ -120,33 +120,33 @@ public class WSSecEncryptedKey extends W
      * is used to refer to the asymmetric encryption cert
      */
     private BinarySecurity bstToken;
-    
+
     private X509Certificate useThisCert;
-    
+
     /**
      * Custom token value
      */
     private String customEKTokenValueType;
-    
+
     /**
      * Custom token id
      */
     private String customEKTokenId;
-    
+
     private boolean bstAddedToSecurityHeader;
     private boolean includeEncryptionToken;
     private Element customEKKeyInfoElement;
-    
+
     public WSSecEncryptedKey() {
         super();
     }
-    
+
     /**
      * Set the user name to get the encryption certificate.
-     * 
+     *
      * The public key of this certificate is used, thus no password necessary.
      * The user name is a keystore alias usually.
-     * 
+     *
      * @param user
      */
     public void setUserInfo(String user) {
@@ -155,9 +155,9 @@ public class WSSecEncryptedKey extends W
 
     /**
      * Get the id generated during <code>prepare()</code>.
-     * 
+     *
      * Returns the the value of wsu:Id attribute of the EncryptedKey element.
-     * 
+     *
      * @return Return the wsu:Id of this token or null if <code>prepare()</code>
      *         was not called before.
      */
@@ -170,12 +170,12 @@ public class WSSecEncryptedKey extends W
         symmetricKey = null;
         encryptedEphemeralKey = null;
     }
-    
+
 
     /**
      * Prepare the ephemeralKey and the tokens required to be added to the
      * security header
-     * 
+     *
      * @param doc The SOAP envelope as <code>Document</code>
      * @param crypto An instance of the Crypto API to handle keystore and certificates
      * @throws WSSecurityException
@@ -196,7 +196,7 @@ public class WSSecEncryptedKey extends W
                 ephemeralKey = symmetricKey.getEncoded();
             }
         }
-        
+
         if (encryptedEphemeralKey == null) {
             //
             // Get the certificate that contains the public key for the public key
@@ -221,7 +221,7 @@ public class WSSecEncryptedKey extends W
                 }
                 remoteCert = certs[0];
             }
-            
+
             prepareInternal(symmetricKey, remoteCert, crypto);
         } else {
             prepareInternal(symmetricKey);
@@ -230,10 +230,10 @@ public class WSSecEncryptedKey extends W
 
     /**
      * Encrypt the symmetric key data and prepare the EncryptedKey element
-     * 
+     *
      * This method does the most work for to prepare the EncryptedKey element.
      * It is also used by the WSSecEncrypt sub-class.
-     * 
+     *
      * @param secretKey The symmetric key
      * @param remoteCert The certificate that contains the public key to encrypt the
      *                   symmetric key data
@@ -241,7 +241,7 @@ public class WSSecEncryptedKey extends W
      * @throws WSSecurityException
      */
     protected void prepareInternal(
-        SecretKey secretKey, 
+        SecretKey secretKey,
         X509Certificate remoteCert,
         Crypto crypto
     ) throws WSSecurityException {
@@ -267,8 +267,8 @@ public class WSSecEncryptedKey extends W
                         mgf1ParameterSpec = new MGF1ParameterSpec("SHA-512");
                     }
                 }
-                
-                oaepParameterSpec = 
+
+                oaepParameterSpec =
                     new OAEPParameterSpec(
                         jceDigestAlgorithm, "MGF1", mgf1ParameterSpec, PSource.PSpecified.DEFAULT
                     );
@@ -287,7 +287,7 @@ public class WSSecEncryptedKey extends W
         if (doDebug) {
             LOG.debug("cipher blksize: " + blockSize);
         }
-        
+
         try {
             encryptedEphemeralKey = cipher.wrap(secretKey);
         } catch (IllegalStateException | IllegalBlockSizeException | InvalidKeyException ex) {
@@ -314,20 +314,20 @@ public class WSSecEncryptedKey extends W
             encryptedKeyElement.appendChild(document.adoptNode(customEKKeyInfoElement));
         } else {
             SecurityTokenReference secToken = new SecurityTokenReference(document);
-    
+
             switch (keyIdentifierType) {
             case WSConstants.X509_KEY_IDENTIFIER:
                 secToken.setKeyIdentifier(remoteCert);
                 break;
-    
+
             case WSConstants.SKI_KEY_IDENTIFIER:
                 secToken.setKeyIdentifierSKI(remoteCert, crypto);
-                
+
                 if (includeEncryptionToken) {
                     addBST(remoteCert);
                 }
                 break;
-    
+
             case WSConstants.THUMBPRINT_IDENTIFIER:
             case WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER:
                 //
@@ -335,27 +335,27 @@ public class WSSecEncryptedKey extends W
                 // ThumbprintRSA.
                 //
                 secToken.setKeyIdentifierThumb(remoteCert);
-                
+
                 if (includeEncryptionToken) {
                     addBST(remoteCert);
                 }
                 break;
-    
+
             case WSConstants.ISSUER_SERIAL:
                 String issuer = remoteCert.getIssuerX500Principal().getName();
                 java.math.BigInteger serialNumber = remoteCert.getSerialNumber();
-                DOMX509IssuerSerial domIssuerSerial = 
+                DOMX509IssuerSerial domIssuerSerial =
                     new DOMX509IssuerSerial(
                         document, issuer, serialNumber
                     );
                 DOMX509Data domX509Data = new DOMX509Data(document, domIssuerSerial);
                 secToken.setUnknownElement(domX509Data.getElement());
-                
+
                 if (includeEncryptionToken) {
                     addBST(remoteCert);
                 }
                 break;
-    
+
             case WSConstants.BST_DIRECT_REFERENCE:
                 Reference ref = new Reference(document);
                 String certUri = IDGenerator.generateID(null);
@@ -366,7 +366,7 @@ public class WSSecEncryptedKey extends W
                 ref.setValueType(bstToken.getValueType());
                 secToken.setReference(ref);
                 break;
-                
+
             case WSConstants.CUSTOM_SYMM_SIGNING :
                 Reference refCust = new Reference(document);
                 if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customEKTokenValueType)) {
@@ -383,7 +383,7 @@ public class WSSecEncryptedKey extends W
                 refCust.setURI("#" + customEKTokenId);
                 secToken.setReference(refCust);
                 break;
-                
+
             case WSConstants.CUSTOM_SYMM_SIGNING_DIRECT :
                 Reference refCustd = new Reference(document);
                 if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customEKTokenValueType)) {
@@ -400,7 +400,7 @@ public class WSSecEncryptedKey extends W
                 refCustd.setURI(customEKTokenId);
                 secToken.setReference(refCustd);
                 break;
-                
+
             case WSConstants.CUSTOM_KEY_IDENTIFIER:
                 secToken.setKeyIdentifier(customEKTokenValueType, customEKTokenId);
                 if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customEKTokenValueType)) {
@@ -412,12 +412,12 @@ public class WSSecEncryptedKey extends W
                 } else if (SecurityTokenReference.ENC_KEY_SHA1_URI.equals(customEKTokenValueType)) {
                     secToken.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
                 }
-                break;           
-    
+                break;
+
             default:
                 throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "unsupportedKeyId");
             }
-            Element keyInfoElement = 
+            Element keyInfoElement =
                 document.createElementNS(
                     WSConstants.SIG_NS, WSConstants.SIG_PREFIX + ":" + WSConstants.KEYINFO_LN
                 );
@@ -431,15 +431,15 @@ public class WSSecEncryptedKey extends W
         Element xencCipherValue = createCipherValue(document, encryptedKeyElement);
         if (storeBytesInAttachment) {
             final String attachmentId = getIdAllocator().createId("", document);
-            WSSecurityUtil.storeBytesInAttachment(xencCipherValue, document, attachmentId, 
+            WSSecurityUtil.storeBytesInAttachment(xencCipherValue, document, attachmentId,
                                                   encryptedEphemeralKey, attachmentCallbackHandler);
         } else {
-            Text keyText = 
+            Text keyText =
                 WSSecurityUtil.createBase64EncodedTextNode(document, encryptedEphemeralKey);
             xencCipherValue.appendChild(keyText);
         }
     }
-    
+
     protected void prepareInternal(SecretKey secretKey) throws WSSecurityException {
         encryptedKeyElement = createEncryptedKey(document, keyEncAlgo);
         if (encKeyId == null || "".equals(encKeyId)) {
@@ -455,7 +455,7 @@ public class WSSecEncryptedKey extends W
             SecurityTokenReference secToken = new SecurityTokenReference(document);
 
             switch (keyIdentifierType) {
-    
+
                 case WSConstants.CUSTOM_SYMM_SIGNING :
                     Reference refCust = new Reference(document);
                     if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customEKTokenValueType)) {
@@ -472,7 +472,7 @@ public class WSSecEncryptedKey extends W
                     refCust.setURI("#" + customEKTokenId);
                     secToken.setReference(refCust);
                     break;
-    
+
                 case WSConstants.CUSTOM_SYMM_SIGNING_DIRECT :
                     Reference refCustd = new Reference(document);
                     if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customEKTokenValueType)) {
@@ -489,7 +489,7 @@ public class WSSecEncryptedKey extends W
                     refCustd.setURI(customEKTokenId);
                     secToken.setReference(refCustd);
                     break;
-    
+
                 case WSConstants.CUSTOM_KEY_IDENTIFIER:
                     secToken.setKeyIdentifier(customEKTokenValueType, customEKTokenId);
                     if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customEKTokenValueType)) {
@@ -501,12 +501,12 @@ public class WSSecEncryptedKey extends W
                     } else if (SecurityTokenReference.ENC_KEY_SHA1_URI.equals(customEKTokenValueType)) {
                         secToken.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
                     }
-                    break;           
-    
+                    break;
+
                 default:
                     throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "unsupportedKeyId");
             }
-            Element keyInfoElement = 
+            Element keyInfoElement =
                 document.createElementNS(
                     WSConstants.SIG_NS, WSConstants.SIG_PREFIX + ":" + WSConstants.KEYINFO_LN
                 );
@@ -520,10 +520,10 @@ public class WSSecEncryptedKey extends W
         Element xencCipherValue = createCipherValue(document, encryptedKeyElement);
         if (storeBytesInAttachment) {
             final String attachmentId = getIdAllocator().createId("", document);
-            WSSecurityUtil.storeBytesInAttachment(xencCipherValue, document, attachmentId, 
+            WSSecurityUtil.storeBytesInAttachment(xencCipherValue, document, attachmentId,
                                                   encryptedEphemeralKey, attachmentCallbackHandler);
         } else {
-            Text keyText = 
+            Text keyText =
                 WSSecurityUtil.createBase64EncodedTextNode(document, encryptedEphemeralKey);
             xencCipherValue.appendChild(keyText);
         }
@@ -535,29 +535,29 @@ public class WSSecEncryptedKey extends W
     private void addBST(X509Certificate cert) throws WSSecurityException {
         bstToken = new X509Security(document);
         ((X509Security) bstToken).setX509Certificate(cert);
-        
+
         bstAddedToSecurityHeader = false;
         bstToken.setID(IDGenerator.generateID(null));
     }
 
     /**
      * Create DOM subtree for <code>xenc:EncryptedKey</code>
-     * 
+     *
      * @param doc the SOAP envelope parent document
      * @param keyTransportAlgo specifies which algorithm to use to encrypt the symmetric key
      * @return an <code>xenc:EncryptedKey</code> element
      */
     protected Element createEncryptedKey(Document doc, String keyTransportAlgo) {
-        Element encryptedKey = 
+        Element encryptedKey =
             doc.createElementNS(WSConstants.ENC_NS, WSConstants.ENC_PREFIX + ":EncryptedKey");
 
         org.apache.wss4j.common.util.XMLUtils.setNamespace(encryptedKey, WSConstants.ENC_NS, WSConstants.ENC_PREFIX);
-        Element encryptionMethod = 
+        Element encryptionMethod =
             doc.createElementNS(WSConstants.ENC_NS, WSConstants.ENC_PREFIX + ":EncryptionMethod");
         encryptionMethod.setAttributeNS(null, "Algorithm", keyTransportAlgo);
-        
+
         if (digestAlgo != null) {
-            Element digestElement = 
+            Element digestElement =
                 XMLUtils.createElementInSignatureSpace(doc, Constants._TAG_DIGESTMETHOD);
             digestElement.setAttributeNS(null, "Algorithm", digestAlgo);
             encryptionMethod.appendChild(digestElement);
@@ -568,15 +568,15 @@ public class WSSecEncryptedKey extends W
             mgfElement.setAttributeNS(null, "Algorithm", mgfAlgo);
             encryptionMethod.appendChild(mgfElement);
         }
-        
+
         encryptedKey.appendChild(encryptionMethod);
         return encryptedKey;
     }
-    
+
     protected Element createCipherValue(Document doc, Element encryptedKey) {
-        Element cipherData = 
+        Element cipherData =
             doc.createElementNS(WSConstants.ENC_NS, WSConstants.ENC_PREFIX + ":CipherData");
-        Element cipherValue = 
+        Element cipherValue =
             doc.createElementNS(WSConstants.ENC_NS, WSConstants.ENC_PREFIX + ":CipherValue");
         cipherData.appendChild(cipherValue);
         encryptedKey.appendChild(cipherData);
@@ -586,11 +586,11 @@ public class WSSecEncryptedKey extends W
     /**
      * Prepend the EncryptedKey element to the elements already in the Security
      * header.
-     * 
+     *
      * The method can be called any time after <code>prepare()</code>. This
      * allows to insert the EncryptedKey element at any position in the Security
      * header.
-     * 
+     *
      * @param secHeader The security header that holds the Signature element.
      */
     public void prependToHeader(WSSecHeader secHeader) {
@@ -600,25 +600,25 @@ public class WSSecEncryptedKey extends W
     /**
      * Append the EncryptedKey element to the elements already in the Security
      * header.
-     * 
+     *
      * The method can be called any time after <code>prepare()</code>. This
      * allows to insert the EncryptedKey element at any position in the Security
      * header.
-     * 
+     *
      * @param secHeader The security header that holds the Signature element.
      */
     public void appendToHeader(WSSecHeader secHeader) {
         Element secHeaderElement = secHeader.getSecurityHeader();
         secHeaderElement.appendChild(encryptedKeyElement);
     }
-    
+
     /**
      * Prepend the BinarySecurityToken to the elements already in the Security
      * header.
-     * 
+     *
      * The method can be called any time after <code>prepare()</code>. This
      * allows to insert the BST element at any position in the Security header.
-     * 
+     *
      * @param secHeader The security header that holds the BST element.
      */
     public void prependBSTElementToHeader(WSSecHeader secHeader) {
@@ -633,10 +633,10 @@ public class WSSecEncryptedKey extends W
     /**
      * Append the BinarySecurityToken to the elements already in the Security
      * header.
-     * 
+     *
      * The method can be called any time after <code>prepare()</code>. This
      * allows to insert the BST element at any position in the Security header.
-     * 
+     *
      * @param secHeader The security header that holds the BST element.
      */
     public void appendBSTElementToHeader(WSSecHeader secHeader) {
@@ -646,27 +646,27 @@ public class WSSecEncryptedKey extends W
             bstAddedToSecurityHeader = true;
         }
     }
-    
+
     /**
      * @return Returns the ephemeralKey.
      */
     public byte[] getEphemeralKey() {
         return ephemeralKey;
     }
-    
+
     /**
      * Set the X509 Certificate to use for encryption.
-     * 
+     *
      * If this is set <b>and</b> the key identifier is set to
      * <code>DirectReference</code> then use this certificate to get the
      * public key for encryption.
-     * 
+     *
      * @param cert is the X509 certificate to use for encryption
      */
     public void setUseThisCert(X509Certificate cert) {
         useThisCert = cert;
     }
-    
+
     public X509Certificate getUseThisCert() {
         return useThisCert;
     }
@@ -677,7 +677,7 @@ public class WSSecEncryptedKey extends W
     public Element getEncryptedKeyElement() {
         return encryptedKeyElement;
     }
-    
+
     /**
      * Set the encrypted key element when a pre prepared encrypted key is used
      * @param encryptedKeyElement EncryptedKey element of the encrypted key used
@@ -685,7 +685,7 @@ public class WSSecEncryptedKey extends W
     public void setEncryptedKeyElement(Element encryptedKeyElement) {
         this.encryptedKeyElement = encryptedKeyElement;
     }
-    
+
     /**
      * @return Returns the BinarySecurityToken element.
      */
@@ -695,11 +695,11 @@ public class WSSecEncryptedKey extends W
         }
         return null;
     }
-    
+
     public void setKeyEncAlgo(String keyEncAlgo) {
         this.keyEncAlgo = keyEncAlgo;
     }
-    
+
     public String getKeyEncAlgo() {
         return keyEncAlgo;
     }
@@ -710,18 +710,18 @@ public class WSSecEncryptedKey extends W
     public void setEphemeralKey(byte[] ephemeralKey) {
         this.ephemeralKey = ephemeralKey;
     }
-    
+
     /**
      * Get the id of the BSt generated  during <code>prepare()</code>.
-     * 
-     * @return Returns the the value of wsu:Id attribute of the 
+     *
+     * @return Returns the the value of wsu:Id attribute of the
      * BinaruSecurityToken element.
      */
     public String getBSTTokenId() {
         if (bstToken == null) {
             return null;
         }
-        
+
         return bstToken.getID();
     }
 
@@ -738,7 +738,7 @@ public class WSSecEncryptedKey extends W
     public void setEncKeyId(String encKeyId) {
         this.encKeyId = encKeyId;
     }
-    
+
     public boolean isCertSet() {
         if (useThisCert == null) {
             return false;
@@ -749,11 +749,11 @@ public class WSSecEncryptedKey extends W
     public byte[] getEncryptedEphemeralKey() {
         return encryptedEphemeralKey;
     }
-    
+
     public void setEncryptedEphemeralKey(byte[] encryptedKey) {
         encryptedEphemeralKey = encryptedKey;
     }
-    
+
     public void setCustomEKTokenValueType(String customEKTokenValueType) {
         this.customEKTokenValueType = customEKTokenValueType;
     }
@@ -761,14 +761,14 @@ public class WSSecEncryptedKey extends W
     public void setCustomEKTokenId(String customEKTokenId) {
         this.customEKTokenId = customEKTokenId;
     }
-    
+
     /**
      * Set the name of the symmetric encryption algorithm to use.
-     * 
+     *
      * This encryption algorithm is used to encrypt the data. If the algorithm
      * is not set then AES128 is used. Refer to WSConstants which algorithms are
      * supported.
-     * 
+     *
      * @param algo Is the name of the encryption algorithm
      * @see WSConstants#TRIPLE_DES
      * @see WSConstants#AES_128
@@ -779,13 +779,13 @@ public class WSSecEncryptedKey extends W
         symEncAlgo = algo;
     }
 
-    
+
     /**
      * Get the name of symmetric encryption algorithm to use.
-     * 
+     *
      * The name of the encryption algorithm to encrypt the data, i.e. the SOAP
      * Body. Refer to WSConstants which algorithms are supported.
-     * 
+     *
      * @return the name of the currently selected symmetric encryption algorithm
      * @see WSConstants#TRIPLE_DES
      * @see WSConstants#AES_128
@@ -795,17 +795,17 @@ public class WSSecEncryptedKey extends W
     public String getSymmetricEncAlgorithm() {
         return symEncAlgo;
     }
-    
+
     /**
      * Set the digest algorithm to use with the RSA-OAEP key transport algorithm. The
      * default is SHA-1.
-     * 
+     *
      * @param digestAlgorithm the digest algorithm to use with the RSA-OAEP key transport algorithm
      */
     public void setDigestAlgorithm(String digestAlgorithm) {
         this.digestAlgo = digestAlgorithm;
     }
-    
+
     /**
      * Get the digest algorithm to use with the RSA-OAEP key transport algorithm. The
      * default is SHA-1.
@@ -841,7 +841,7 @@ public class WSSecEncryptedKey extends W
 
     /**
      * Set the symmetric key to be used for encryption
-     * 
+     *
      * @param key
      */
     public void setSymmetricKey(SecretKey key) {

Modified: webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecHeader.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecHeader.java?rev=1720895&r1=1720894&r2=1720895&view=diff
==============================================================================
--- webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecHeader.java (original)
+++ webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecHeader.java Sat Dec 19 11:11:50 2015
@@ -28,9 +28,9 @@ import org.w3c.dom.Node;
 
 /**
  * This class implements WS Security header.
- * 
+ *
  * Setup a Security header with a specified actor and mustunderstand flag.
- * 
+ *
  * The defaults for actor and mustunderstand are: empty <code>actor</code> and
  * <code>mustunderstand</code> is true.
  */
@@ -40,7 +40,7 @@ public class WSSecHeader {
     private boolean mustunderstand = true;
 
     private Element securityHeader;
-    
+
     private final Document doc;
 
     /**
@@ -53,7 +53,7 @@ public class WSSecHeader {
 
     /**
      * Constructor.
-     * 
+     *
      * @param actor The actor name of the <code>wsse:Security</code> header
      * @param doc The Document to use when creating the security header
      */
@@ -63,7 +63,7 @@ public class WSSecHeader {
 
     /**
      * Constructor.
-     * 
+     *
      * @param act The actor name of the <code>wsse:Security</code> header
      * @param mu Set <code>mustUnderstand</code> to true or false
      * @param doc The Document to use when creating the security header
@@ -76,7 +76,7 @@ public class WSSecHeader {
 
     /**
      * set actor name.
-     * 
+     *
      * @param act The actor name of the <code>wsse:Security</code> header
      */
     public void setActor(String act) {
@@ -86,7 +86,7 @@ public class WSSecHeader {
     /**
      * Set the <code>mustUnderstand</code> flag for the
      * <code>wsse:Security</code> header.
-     * 
+     *
      * @param mu Set <code>mustUnderstand</code> to true or false
      */
     public void setMustUnderstand(boolean mu) {
@@ -95,16 +95,16 @@ public class WSSecHeader {
 
     /**
      * Get the security header element of this instance.
-     * 
+     *
      * @return The security header element.
      */
     public Element getSecurityHeader() {
         return securityHeader;
     }
-    
+
     /**
      * Returns whether the security header is empty
-     * 
+     *
      * @return true if empty or if there is no security header
      *         false if non empty security header
      */
@@ -113,13 +113,13 @@ public class WSSecHeader {
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty",
                                           new Object[] {"The Document of WSSecHeader is null"});
         }
-        if (securityHeader == null) {            
-            securityHeader = 
+        if (securityHeader == null) {
+            securityHeader =
                 WSSecurityUtil.findWsseSecurityHeaderBlock(
                     doc, doc.getDocumentElement(), actor, false
                 );
         }
-        
+
         if (securityHeader == null || securityHeader.getFirstChild() == null) {
             return true;
         }
@@ -128,11 +128,11 @@ public class WSSecHeader {
 
     /**
      * Creates a security header and inserts it as child into the SOAP Envelope.
-     * 
+     *
      * Check if a WS Security header block for an actor is already available in
      * the document. If a header block is found return it, otherwise a new
      * wsse:Security header block is created and the attributes set
-     * 
+     *
      * @return A <code>wsse:Security</code> element
      */
     public Element insertSecurityHeader() throws WSSecurityException {
@@ -142,23 +142,23 @@ public class WSSecHeader {
         if (securityHeader != null) {
             return securityHeader;
         }
-        
+
         if (doc == null) {
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty",
                                           new Object[] {"The Document of WSSecHeader is null"});
         }
-        
-        securityHeader = 
+
+        securityHeader =
             WSSecurityUtil.findWsseSecurityHeaderBlock(
                 doc, doc.getDocumentElement(), actor, true
             );
 
         String soapNamespace = WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement());
-        String soapPrefix = 
+        String soapPrefix =
             XMLUtils.setNamespace(
                 securityHeader, soapNamespace, WSConstants.DEFAULT_SOAP_PREFIX
             );
-        
+
         if (actor != null && actor.length() > 0) {
             String actorLocal = WSConstants.ATTR_ACTOR;
             if (WSConstants.URI_SOAP12_ENV.equals(soapNamespace)) {
@@ -166,7 +166,7 @@ public class WSSecHeader {
             }
             securityHeader.setAttributeNS(
                 soapNamespace,
-                soapPrefix + ":" + actorLocal, 
+                soapPrefix + ":" + actorLocal,
                 actor
             );
         }
@@ -182,27 +182,27 @@ public class WSSecHeader {
             );
         }
         XMLUtils.setNamespace(securityHeader, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
-        
+
         return securityHeader;
     }
-    
+
     public void removeSecurityHeader() throws WSSecurityException {
-        if (securityHeader == null) {    
+        if (securityHeader == null) {
             if (doc == null) {
                 throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty",
                                               new Object[] {"The Document of WSSecHeader is null"});
             }
-            
-            securityHeader = 
+
+            securityHeader =
                 WSSecurityUtil.findWsseSecurityHeaderBlock(
                     doc, doc.getDocumentElement(), actor, false
                 );
         }
-        
+
         if (securityHeader != null) {
             Node parent = securityHeader.getParentNode();
             parent.removeChild(securityHeader);
         }
     }
-    
+
 }

Modified: webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSAMLToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSAMLToken.java?rev=1720895&r1=1720894&r2=1720895&view=diff
==============================================================================
--- webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSAMLToken.java (original)
+++ webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSAMLToken.java Sat Dec 19 11:11:50 2015
@@ -32,28 +32,28 @@ import org.w3c.dom.Element;
  */
 public class WSSecSAMLToken extends WSSecBase {
 
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(WSSecSAMLToken.class);
-    
+
     private Document document;
-    
+
     private SamlAssertionWrapper saml;
-    
+
     private Element samlElement;
 
     public WSSecSAMLToken() {
         super();
     }
-    
+
     /**
      * Creates a SAML token.
-     * 
+     *
      * The method prepares and initializes a WSSec UsernameToken structure after
      * the relevant information was set. A Before calling
      * <code>prepare()</code> all parameters such as user, password,
      * passwordType etc. must be set. A complete <code>UsernameToken</code> is
      * constructed.
-     * 
+     *
      * @param doc
      *            The SOAP envelope as W3C document
      */
@@ -65,11 +65,11 @@ public class WSSecSAMLToken extends WSSe
     /**
      * Prepends the SAML Assertion to the elements already in the
      * Security header.
-     * 
+     *
      * The method can be called any time after <code>prepare()</code>.
      * This allows to insert the SAML assertion at any position in the
      * Security header.
-     * 
+     *
      * @param secHeader
      *            The security header that holds the Signature element.
      */
@@ -83,7 +83,7 @@ public class WSSecSAMLToken extends WSSe
             throw new RuntimeException(ex.toString(), ex);
         }
     }
-    
+
     public Element getElement() throws WSSecurityException {
         if (samlElement != null) {
             return samlElement;
@@ -94,12 +94,12 @@ public class WSSecSAMLToken extends WSSe
         samlElement = saml.toDOM(document);
         return samlElement;
     }
-    
+
     /**
      * Get the id generated during <code>prepare()</code>.
-     * 
-     * Returns the the value of wsu:Id attribute of this Timestamp. 
-     * 
+     *
+     * Returns the the value of wsu:Id attribute of this Timestamp.
+     *
      * @return Return the wsu:Id of this token or null if <code>prepareToken()</code>
      * was not called before.
      */
@@ -109,7 +109,7 @@ public class WSSecSAMLToken extends WSSe
         }
         return saml.getId();
     }
-    
+
     /**
      * Adds a new <code>SAMLAssertion</code> to a soap envelope.
      * <p/>
@@ -122,10 +122,10 @@ public class WSSecSAMLToken extends WSSe
      */
     public Document build(Document doc, SamlAssertionWrapper samlAssertion, WSSecHeader secHeader) {
         LOG.debug("Begin add SAMLAssertion token...");
-        
+
         prepare(doc, samlAssertion);
         prependToHeader(secHeader);
-        
+
         return doc;
     }
 }

Modified: webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java?rev=1720895&r1=1720894&r2=1720895&view=diff
==============================================================================
--- webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java (original)
+++ webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java Sat Dec 19 11:11:50 2015
@@ -40,7 +40,7 @@ public class WSSecSecurityContextToken {
     private SecurityContextToken sct;
 
     /**
-     * The <code>wsu:Id</code> of the <code>wsc:SecurityContextToken</code> 
+     * The <code>wsu:Id</code> of the <code>wsc:SecurityContextToken</code>
      */
     private String sctId;
 
@@ -54,13 +54,13 @@ public class WSSecSecurityContextToken {
      * The symmetric secret associated with the SecurityContextToken
      */
     private byte[] secret;
-    
+
     private int wscVersion = ConversationConstants.DEFAULT_VERSION;
     private WSSConfig wssConfig;
-    
+
     public WSSecSecurityContextToken() {
     }
-    
+
     public WSSecSecurityContextToken(WSSConfig config) {
         wssConfig = config;
     }
@@ -153,7 +153,7 @@ public class WSSecSecurityContextToken {
     public void setWscVersion(int wscVersion) {
         this.wscVersion = wscVersion;
     }
-    
+
     private WSSConfig getWsConfig() {
         if (wssConfig == null) {
             wssConfig = WSSConfig.getNewInstance();

Modified: webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java?rev=1720895&r1=1720894&r2=1720895&view=diff
==============================================================================
--- webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java (original)
+++ webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java Sat Dec 19 11:11:50 2015
@@ -66,17 +66,17 @@ import org.w3c.dom.Node;
 
 /**
  * Creates a Signature according to WS Specification, X509 profile.
- * 
+ *
  * This class is a re-factored implementation of the previous WSS4J class
  * <code>WSSignEnvelope</code>. This new class allows better control of
  * the process to create a Signature and to add it to the Security header.
- * 
+ *
  * The flexibility and fine granular control is required to implement a handler
  * that uses WSSecurityPolicy files to control the setup of a Security header.
  */
 public class WSSecSignature extends WSSecSignatureBase {
 
-    private static final org.slf4j.Logger LOG = 
+    private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(WSSecSignature.class);
 
     protected XMLSignatureFactory signatureFactory;
@@ -91,7 +91,7 @@ public class WSSecSignature extends WSSe
     protected String keyInfoUri;
     protected String certUri;
     protected byte[] signatureValue;
-    
+
     private boolean useSingleCert = true;
     private String sigAlgo;
     private String canonAlgo = WSConstants.C14N_EXCL_OMIT_COMMENTS;
@@ -112,7 +112,7 @@ public class WSSecSignature extends WSSe
         super();
         init();
     }
-    
+
     private void init() {
         // Try to install the Santuario Provider - fall back to the JDK provider if this does
         // not work
@@ -122,17 +122,17 @@ public class WSSecSignature extends WSSe
             signatureFactory = XMLSignatureFactory.getInstance("DOM");
         }
     }
-   
+
     /**
      * Initialize a WSSec Signature.
-     * 
+     *
      * The method sets up and initializes a WSSec Signature structure after the
      * relevant information was set. After setup of the references to elements
      * to sign may be added. After all references are added they can be signed.
-     * 
+     *
      * This method does not add the Signature element to the security header.
      * See <code>prependSignatureElementToHeader()</code> method.
-     * 
+     *
      * @param doc The SOAP envelope as <code>Document</code>
      * @param cr An instance of the Crypto API to handle keystore and certificates
      * @param secHeader The security header that will hold the Signature. This is used
@@ -150,7 +150,7 @@ public class WSSecSignature extends WSSe
         wsDocInfo = new WSDocInfo(doc);
         wsDocInfo.setCrypto(cr);
         securityHeader = secHeader.getSecurityHeader();
-        
+
         //
         // At first get the security token (certificate) according to the parameters.
         //
@@ -159,11 +159,11 @@ public class WSSecSignature extends WSSe
         try {
             C14NMethodParameterSpec c14nSpec = null;
             if (addInclusivePrefixes && canonAlgo.equals(WSConstants.C14N_EXCL_OMIT_COMMENTS)) {
-                List<String> prefixes = 
+                List<String> prefixes =
                     getInclusivePrefixes(secHeader.getSecurityHeader(), false);
                 c14nSpec = new ExcC14NParameterSpec(prefixes);
             }
-            
+
            c14nMethod = signatureFactory.newCanonicalizationMethod(canonAlgo, c14nSpec);
         } catch (Exception ex) {
             LOG.error("", ex);
@@ -179,11 +179,11 @@ public class WSSecSignature extends WSSe
             secRef.addWSSENamespace();
             secRef.addWSUNamespace();
             secRef.setID(strUri);
-            
+
             //
             // Get an initialized XMLSignature element.
             //
-            
+
             //
             // Prepare and setup the token references for this Signature
             //
@@ -191,7 +191,7 @@ public class WSSecSignature extends WSSe
             case WSConstants.BST_DIRECT_REFERENCE:
                 Reference ref = new Reference(document);
                 ref.setURI("#" + certUri);
-                
+
                 addBST(certs);
                 if (!useSingleCert) {
                     secRef.addTokenType(PKIPathSecurity.PKI_TYPE);
@@ -201,40 +201,40 @@ public class WSSecSignature extends WSSe
                 }
                 secRef.setReference(ref);
                 break;
-    
+
             case WSConstants.ISSUER_SERIAL:
                 String issuer = certs[0].getIssuerX500Principal().getName();
                 java.math.BigInteger serialNumber = certs[0].getSerialNumber();
-                DOMX509IssuerSerial domIssuerSerial = 
+                DOMX509IssuerSerial domIssuerSerial =
                     new DOMX509IssuerSerial(doc, issuer, serialNumber);
                 DOMX509Data domX509Data = new DOMX509Data(doc, domIssuerSerial);
                 secRef.setUnknownElement(domX509Data.getElement());
-                
+
                 if (includeSignatureToken) {
                     addBST(certs);
                 }
                 break;
-    
+
             case WSConstants.X509_KEY_IDENTIFIER:
                 secRef.setKeyIdentifier(certs[0]);
                 break;
-    
+
             case WSConstants.SKI_KEY_IDENTIFIER:
                 secRef.setKeyIdentifierSKI(certs[0], crypto);
-                
+
                 if (includeSignatureToken) {
                     addBST(certs);
                 }
                 break;
-    
+
             case WSConstants.THUMBPRINT_IDENTIFIER:
                 secRef.setKeyIdentifierThumb(certs[0]);
-                
+
                 if (includeSignatureToken) {
                     addBST(certs);
                 }
                 break;
-                
+
             case WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER:
                 if (encrKeySha1value != null) {
                     secRef.setKeyIdentifierEncKeySHA1(encrKeySha1value);
@@ -244,7 +244,7 @@ public class WSSecSignature extends WSSe
                 }
                 secRef.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
                 break;
-    
+
             case WSConstants.CUSTOM_SYMM_SIGNING :
                 Reference refCust = new Reference(document);
                 if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customTokenValueType)) {
@@ -264,7 +264,7 @@ public class WSSecSignature extends WSSe
                 refCust.setURI("#" + customTokenId);
                 secRef.setReference(refCust);
                 break;
-    
+
             case WSConstants.CUSTOM_SYMM_SIGNING_DIRECT :
                 Reference refCustd = new Reference(document);
                 if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customTokenValueType)) {
@@ -284,7 +284,7 @@ public class WSSecSignature extends WSSe
                 refCustd.setURI(customTokenId);
                 secRef.setReference(refCustd);
                 break;
-                
+
             case WSConstants.CUSTOM_KEY_IDENTIFIER:
                 if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customTokenValueType)) {
                     secRef.setKeyIdentifier(customTokenValueType, customTokenId);
@@ -301,16 +301,16 @@ public class WSSecSignature extends WSSe
                 } else if (WSConstants.WSS_KRB_KI_VALUE_TYPE.equals(customTokenValueType)) {
                     secRef.setKeyIdentifier(customTokenValueType, customTokenId, true);
                     secRef.addTokenType(WSConstants.WSS_GSS_KRB_V5_AP_REQ);
-                } 
+                }
                 break;
-                
+
             case WSConstants.KEY_VALUE:
                 java.security.PublicKey publicKey = certs[0].getPublicKey();
-                
+
                 try {
                     KeyInfoFactory keyInfoFactory = signatureFactory.getKeyInfoFactory();
                     KeyValue keyValue = keyInfoFactory.newKeyValue(publicKey);
-                    keyInfo = 
+                    keyInfo =
                         keyInfoFactory.newKeyInfo(
                             java.util.Collections.singletonList(keyValue), keyInfoUri
                         );
@@ -325,28 +325,28 @@ public class WSSecSignature extends WSSe
                 throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "unsupportedKeyId");
             }
         }
-        
+
         if (keyIdentifierType != WSConstants.KEY_VALUE) {
             XMLStructure structure = new DOMStructure(secRef.getElement());
             wsDocInfo.addTokenElement(secRef.getElement(), false);
             KeyInfoFactory keyInfoFactory = signatureFactory.getKeyInfoFactory();
-            keyInfo = 
+            keyInfo =
                 keyInfoFactory.newKeyInfo(
                     java.util.Collections.singletonList(structure), keyInfoUri
                 );
         }
     }
-    
-    
+
+
     /**
      * Builds a signed soap envelope.
-     * 
+     *
      * This is a convenience method and for backward compatibility. The method
      * creates a Signature and puts it into the Security header. It does so by
      * calling the single functions in order to perform a <i>one shot signature</i>.
      * This method is compatible with the build method of the previous version
      * with the exception of the additional WSSecHeader parameter.
-     * 
+     *
      * @param doc The unsigned SOAP envelope as <code>Document</code>
      * @param cr An instance of the Crypto API to handle keystore and certificates
      * @param secHeader the security header element to hold the encrypted key element.
@@ -372,11 +372,11 @@ public class WSSecSignature extends WSSe
             }
         }
 
-        List<javax.xml.crypto.dsig.Reference> referenceList = 
+        List<javax.xml.crypto.dsig.Reference> referenceList =
             addReferencesToSign(getParts(), secHeader);
 
         computeSignature(referenceList);
-        
+
         //
         // if we have a BST prepend it in front of the Signature according to
         // strict layout rules.
@@ -387,27 +387,27 @@ public class WSSecSignature extends WSSe
 
         return doc;
     }
-    
-    
+
+
     /**
      * This method adds references to the Signature.
-     * 
+     *
      * @param references The list of references to sign
      * @param secHeader The Security Header
      * @throws WSSecurityException
      */
     public List<javax.xml.crypto.dsig.Reference> addReferencesToSign(
-        List<WSEncryptionPart> references, 
+        List<WSEncryptionPart> references,
         WSSecHeader secHeader
     ) throws WSSecurityException {
-        return 
+        return
             addReferencesToSign(
-                document, 
+                document,
                 references,
                 wsDocInfo,
-                signatureFactory, 
-                secHeader, 
-                addInclusivePrefixes, 
+                signatureFactory,
+                secHeader,
+                addInclusivePrefixes,
                 digestAlgo
             );
     }
@@ -423,17 +423,17 @@ public class WSSecSignature extends WSSe
                 securityHeader, WSConstants.SIG_LN, WSConstants.SIG_NS
             );
     }
-    
+
     /**
      * Add a BinarySecurityToken
      */
     private void addBST(X509Certificate[] certs) throws WSSecurityException {
         if (storeBytesInAttachment) {
-            bstToken = 
+            bstToken =
                 document.createElementNS(WSS4JConstants.WSSE_NS, "wsse:BinarySecurityToken");
             bstToken.setAttributeNS(null, "EncodingType", WSS4JConstants.BASE64_ENCODING);
             bstToken.setAttributeNS(WSS4JConstants.WSU_NS, WSS4JConstants.WSU_PREFIX + ":Id", certUri);
-            
+
             byte[] certBytes = null;
             if (!useSingleCert) {
                 bstToken.setAttributeNS(null, "ValueType", PKIPathSecurity.PKI_TYPE);
@@ -448,9 +448,9 @@ public class WSSecSignature extends WSSe
                     );
                 }
             }
-            
+
             final String attachmentId = getIdAllocator().createId("", document);
-            WSSecurityUtil.storeBytesInAttachment(bstToken, document, attachmentId, 
+            WSSecurityUtil.storeBytesInAttachment(bstToken, document, attachmentId,
                                                   certBytes, attachmentCallbackHandler);
             wsDocInfo.addTokenElement(bstToken, false);
         } else {
@@ -466,18 +466,18 @@ public class WSSecSignature extends WSSe
             bstToken = binarySecurity.getElement();
             wsDocInfo.addTokenElement(bstToken, false);
         }
-        
+
         bstAddedToSecurityHeader = false;
     }
-    
+
     /**
      * Prepend the BinarySecurityToken to the elements already in the Security
      * header.
-     * 
+     *
      * The method can be called any time after <code>prepare()</code>.
      * This allows to insert the BST element at any position in the Security
      * header.
-     * 
+     *
      * @param secHeader The security header
      */
     public void prependBSTElementToHeader(WSSecHeader secHeader) {
@@ -488,7 +488,7 @@ public class WSSecSignature extends WSSe
     }
 
     /**
-     * Append the BinarySecurityToken to the security header. 
+     * Append the BinarySecurityToken to the security header.
      * @param secHeader The security header
      */
     public void appendBSTElementToHeader(WSSecHeader secHeader) {
@@ -498,38 +498,38 @@ public class WSSecSignature extends WSSe
             bstAddedToSecurityHeader = true;
         }
     }
-    
+
     /**
-     * Compute the Signature over the references. The signature element will be 
+     * Compute the Signature over the references. The signature element will be
      * prepended to the security header.
-     * 
+     *
      * This method can be called any time after the references were set. See
      * <code>addReferencesToSign()</code>.
-     * 
+     *
      * @param referenceList The list of references to sign
-     * 
+     *
      * @throws WSSecurityException
      */
     public void computeSignature(
-        List<javax.xml.crypto.dsig.Reference> referenceList 
+        List<javax.xml.crypto.dsig.Reference> referenceList
     ) throws WSSecurityException {
         computeSignature(referenceList, true, null);
     }
-    
+
     /**
      * Compute the Signature over the references.
-     * 
+     *
      * This method can be called any time after the references were set. See
      * <code>addReferencesToSign()</code>.
-     * 
+     *
      * @param referenceList The list of references to sign
      * @param prepend Whether to prepend the signature element to the security header
      * @param siblingElement If prepending, then prepend before this sibling Element
-     * 
+     *
      * @throws WSSecurityException
      */
     public void computeSignature(
-        List<javax.xml.crypto.dsig.Reference> referenceList, 
+        List<javax.xml.crypto.dsig.Reference> referenceList,
         boolean prepend,
         Element siblingElement
     ) throws WSSecurityException {
@@ -540,18 +540,18 @@ public class WSSecSignature extends WSSe
             } else {
                 key = KeyUtils.prepareSecretKey(sigAlgo, secretKey);
             }
-            SignatureMethod signatureMethod = 
+            SignatureMethod signatureMethod =
                 signatureFactory.newSignatureMethod(sigAlgo, null);
-            SignedInfo signedInfo = 
+            SignedInfo signedInfo =
                 signatureFactory.newSignedInfo(c14nMethod, signatureMethod, referenceList);
-            
+
             sig = signatureFactory.newXMLSignature(
-                    signedInfo, 
+                    signedInfo,
                     keyInfo,
                     null,
                     getIdAllocator().createId("SIG-", null),
                     null);
-            
+
             //
             // Figure out where to insert the signature element
             //
@@ -561,7 +561,7 @@ public class WSSecSignature extends WSSe
                     Node child = securityHeader.getFirstChild();
                     while (child != null && child.getNodeType() != Node.ELEMENT_NODE) {
                         child = child.getNextSibling();
-                    } 
+                    }
                     siblingElement = (Element)child;
                 }
                 if (siblingElement == null) {
@@ -572,21 +572,21 @@ public class WSSecSignature extends WSSe
             } else {
                 signContext = new DOMSignContext(key, securityHeader);
             }
-            
+
             signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
             if (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
                 signContext.putNamespacePrefix(
-                    WSConstants.C14N_EXCL_OMIT_COMMENTS, 
+                    WSConstants.C14N_EXCL_OMIT_COMMENTS,
                     WSConstants.C14N_EXCL_OMIT_COMMENTS_PREFIX
                 );
             }
             signContext.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
             wsDocInfo.setCallbackLookup(callbackLookup);
-            
+
             // Add the elements to sign to the Signature Context
             wsDocInfo.setTokensOnContext((DOMSignContext)signContext);
             sig.sign(signContext);
-            
+
             signatureValue = sig.getSignatureValue().getValue();
         } catch (Exception ex) {
             LOG.error(ex.getMessage(), ex);
@@ -595,10 +595,10 @@ public class WSSecSignature extends WSSe
             );
         }
     }
-    
+
     /**
      * Set the single cert flag.
-     * 
+     *
      * @param useSingleCert
      */
     public void setUseSingleCertificate(boolean useSingleCert) {
@@ -607,7 +607,7 @@ public class WSSecSignature extends WSSe
 
     /**
      * Get the single cert flag.
-     * 
+     *
      * @return A boolean if single certificate is set.
      */
     public boolean isUseSingleCertificate() {
@@ -616,11 +616,11 @@ public class WSSecSignature extends WSSe
 
     /**
      * Set the name (uri) of the signature encryption algorithm to use.
-     * 
+     *
      * If the algorithm is not set then an automatic detection of the signature
      * algorithm to use is performed during the <code>prepare()</code>
      * method. Refer to WSConstants which algorithms are supported.
-     * 
+     *
      * @param algo the name of the signature algorithm
      * @see WSConstants#RSA
      * @see WSConstants#DSA
@@ -631,11 +631,11 @@ public class WSSecSignature extends WSSe
 
     /**
      * Get the name (uri) of the signature algorithm that is being used.
-     * 
+     *
      * Call this method after <code>prepare</code> to get the information
      * which signature algorithm was automatically detected if no signature
      * algorithm was preset.
-     * 
+     *
      * @return the identifier URI of the signature algorithm
      */
     public String getSignatureAlgorithm() {
@@ -644,11 +644,11 @@ public class WSSecSignature extends WSSe
 
     /**
      * Set the canonicalization method to use.
-     * 
+     *
      * If the canonicalization method is not set then the recommended Exclusive
      * XML Canonicalization is used by default. Refer to WSConstants which
      * algorithms are supported.
-     * 
+     *
      * @param algo Is the name of the signature algorithm
      * @see WSConstants#C14N_OMIT_COMMENTS
      * @see WSConstants#C14N_WITH_COMMENTS
@@ -661,10 +661,10 @@ public class WSSecSignature extends WSSe
 
     /**
      * Get the canonicalization method.
-     * 
+     *
      * If the canonicalization method was not set then Exclusive XML
      * Canonicalization is used by default.
-     * 
+     *
      * @return The string describing the canonicalization algorithm.
      */
     public String getSigCanonicalization() {
@@ -679,22 +679,22 @@ public class WSSecSignature extends WSSe
     }
 
     /**
-     * Set the string that defines which digest algorithm to use. 
+     * Set the string that defines which digest algorithm to use.
      * The default is WSConstants.SHA1.
-     * 
+     *
      * @param digestAlgo the digestAlgo to set
      */
     public void setDigestAlgo(String digestAlgo) {
         this.digestAlgo = digestAlgo;
     }
-    
-    
+
+
     /**
      * Returns the computed Signature value.
-     * 
+     *
      * Call this method after <code>computeSignature()</code> or <code>build()</code>
      * methods were called.
-     * 
+     *
      * @return Returns the signatureValue.
      */
     public byte[] getSignatureValue() {
@@ -703,9 +703,9 @@ public class WSSecSignature extends WSSe
 
     /**
      * Get the id generated during <code>prepare()</code>.
-     * 
+     *
      * Returns the the value of wsu:Id attribute of the Signature element.
-     * 
+     *
      * @return Return the wsu:Id of this token or null if <code>prepare()</code>
      *         was not called before.
      */
@@ -715,11 +715,11 @@ public class WSSecSignature extends WSSe
         }
         return sig.getId();
     }
-    
+
     /**
      * Get the id of the BST generated  during <code>prepare()</code>.
-     * 
-     * @return Returns the the value of wsu:Id attribute of the 
+     *
+     * @return Returns the the value of wsu:Id attribute of the
      * BinaruSecurityToken element.
      */
     public String getBSTTokenId() {
@@ -728,7 +728,7 @@ public class WSSecSignature extends WSSe
         }
         return bstToken.getAttributeNS(WSS4JConstants.WSU_NS, "Id");
     }
-    
+
     /**
      * Set the secret key to use
      * @param secretKey the secret key to use
@@ -760,7 +760,7 @@ public class WSSecSignature extends WSSe
     public void setEncrKeySha1value(String encrKeySha1value) {
         this.encrKeySha1value = encrKeySha1value;
     }
-    
+
     /**
      * Set the X509 Certificate to use
      * @param cer the X509 Certificate to use
@@ -768,7 +768,7 @@ public class WSSecSignature extends WSSe
     public void setX509Certificate(X509Certificate cer) {
         this.useThisCert = cer;
     }
-    
+
     /**
      * Returns the BST Token element.
      * The method can be called any time after <code>prepare()</code>.
@@ -777,7 +777,7 @@ public class WSSecSignature extends WSSe
     public Element getBinarySecurityTokenElement() {
         return bstToken;
     }
-    
+
     /**
      * @return the URI associated with the SecurityTokenReference
      * (must be called after {@link #prepare(Document, Crypto, WSSecHeader)}
@@ -785,14 +785,14 @@ public class WSSecSignature extends WSSe
     public String getSecurityTokenReferenceURI() {
         return strUri;
     }
-    
+
     /**
      * Get the SecurityTokenReference to be used in the KeyInfo element.
      */
     public SecurityTokenReference getSecurityTokenReference() {
         return secRef;
     }
-    
+
     /**
      * Set the SecurityTokenReference to be used in the KeyInfo element. If this
      * method is not called, a SecurityTokenRefence will be generated.
@@ -827,7 +827,7 @@ public class WSSecSignature extends WSSe
                         "noUserCertsFound",
                         new Object[] {user, "signature"});
             }
-            certUri = getIdAllocator().createSecureId("X509-", certs[0]);  
+            certUri = getIdAllocator().createSecureId("X509-", certs[0]);
             //
             // If no signature algorithm was set try to detect it according to the
             // data stored in the certificate.
@@ -867,5 +867,5 @@ public class WSSecSignature extends WSSe
     public void setAddInclusivePrefixes(boolean addInclusivePrefixes) {
         this.addInclusivePrefixes = addInclusivePrefixes;
     }
-    
+
 }