Author: ruchithf
Date: Fri Nov  9 00:49:03 2007
New Revision: 593455

URL: http://svn.apache.org/viewvc?rev=593455&view=rev
Log:
A security context token can be used to encrypt/sign a msg ... made sure we 
support that.


Modified:
    webservices/wss4j/trunk/src/org/apache/ws/security/WSConstants.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncrypt.java
    
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncryptedKey.java
    
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityTokenReference.java

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/WSConstants.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/WSConstants.java?rev=593455&r1=593454&r2=593455&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/WSConstants.java 
(original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/WSConstants.java Fri Nov 
 9 00:49:03 2007
@@ -414,5 +414,7 @@
      * WS-Trust namespace
      */
     public static final String WST_NS = 
"http://schemas.xmlsoap.org/ws/2005/02/trust";;
-
+    
+    public final static String WSC_SCT = 
"http://schemas.xmlsoap.org/ws/2005/02/sc/sct";;
+    
 }

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=593455&r1=593454&r2=593455&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 
Fri Nov  9 00:49:03 2007
@@ -83,6 +83,11 @@
      * or not.
      */
     private boolean encryptSymmKey = true;
+    
+    /**
+     * Custom reference value
+     */
+    private String customReferenceValue;
 
     /**
      * Constructor.
@@ -434,10 +439,14 @@
        // Prepare KeyInfo if useKeyIdentifier is set
        if ( useKeyIdentifier && 
                         keyIdentifierType == 
WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER) {
-            
                keyInfo = new KeyInfo(document);
             SecurityTokenReference secToken = new 
SecurityTokenReference(document);
-            
secToken.setKeyIdentifierEncKeySHA1(getSHA1(encryptedEphemeralKey));
+            if(this.customReferenceValue != null) {
+                secToken.setKeyIdentifierEncKeySHA1(this.customReferenceValue);
+            } else {
+                
secToken.setKeyIdentifierEncKeySHA1(getSHA1(encryptedEphemeralKey));
+            }
+            
 
             keyInfo.addUnknownElement(secToken.getElement());
        } 
@@ -492,14 +501,14 @@
             boolean content = modifier.equals("Content") ? true : false;
             String xencEncryptedDataId = "EncDataId-" + body.hashCode();
 
+            cloneKeyInfo = true;
+            
             if(keyInfo == null) {
-                cloneKeyInfo = true;
                 keyInfo = new KeyInfo(document);
                 SecurityTokenReference secToken = new 
SecurityTokenReference(document);
                 Reference ref = new Reference(document);
                 ref.setURI("#" + encKeyId);
                 secToken.setReference(ref);
-    
                 keyInfo.addUnknownElement(secToken.getElement());
             }
             /*
@@ -542,7 +551,8 @@
                     xmlCipher.doFinal(doc, body, content);             
                }
                 if(cloneKeyInfo) {
-                    keyInfo = null;
+                    keyInfo = new KeyInfo((Element) keyInfo.getElement()
+                            .cloneNode(true), null);
                 }
             } catch (Exception e2) {
                 throw new WSSecurityException(
@@ -735,6 +745,10 @@
             throw new WSSecurityException(
                     WSSecurityException.UNSUPPORTED_ALGORITHM, null, null, e);
         }
+    }
+
+    public void setCustomReferenceValue(String customReferenceValue) {
+        this.customReferenceValue = customReferenceValue;
     }
     
 }

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncryptedKey.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncryptedKey.java?rev=593455&r1=593454&r2=593455&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncryptedKey.java
 (original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncryptedKey.java
 Fri Nov  9 00:49:03 2007
@@ -505,5 +505,4 @@
         return encryptedEphemeralKey;
     }
     
-    
 }

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=593455&r1=593454&r2=593455&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
 Fri Nov  9 00:49:03 2007
@@ -162,7 +162,10 @@
         Element tokElement = null;
         String tmpS = WSConstants.WSS_SAML_NS + WSConstants.WSS_SAML_ASSERTION;
         String saml10 = WSConstants.WSS_SAML_NS + 
WSConstants.SAML_ASSERTION_ID;
-        if (tmpS.equals(ref.getValueType()) || 
saml10.equals(ref.getValueType())) {
+        
+        if (tmpS.equals(ref.getValueType())
+                || saml10.equals(ref.getValueType())
+                || WSConstants.WSC_SCT.equals(ref.getValueType())) {
             Element sa = docInfo.getAssertion();
             String saID = null;
             if (sa != null) {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to