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/06/22 12:31:59 UTC

svn commit: r1686833 - in /webservices/wss4j/branches/2_0_x-fixes: ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/ConversationConstants.java ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java

Author: coheigea
Date: Mon Jun 22 10:31:59 2015
New Revision: 1686833

URL: http://svn.apache.org/r1686833
Log:
[WSS-542] - Secure Conversation Renew is missing Instance creation. Thanks to Freddy Exposito for the patch.


Conflicts:
	ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java

Modified:
    webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/ConversationConstants.java
    webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java

Modified: webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/ConversationConstants.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/ConversationConstants.java?rev=1686833&r1=1686832&r2=1686833&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/ConversationConstants.java (original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/derivedKey/ConversationConstants.java Mon Jun 22 10:31:59 2015
@@ -68,6 +68,11 @@ public final class ConversationConstants
      * Field IDENTIFIER_LN
      */
     public static final String IDENTIFIER_LN = "Identifier";
+    
+    /**
+     * Field INSTANCE_LN
+     */
+    public static final String INSTANCE_LN = "Instance";
 
     /**
      * Field EXPIRES_LN

Modified: webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java?rev=1686833&r1=1686832&r2=1686833&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java (original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/SecurityContextToken.java Mon Jun 22 10:31:59 2015
@@ -46,6 +46,11 @@ public class SecurityContextToken {
     private Element elementIdentifier;
     
     private WSSConfig wssConfig;
+
+    /**
+     * Instance element
+     */
+    private Element elementInstance;
     
     private String tokenType = WSConstants.WSC_SCT;
     
@@ -120,7 +125,23 @@ public class SecurityContextToken {
             tokenType = WSConstants.WSC_SCT_05_12;
         }
     }
-
+    
+    /**
+     * Constructor to create the SCT with a given uuid and instance
+     *
+     * @param doc
+     */
+    public SecurityContextToken(int version, Document doc, String uuid, String instance)
+        throws WSSecurityException {
+        this(version, doc, uuid);
+        
+        if (instance != null) {
+            String ns = ConversationConstants.getWSCNs(version);
+            elementInstance = doc.createElementNS(ns, ConversationConstants.INSTANCE_LN);
+            element.appendChild(elementInstance);
+            elementInstance.appendChild(doc.createTextNode(instance));
+        }
+    }
     
     /**
      * This is used to create a SecurityContextToken using a DOM Element
@@ -147,6 +168,13 @@ public class SecurityContextToken {
                 ConversationConstants.IDENTIFIER_LN,
                 el.getNamespaceURI()
             );
+        
+        elementInstance = 
+            WSSecurityUtil.getDirectChildElement(
+                element, 
+                ConversationConstants.INSTANCE_LN,
+                el.getNamespaceURI()
+            );
     }
     
     /**
@@ -176,7 +204,22 @@ public class SecurityContextToken {
         }
         return null;
     }
-    
+
+    /**
+     * Get the instance.
+     *
+     * @return the data from the instance element.
+     */
+    public String getInstance() {
+        if (elementInstance != null) {
+            Text text = getFirstNode(elementInstance);
+            if (text != null) {
+                return text.getData();
+            }
+        }
+        return null;
+    }
+
     /**
      * Get the WS-Trust tokenType String associated with this token
      */