ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1468893 - in /webservices/wss4j/branches/1_6_x-fixes/src: main/java/org/apache/ws/security/message/ test/java/org/apache/ws/security/message/
Date Wed, 17 Apr 2013 13:11:02 GMT
Author: coheigea
Date: Wed Apr 17 13:11:01 2013
New Revision: 1468893

URL: http://svn.apache.org/r1468893
Log:
[WSS-434] - Add ValueType attribute to a Signature/Encryption Reference to a DerivedKeyToken

Modified:
    webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/message/WSSecDKEncrypt.java
    webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/message/WSSecDKSign.java
    webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/message/WSSecDerivedKeyBase.java
    webservices/wss4j/branches/1_6_x-fixes/src/test/java/org/apache/ws/security/message/DerivedKeyTest.java

Modified: webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/message/WSSecDKEncrypt.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/message/WSSecDKEncrypt.java?rev=1468893&r1=1468892&r2=1468893&view=diff
==============================================================================
--- webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/message/WSSecDKEncrypt.java
(original)
+++ webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/message/WSSecDKEncrypt.java
Wed Apr 17 13:11:01 2013
@@ -23,6 +23,7 @@ import org.apache.ws.security.WSConstant
 import org.apache.ws.security.WSEncryptionPart;
 import org.apache.ws.security.WSSConfig;
 import org.apache.ws.security.WSSecurityException;
+import org.apache.ws.security.conversation.ConversationConstants;
 import org.apache.ws.security.conversation.ConversationException;
 import org.apache.ws.security.message.token.Reference;
 import org.apache.ws.security.message.token.SecurityTokenReference;
@@ -108,7 +109,12 @@ public class WSSecDKEncrypt extends WSSe
     public Element encryptForExternalRef(Element dataRef, List<WSEncryptionPart> references)
         throws WSSecurityException {
         
-        KeyInfo keyInfo = createKeyInfo();
+        KeyInfo keyInfo = null;
+        try {
+            keyInfo = createKeyInfo();
+        } catch (ConversationException ex) {
+            throw new WSSecurityException(ex.getMessage(), ex);
+        }
         SecretKey key = WSSecurityUtil.prepareSecretKey(symEncAlgo, derivedKeyBytes);
 
         List<String> encDataRefs = 
@@ -126,13 +132,18 @@ public class WSSecDKEncrypt extends WSSe
     
     /**
      * Create a KeyInfo object
+     * @throws ConversationException 
      */
-    private KeyInfo createKeyInfo() throws WSSecurityException {
+    private KeyInfo createKeyInfo() throws WSSecurityException, ConversationException {
         KeyInfo keyInfo = new KeyInfo(document);
         SecurityTokenReference secToken = new SecurityTokenReference(document);
         secToken.addWSSENamespace();
         Reference ref = new Reference(document);
         ref.setURI("#" + dktId);
+        String ns = 
+            ConversationConstants.getWSCNs(getWscVersion()) 
+                + ConversationConstants.TOKEN_TYPE_DERIVED_KEY_TOKEN;
+        ref.setValueType(ns);
         secToken.setReference(ref);
 
         keyInfo.addUnknownElement(secToken.getElement());

Modified: webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/message/WSSecDKSign.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/message/WSSecDKSign.java?rev=1468893&r1=1468892&r2=1468893&view=diff
==============================================================================
--- webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/message/WSSecDKSign.java
(original)
+++ webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/message/WSSecDKSign.java
Wed Apr 17 13:11:01 2013
@@ -24,6 +24,7 @@ import org.apache.ws.security.WSDocInfo;
 import org.apache.ws.security.WSEncryptionPart;
 import org.apache.ws.security.WSSConfig;
 import org.apache.ws.security.WSSecurityException;
+import org.apache.ws.security.conversation.ConversationConstants;
 import org.apache.ws.security.conversation.ConversationException;
 import org.apache.ws.security.message.token.Reference;
 import org.apache.ws.security.message.token.SecurityTokenReference;
@@ -168,9 +169,13 @@ public class WSSecDKSign extends WSSecDe
         strUri = getWsConfig().getIdAllocator().createSecureId("STR-", secRef);
         secRef.setID(strUri);
         
-        Reference refUt = new Reference(document);
-        refUt.setURI("#" + dktId);
-        secRef.setReference(refUt);
+        Reference ref = new Reference(document);
+        ref.setURI("#" + dktId);
+        String ns = 
+            ConversationConstants.getWSCNs(getWscVersion()) 
+            + ConversationConstants.TOKEN_TYPE_DERIVED_KEY_TOKEN;
+        ref.setValueType(ns);
+        secRef.setReference(ref);
         
         XMLStructure structure = new DOMStructure(secRef.getElement());
         wsDocInfo.addTokenElement(secRef.getElement(), false);

Modified: webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/message/WSSecDerivedKeyBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/message/WSSecDerivedKeyBase.java?rev=1468893&r1=1468892&r2=1468893&view=diff
==============================================================================
--- webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/message/WSSecDerivedKeyBase.java
(original)
+++ webservices/wss4j/branches/1_6_x-fixes/src/main/java/org/apache/ws/security/message/WSSecDerivedKeyBase.java
Wed Apr 17 13:11:01 2013
@@ -305,6 +305,10 @@ public abstract class WSSecDerivedKeyBas
         this.wscVersion = wscVersion;
     }
     
+    public int getWscVersion() {
+        return wscVersion;
+    }
+    
     public Element getdktElement() {
         return dkt.getElement();
     }

Modified: webservices/wss4j/branches/1_6_x-fixes/src/test/java/org/apache/ws/security/message/DerivedKeyTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/1_6_x-fixes/src/test/java/org/apache/ws/security/message/DerivedKeyTest.java?rev=1468893&r1=1468892&r2=1468893&view=diff
==============================================================================
--- webservices/wss4j/branches/1_6_x-fixes/src/test/java/org/apache/ws/security/message/DerivedKeyTest.java
(original)
+++ webservices/wss4j/branches/1_6_x-fixes/src/test/java/org/apache/ws/security/message/DerivedKeyTest.java
Wed Apr 17 13:11:01 2013
@@ -154,7 +154,7 @@ public class DerivedKeyTest extends org.
         encrKeyBuilder.prependBSTElementToHeader(secHeader);
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Encrypted message: 3DES  + DerivedKeys");
+            LOG.debug("Signed message: 3DES  + DerivedKeys");
             String outputString = 
                 org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
             LOG.debug(outputString);



Mime
View raw message