You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wss4j-dev@ws.apache.org by co...@apache.org on 2009/04/08 12:57:24 UTC

svn commit: r763177 - in /webservices/wss4j/trunk: ./ src/org/apache/ws/security/message/ src/org/apache/ws/security/message/token/ test/wssec/

Author: coheigea
Date: Wed Apr  8 10:57:23 2009
New Revision: 763177

URL: http://svn.apache.org/viewvc?rev=763177&view=rev
Log:
[WSS-173] - Remove unnecessary namespace definitions
 - UsernameToken, SecurityTokenReference and Reference types do not have the wsse namespace defined by default now
 - Care must be taken using the SecurityTokenReference in the SOAP Body as it must have the wsse namespace defined then
 - The security header always defines the wsu namespace from now on.
 - As a result the Timestamp, and UsernameToken child elements do not define it.

Modified:
    webservices/wss4j/trunk/pom.xml
    webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKEncrypt.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncrypt.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignatureConfirmation.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/token/BinarySecurity.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/token/DerivedKeyToken.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Reference.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityContextToken.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityTokenReference.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SignatureConfirmation.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/token/UsernameToken.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew3.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew7.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNewSCT.java

Modified: webservices/wss4j/trunk/pom.xml
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/pom.xml?rev=763177&r1=763176&r2=763177&view=diff
==============================================================================
--- webservices/wss4j/trunk/pom.xml (original)
+++ webservices/wss4j/trunk/pom.xml Wed Apr  8 10:57:23 2009
@@ -379,7 +379,7 @@
         <bcprov.jdk15.version>140</bcprov.jdk15.version>
         <commons.logging.version>1.1</commons.logging.version>
         <xalan.version>2.7.1</xalan.version>
-        <xerces.version>2.8.1</xerces.version>
+        <xerces.version>2.9.1</xerces.version>
         <axis.version>1.4</axis.version>
         <junit.version>3.8.1</junit.version>
     </properties>

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKEncrypt.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKEncrypt.java?rev=763177&r1=763176&r2=763177&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKEncrypt.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKEncrypt.java Wed Apr  8 10:57:23 2009
@@ -136,6 +136,7 @@
                 // Create the SecurityTokenRef to the DKT
                 KeyInfo keyInfo = new KeyInfo(document);
                 SecurityTokenReference secToken = new SecurityTokenReference(document);
