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 ru...@apache.org on 2007/10/05 13:29:45 UTC

svn commit: r582215 - in /webservices/wss4j/trunk/src/org/apache/ws/security: WSConstants.java message/token/SecurityTokenReference.java processor/SignatureProcessor.java

Author: ruchithf
Date: Fri Oct  5 04:29:43 2007
New Revision: 582215

URL: http://svn.apache.org/viewvc?rev=582215&view=rev
Log:
Applied Nandana's patch for WSS-89, Thanks Nandana


Modified:
    webservices/wss4j/trunk/src/org/apache/ws/security/WSConstants.java
    webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityTokenReference.java
    webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.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=582215&r1=582214&r2=582215&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/WSConstants.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/WSConstants.java Fri Oct  5 04:29:43 2007
@@ -57,6 +57,13 @@
      * The SAMLAssertionID relative URI string (without #)
      */
     public static final String SAML_ASSERTION_ID = "SAMLAssertionID";
+    
+    /*
+     * The EncryptedKeyToken value type URI used in wsse:Reference 
+     */
+    public static final String ENC_KEY_VALUE_TYPE_NS = "http://docs.oasis-open.org/wss/2005/xx/oasis-2005xx-wss-soap-message-security-1.1#";
+    public static final String ENC_KEY_VALUE_TYPE = "EncryptedKey";
+    
     /*
      * The namespace prefixes used. We uses the same prefix convention
      * as shown in the specifications
@@ -390,4 +397,3 @@
     public static final String WST_NS = "http://schemas.xmlsoap.org/ws/2005/02/trust";
 
 }
-

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=582215&r1=582214&r2=582215&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 Oct  5 04:29:43 2007
@@ -201,7 +201,13 @@
             }
             tokElement = sa;
         } else {
+            
             tokElement = WSSecurityUtil.getElementByWsuId(doc, uri);
+            
+            // In some scenarios id is used rather than wsu:Id
+            if (tokElement == null) {
+                tokElement = WSSecurityUtil.getElementByGenId(doc, uri);
+            }
         }
         if (tokElement == null) {
             throw new WSSecurityException(WSSecurityException.SECURITY_TOKEN_UNAVAILABLE,
@@ -290,11 +296,11 @@
         createKeyIdentifier(doc, THUMB_URI, text);
     }
     
-	public void setSAMLKeyIdentifier(String keyIdVal)
-			throws WSSecurityException {
-		Document doc = this.element.getOwnerDocument();
+    public void setSAMLKeyIdentifier(String keyIdVal)
+            throws WSSecurityException {
+        Document doc = this.element.getOwnerDocument();
         createKeyIdentifier(doc, SAML_ID_URI, doc.createTextNode(keyIdVal));
-	}
+    }
 
     private void createKeyIdentifier(Document doc, String uri, Node node) {
         
@@ -312,6 +318,26 @@
             this.element.appendChild(keyId);
         }
     }
+    /*
+     * Several helper and utility methods.
+     */
+    
+    /**
+     * get the first child element.
+     *
+     * @return the first <code>Element</code> child node
+     */
+    public Element getFirstElement() {
+        for (Node currentChild = this.element.getFirstChild();
+             currentChild != null;
+             currentChild = currentChild.getNextSibling()) {
+            if (currentChild instanceof Element) {
+                return (Element) currentChild;
+            }
+        }
+        return null;
+    }
+
     /**
      * Gets the KeyIdentifer.
      *
@@ -492,36 +518,6 @@
     /*
      * Several helper and utility methods.
      */
-
-    /**
-     * get the first child element.
-     *
-     * @return the first <code>Element</code> child node
-     */
-    public Element getFirstElement() {
-        for (Node currentChild = this.element.getFirstChild();
-             currentChild != null;
-             currentChild = currentChild.getNextSibling()) {
-            if (currentChild instanceof Element) {
-                return (Element) currentChild;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Method containsKeyName
-     *
-     * @return true if the <code>SecurtityTokenReference</code> contains
-     *         a <code>wsse:KeyName</code> element
-     */
-//    public boolean containsKeyName() {
-//        return element.getLocalName().equals(KEY_NAME);
-//    }
-//
-//    public String getKeyNameValue() {
-//        return element.getFirstChild().getNodeValue();
-//    }
 
     /**
      * Method containsReference

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java?rev=582215&r1=582214&r2=582215&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java Fri Oct  5 04:29:43 2007
@@ -235,7 +235,12 @@
                         
                         certs = samlKi.getCerts();
                         secretKey = samlKi.getSecret();
-                    } else {
+                    } else if (el.equals(WSSecurityEngine.ENCRYPTED_KEY)){
+                        EncryptedKeyProcessor encryptKeyProcessor = new EncryptedKeyProcessor();
+                        encryptKeyProcessor.handleEncryptedKey((Element)token, cb, crypto);
+                        secretKey = encryptKeyProcessor.getDecryptedBytes();
+                     
+                    }else {
                         
                         //Try custom token through callback handler
                       //try to find a custom token



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