+                secToken.addWSSENamespace();
                 Reference ref = new Reference(document);
                 ref.setURI("#" + dktId);
                 secToken.setReference(ref);

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncrypt.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncrypt.java?rev=763177&r1=763176&r2=763177&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncrypt.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncrypt.java Wed Apr  8 10:57:23 2009
@@ -426,6 +426,7 @@
             keyIdentifierType == WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER) {
             keyInfo = new KeyInfo(document);
             SecurityTokenReference secToken = new SecurityTokenReference(document);
+            secToken.addWSSENamespace();
             if (this.customReferenceValue != null) {
                 secToken.setKeyIdentifierEncKeySHA1(this.customReferenceValue);
             } else {
@@ -461,6 +462,7 @@
         if (keyInfo == null) {
             keyInfo = new KeyInfo(document);
             SecurityTokenReference secToken = new SecurityTokenReference(document);
+            secToken.addWSSENamespace();
             Reference ref = new Reference(document);
             if (encKeyIdDirectId) {
                 ref.setURI(encKeyId);

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java?rev=763177&r1=763176&r2=763177&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java Wed Apr  8 10:57:23 2009
@@ -169,6 +169,8 @@
                 mustUnderstandLocal
             );
         }
+        WSSecurityUtil.setNamespace(securityHeader, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
+        
         return securityHeader;
     }
     

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignatureConfirmation.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignatureConfirmation.java?rev=763177&r1=763176&r2=763177&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignatureConfirmation.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignatureConfirmation.java Wed Apr  8 10:57:23 2009
@@ -31,8 +31,7 @@
  */
 
 public class WSSecSignatureConfirmation extends WSSecBase {
-    private static Log log = LogFactory.getLog(WSSecSignatureConfirmation.class
-            .getName());
+    private static Log log = LogFactory.getLog(WSSecSignatureConfirmation.class.getName());
 
     private SignatureConfirmation sc = null;
 

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/BinarySecurity.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/BinarySecurity.java?rev=763177&r1=763176&r2=763177&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/BinarySecurity.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/BinarySecurity.java Wed Apr  8 10:57:23 2009
@@ -91,10 +91,25 @@
      */
     public BinarySecurity(Document doc) {
         this.element = doc.createElementNS(WSConstants.WSSE_NS, "wsse:BinarySecurityToken");
-        WSSecurityUtil.setNamespace(this.element, WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX);
         setEncodingType(BASE64_ENCODING);
         this.element.appendChild(doc.createTextNode(""));
     }
+    
+    /**
+     * Add the WSSE Namespace to this BST. The namespace is not added by default for
+     * efficiency purposes.
+     */
+    public void addWSSENamespace() {
+        WSSecurityUtil.setNamespace(this.element, WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX);
+    }
+    
+    /**
+     * Add the WSU Namespace to this BST. The namespace is not added by default for
+     * efficiency purposes.
+     */
+    public void addWSUNamespace() {
+        WSSecurityUtil.setNamespace(element, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
+    }
 
     /**
      * get the value type.
@@ -196,9 +211,7 @@
      * @param id 
      */
     public void setID(String id) {
-        String prefix = 
-            WSSecurityUtil.setNamespace(this.element, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
-        this.element.setAttributeNS(WSConstants.WSU_NS, prefix + ":Id", id);
+        this.element.setAttributeNS(WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":Id", id);
     }
 
     /**

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/DerivedKeyToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/DerivedKeyToken.java?rev=763177&r1=763176&r2=763177&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/DerivedKeyToken.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/DerivedKeyToken.java Wed Apr  8 10:57:23 2009
@@ -144,6 +144,14 @@
                 this.element, ConversationConstants.NONCE_LN, this.ns
             );
     }
+    
+    /**
+     * Add the WSU Namespace to this DKT. The namespace is not added by default for
+     * efficiency purposes.
+     */
+    public void addWSUNamespace() {
+        WSSecurityUtil.setNamespace(element, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
+    }
 
     /**
      * Sets the security token reference of the derived key token
@@ -437,9 +445,7 @@
      *           DerivedKeyToken
      */
     public void setID(String id) {
-        String prefix = 
-            WSSecurityUtil.setNamespace(this.element, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
-        this.element.setAttributeNS(WSConstants.WSU_NS, prefix + ":Id", id);
+        this.element.setAttributeNS(WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":Id", id);
     }
 
     /**

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Reference.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Reference.java?rev=763177&r1=763176&r2=763177&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Reference.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Reference.java Wed Apr  8 10:57:23 2009
@@ -63,8 +63,14 @@
      * @param doc 
      */
     public Reference(Document doc) {
-        this.element =
-            doc.createElementNS(WSConstants.WSSE_NS, "wsse:Reference");
+        this.element = doc.createElementNS(WSConstants.WSSE_NS, "wsse:Reference");
+    }
+    
+    /**
+     * Add the WSSE Namespace to this reference. The namespace is not added by default for
+     * efficiency purposes, as the reference is embedded in a wsse:SecurityTokenReference.
+     */
+    public void addWSSENamespace() {
         WSSecurityUtil.setNamespace(this.element, WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX);
     }
 

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityContextToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityContextToken.java?rev=763177&r1=763176&r2=763177&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityContextToken.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityContextToken.java Wed Apr  8 10:57:23 2009
@@ -114,6 +114,7 @@
         this.elementIdentifier.appendChild(doc.createTextNode(uuid));
     }
 
+    
     /**
      * This is used to create a SecurityContextToken using a DOM Element
      *
@@ -142,6 +143,14 @@
                 el.getNamespaceURI()
             );
     }
+    
+    /**
+     * Add the WSU Namespace to this SCT. The namespace is not added by default for
+     * efficiency purposes.
+     */
+    public void addWSUNamespace() {
+        WSSecurityUtil.setNamespace(element, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
+    }
 
     /**
      * Set the identifier.
@@ -214,9 +223,7 @@
      *           SecurityContextToken
      */
     public void setID(String id) {
-        String prefix = 
-            WSSecurityUtil.setNamespace(this.element, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
-        this.element.setAttributeNS(WSConstants.WSU_NS, prefix + ":Id", id);
+        this.element.setAttributeNS(WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":Id", id);
     }
 
 }

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityTokenReference.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityTokenReference.java?rev=763177&r1=763176&r2=763177&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityTokenReference.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityTokenReference.java Wed Apr  8 10:57:23 2009
@@ -91,9 +91,15 @@
      */
     public SecurityTokenReference(Document doc) {
         doDebug = log.isDebugEnabled();
-        this.element =
-                doc.createElementNS(WSConstants.WSSE_NS, "wsse:SecurityTokenReference");
-        WSSecurityUtil.setNamespace(this.element, WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX);        
+        this.element = doc.createElementNS(WSConstants.WSSE_NS, "wsse:SecurityTokenReference");
+    }
+    
+    /**
+     * Add the WSSE Namespace to this STR. The namespace is not added by default for
+     * efficiency purposes.
+     */
+    public void addWSSENamespace() {
+        WSSecurityUtil.setNamespace(this.element, WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX);
     }
 
     /**
@@ -753,11 +759,8 @@
      * @param id
      */
     public void setID(String id) {
-        String prefix =
-                WSSecurityUtil.setNamespace(
-                    this.element, WSConstants.WSU_NS, WSConstants.WSU_PREFIX
-                );
-        this.element.setAttributeNS(WSConstants.WSU_NS, prefix + ":Id", id);
+        WSSecurityUtil.setNamespace(element, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
+        this.element.setAttributeNS(WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":Id", id);
     }
 
     /**

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SignatureConfirmation.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SignatureConfirmation.java?rev=763177&r1=763176&r2=763177&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SignatureConfirmation.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SignatureConfirmation.java Wed Apr  8 10:57:23 2009
@@ -73,7 +73,14 @@
             String sv = Base64.encode(signVal);
             element.setAttribute(VALUE, sv);
         }
-
+    }
+    
+    /**
+     * Add the WSU Namespace to this SC. The namespace is not added by default for
+     * efficiency purposes.
+     */
+    public void addWSUNamespace() {
+        WSSecurityUtil.setNamespace(element, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
     }
 
     /**
@@ -99,9 +106,7 @@
      * @param id
      */
     public void setID(String id) {
-        String prefix = 
-            WSSecurityUtil.setNamespace(this.element, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
-        this.element.setAttributeNS(WSConstants.WSU_NS, prefix + ":Id", id);
+        this.element.setAttributeNS(WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":Id", id);
     }
     
     /**

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java?rev=763177&r1=763176&r2=763177&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java Wed Apr  8 10:57:23 2009
@@ -123,7 +123,6 @@
             doc.createElementNS(
                 WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":" + WSConstants.TIMESTAMP_TOKEN_LN
             );
-        WSSecurityUtil.setNamespace(element, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
 
         DateFormat zulu = null;
         if (milliseconds) {
@@ -154,6 +153,14 @@
             element.appendChild(elementExpires);
         }
     }
+    
+    /**
+     * Add the WSU Namespace to this T. The namespace is not added by default for
+     * efficiency purposes.
+     */
+    public void addWSUNamespace() {
+        WSSecurityUtil.setNamespace(element, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
+    }
 
     /**
      * Get the current time

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/UsernameToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/UsernameToken.java?rev=763177&r1=763176&r2=763177&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/UsernameToken.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/UsernameToken.java Wed Apr  8 10:57:23 2009
@@ -189,7 +189,6 @@
     public UsernameToken(boolean milliseconds, Document doc, String pwType) {
         element = 
             doc.createElementNS(WSConstants.WSSE_NS, "wsse:" + WSConstants.USERNAME_TOKEN_LN);
-        WSSecurityUtil.setNamespace(element, WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX);
 
         elementUsername = 
             doc.createElementNS(WSConstants.WSSE_NS, "wsse:" + WSConstants.USERNAME_LN);
@@ -211,6 +210,22 @@
             }
         }
     }
+    
+    /**
+     * Add the WSSE Namespace to this UT. The namespace is not added by default for
+     * efficiency purposes.
+     */
+    public void addWSSENamespace() {
+        WSSecurityUtil.setNamespace(this.element, WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX);
+    }
+    
+    /**
+     * Add the WSU Namespace to this UT. The namespace is not added by default for
+     * efficiency purposes.
+     */
+    public void addWSUNamespace() {
+        WSSecurityUtil.setNamespace(this.element, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
+    }
 
     /**
      * Creates and adds a Nonce element to this UsernameToken
@@ -244,9 +259,8 @@
         Calendar rightNow = Calendar.getInstance();
         elementCreated = 
             doc.createElementNS(
-                WSConstants.WSU_NS,WSConstants.WSU_PREFIX + ":" + WSConstants.CREATED_LN
+                WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":" + WSConstants.CREATED_LN
             );
-        WSSecurityUtil.setNamespace(element, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
         elementCreated.appendChild(doc.createTextNode(zulu.format(rightNow.getTime())));
         element.appendChild(elementCreated);
     }
@@ -532,9 +546,7 @@
      *            username token
      */
     public void setID(String id) {
-        String prefix = 
-            WSSecurityUtil.setNamespace(element, WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
-        element.setAttributeNS(WSConstants.WSU_NS, prefix + ":Id", id);
+        element.setAttributeNS(WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":Id", id);
     }
 
     /**

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew3.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew3.java?rev=763177&r1=763176&r2=763177&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew3.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew3.java Wed Apr  8 10:57:23 2009
@@ -27,6 +27,7 @@
 import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSPasswordCallback;
 import org.apache.ws.security.WSSecurityEngine;
 import org.apache.ws.security.components.crypto.Crypto;
@@ -120,16 +121,75 @@
      * 
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
+    public void testIssuerSerialSignature() throws Exception {
+        WSSecSignature builder = new WSSecSignature();
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        LOG.info("Before Signing....");
+        Document doc = unsignedEnvelope.getAsDocument();
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        Document signedDoc = builder.build(doc, crypto, secHeader);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After Signing....");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
+            LOG.debug(outputString);
+        }
+        
+        verify(signedDoc);
+    }
+    
+    /**
+     * Test that signs and verifies a WS-Security envelope
+     * <p/>
+     * 
+     * @throws java.lang.Exception Thrown when there is any problem in signing or verification
+     */
+    public void testBSTSignature() throws Exception {
+        WSSecSignature builder = new WSSecSignature();
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+        LOG.info("Before Signing....");
+        Document doc = unsignedEnvelope.getAsDocument();
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        Document signedDoc = builder.build(doc, crypto, secHeader);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After Signing....");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
+            LOG.debug(outputString);
+        }
+        
+        verify(signedDoc);
+    }
+    
+    
+    /**
+     * Test that signs and verifies a WS-Security envelope
+     * <p/>
+     * 
+     * @throws java.lang.Exception Thrown when there is any problem in signing or verification
+     */
     public void testX509Signature() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        builder.setKeyIdentifierType(WSConstants.X509_KEY_IDENTIFIER);
         LOG.info("Before Signing....");
         Document doc = unsignedEnvelope.getAsDocument();
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         Document signedDoc = builder.build(doc, crypto, secHeader);
 
-        LOG.info("After Signing....");
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After Signing....");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
+            LOG.debug(outputString);
+        }
+        
         verify(signedDoc);
     }
 

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew7.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew7.java?rev=763177&r1=763176&r2=763177&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew7.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew7.java Wed Apr  8 10:57:23 2009
@@ -114,7 +114,7 @@
 
     /**
      * Test that encrypt and then again encrypts (Super encryption) WS-Security
-     * envelope and then verifies ist <p/>
+     * envelope and then verifies it <p/>
      * 
      * @throws Exception
      *             Thrown when there is any problem in encryption or
@@ -130,8 +130,22 @@
         secHeader.insertSecurityHeader(doc);
 
         Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
-        Document encryptedEncryptedDoc = encrypt.build(encryptedDoc, crypto,
-                secHeader);
+        
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After the first encryption:");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
+            LOG.debug(outputString);
+        }
+        
+        Document encryptedEncryptedDoc = encrypt.build(encryptedDoc, crypto, secHeader);
+        
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After the second encryption:");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedEncryptedDoc);
+            LOG.debug(outputString);
+        }
 
         LOG.info("After Encryption....");
         verify(encryptedEncryptedDoc);

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNewSCT.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNewSCT.java?rev=763177&r1=763176&r2=763177&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNewSCT.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNewSCT.java Wed Apr  8 10:57:23 2009
@@ -33,6 +33,8 @@
 import org.apache.axis.client.AxisClient;
 import org.apache.axis.configuration.NullProvider;
 import org.apache.axis.message.SOAPEnvelope;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSPasswordCallback;
 import org.apache.ws.security.WSSecurityEngine;
@@ -54,6 +56,7 @@
  * @author Ruchith Fernando (ruchith.fernando@gmail.com)
  */
 public class TestWSSecurityNewSCT extends TestCase implements CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(TestWSSecurityNewSCT.class);
 
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
@@ -109,6 +112,10 @@
 
             String out = 
                 org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
+            
+            if (LOG.isDebugEnabled()) {
+                LOG.debug(out);
+            }
 
             assertTrue(
                 "SecurityContextToken missing",
@@ -119,8 +126,6 @@
                 out.indexOf(ConversationConstants.IDENTIFIER_LN) > 0
             );
 
-            // System.out.println(out);
-
         } catch (Exception e) {
             e.printStackTrace();
             fail(e.getMessage());
@@ -158,9 +163,10 @@
 
             sctBuilder.prependSCTElementToHeader(doc, secHeader);
 
-            // String out = org.apache.ws.security.util.XMLUtils
-            //          .PrettyDocumentToString(doc);
-            // System.out.println(out);
+            if (LOG.isDebugEnabled()) {
+                String out = org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
+                LOG.debug(out);
+            }
 
             verify(doc);
         } catch (Exception e) {
@@ -196,9 +202,10 @@
             
             sctBuilder.prependSCTElementToHeader(doc, secHeader);
 
-//            String out = org.apache.ws.security.util.XMLUtils
-//                     .PrettyDocumentToString(doc);
-//            System.out.println(out);
+            if (LOG.isDebugEnabled()) {
+                String out = org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
+                LOG.debug(out);
+            }
 
             verify(doc);
         } catch (Exception e) {
@@ -240,10 +247,10 @@
 
             sctBuilder.prependSCTElementToHeader(doc, secHeader);
 
-//            String out = org.apache.ws.security.util.XMLUtils
-//                     .PrettyDocumentToString(doc);
-
-//            System.out.println(out);
+            if (LOG.isDebugEnabled()) {
+                String out = org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
+                LOG.debug(out);
+            }
 
             verify(doc);
         } catch (Exception e) {
@@ -285,9 +292,10 @@
 
             sctBuilder.prependSCTElementToHeader(doc, secHeader);
 
-//            String out = org.apache.ws.security.util.XMLUtils
-//                     .PrettyDocumentToString(doc);
-//            System.out.println(out);
+            if (LOG.isDebugEnabled()) {
+                String out = org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
+                LOG.debug(out);
+            }
 
             verify(doc);
         } catch (Exception e) {
@@ -307,8 +315,7 @@
         secEngine.processSecurityHeader(doc, null, this, crypto);
         String outputString = 
             org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
-        assertTrue(outputString.indexOf("LogTestService2") > 0 ? true
-                : false);
+        assertTrue(outputString.indexOf("LogTestService2") > 0 ? true : false);
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org