cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1050465 - in /cxf/branches/wss4j-1.6-port/rt/ws/security/src: main/java/org/apache/cxf/ws/security/trust/ main/java/org/apache/cxf/ws/security/wss4j/ main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/ test/java/org/apache/cxf/ws/se...
Date Fri, 17 Dec 2010 18:39:32 GMT
Author: coheigea
Date: Fri Dec 17 18:39:32 2010
New Revision: 1050465

URL: http://svn.apache.org/viewvc?rev=1050465&view=rev
Log:
Some changes following a recent merge for WSS-232

Modified:
    cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java
    cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java
    cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenProcessorWithoutCallbacks.java
    cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
    cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
    cxf/branches/wss4j-1.6-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/CustomProcessor.java

Modified: cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java?rev=1050465&r1=1050464&r2=1050465&view=diff
==============================================================================
--- cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java
(original)
+++ cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/trust/STSClient.java
Fri Dec 17 18:39:32 2010
@@ -32,7 +32,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.Vector;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -101,6 +100,7 @@ import org.apache.neethi.ExactlyOne;
 import org.apache.neethi.Policy;
 import org.apache.neethi.PolicyComponent;
 import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.WSDocInfo;
 import org.apache.ws.security.WSSecurityEngineResult;
 import org.apache.ws.security.WSSecurityException;
 import org.apache.ws.security.components.crypto.Crypto;
@@ -883,13 +883,14 @@ public class STSClient implements Config
                 secret = Base64.decode(b64Secret);
             } else if (childQname.equals(new QName(namespace, WSConstants.ENC_KEY_LN))) {
                 try {
-
-                    EncryptedKeyProcessor processor = new EncryptedKeyProcessor();
-
-                    processor.handleToken(child, null, createCrypto(true), createHandler(),
null,
-                                          new Vector<WSSecurityEngineResult>(), null);
-
-                    secret = processor.getDecryptedBytes();
+                    EncryptedKeyProcessor proc = new EncryptedKeyProcessor();
+                    WSDocInfo docInfo = new WSDocInfo(child.getOwnerDocument());
+                    List<WSSecurityEngineResult> result =
+                        proc.handleToken(child, null, createCrypto(true), createHandler(),
docInfo, null);
+                    secret = 
+                        (byte[])result.get(0).get(
+                            WSSecurityEngineResult.TAG_DECRYPTED_KEY
+                        );
                 } catch (IOException e) {
                     throw new TrustException("ENCRYPTED_KEY_ERROR", LOG, e);
                 }

Modified: cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java?rev=1050465&r1=1050464&r2=1050465&view=diff
==============================================================================
--- cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java
(original)
+++ cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java
Fri Dec 17 18:39:32 2010
@@ -57,6 +57,7 @@ import org.apache.cxf.ws.security.policy
 import org.apache.cxf.ws.security.policy.SPConstants;
 import org.apache.cxf.ws.security.policy.model.UsernameToken;
 import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.WSDocInfo;
 import org.apache.ws.security.WSPasswordCallback;
 import org.apache.ws.security.WSSecurityEngineResult;
 import org.apache.ws.security.WSSecurityException;
@@ -164,7 +165,10 @@ public class UsernameTokenInterceptor ex
         Object validateProperty = message.getContextualProperty(SecurityConstants.VALIDATE_PASSWORD);
         if (validateProperty == null || MessageUtils.isTrue(validateProperty)) {
             UsernameTokenProcessor p = new UsernameTokenProcessor();
-            return p.handleUsernameToken(tokenElement, getCallback(message));
+            WSDocInfo wsDocInfo = new WSDocInfo(tokenElement.getOwnerDocument());
+            List<WSSecurityEngineResult> results = 
+                p.handleToken(tokenElement, null, null, getCallback(message), wsDocInfo,
null);
+            return (WSUsernameTokenPrincipal)results.get(0).get(WSSecurityEngineResult.TAG_PRINCIPAL);
         } else {
             return parseTokenAndCreatePrincipal(tokenElement);
         }

Modified: cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenProcessorWithoutCallbacks.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenProcessorWithoutCallbacks.java?rev=1050465&r1=1050464&r2=1050465&view=diff
==============================================================================
--- cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenProcessorWithoutCallbacks.java
(original)
+++ cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenProcessorWithoutCallbacks.java
Fri Dec 17 18:39:32 2010
@@ -49,22 +49,20 @@ public class UsernameTokenProcessorWitho
     private static final Logger LOG = 
         LogUtils.getL7dLogger(UsernameTokenProcessorWithoutCallbacks.class);
     
-    private String utId;
     private UsernameToken ut;
     
-    public void handleToken(Element elem, Crypto crypto, Crypto decCrypto, CallbackHandler
cb, 
-        WSDocInfo wsDocInfo, List<WSSecurityEngineResult> returnResults, WSSConfig
wsc
+    public List<WSSecurityEngineResult> handleToken(Element elem, Crypto crypto, Crypto
decCrypto, 
+        CallbackHandler cb, WSDocInfo wsDocInfo, WSSConfig wsc
     ) throws WSSecurityException {
         if (LOG.isLoggable(Level.FINE)) {
             LOG.fine("Found UsernameToken list element");
         }
         
         Principal principal = handleUsernameToken(elem, cb);
-        returnResults.add(
-            0, 
-            new WSSecurityEngineResult(WSConstants.UT, principal, null, null, null)
-        );
-        utId = ut.getID();
+        WSSecurityEngineResult result = 
+            new WSSecurityEngineResult(WSConstants.UT, principal, null, null, null);
+        result.put(WSSecurityEngineResult.TAG_ID, ut.getID());
+        return java.util.Collections.singletonList(result);
     }
     
     private WSUsernameTokenPrincipal handleUsernameToken(
@@ -101,7 +99,4 @@ public class UsernameTokenProcessorWitho
         return principal;
     }
     
-    public String getId() {
-        return utId;
-    }
 }

Modified: cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java?rev=1050465&r1=1050464&r2=1050465&view=diff
==============================================================================
--- cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
(original)
+++ cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
Fri Dec 17 18:39:32 2010
@@ -467,7 +467,7 @@ public class AsymmetricBindingHandler ex
              */
             for (WSSecurityEngineResult wser : wsSecEngineResults) {
                 Integer actInt = (Integer)wser.get(WSSecurityEngineResult.TAG_ACTION);
-                String encrKeyId = (String)wser.get(WSSecurityEngineResult.TAG_ENCRYPTED_KEY_ID);
+                String encrKeyId = (String)wser.get(WSSecurityEngineResult.TAG_ID);
                 if (actInt.intValue() == WSConstants.ENCR && encrKeyId != null) {
                     return encrKeyId;
                 }

Modified: cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java?rev=1050465&r1=1050464&r2=1050465&view=diff
==============================================================================
--- cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
(original)
+++ cxf/branches/wss4j-1.6-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
Fri Dec 17 18:39:32 2010
@@ -762,12 +762,10 @@ public class SymmetricBindingHandler ext
             
             for (WSSecurityEngineResult wser : wsSecEngineResults) {
                 Integer actInt = (Integer)wser.get(WSSecurityEngineResult.TAG_ACTION);
+                String encryptedKeyID = (String)wser.get(WSSecurityEngineResult.TAG_ID);
                 if (actInt.intValue() == WSConstants.ENCR
-                    && wser.get(WSSecurityEngineResult.TAG_ENCRYPTED_KEY_ID) != null
-                    && ((String)wser.get(WSSecurityEngineResult.TAG_ENCRYPTED_KEY_ID)).length()
!= 0) {
-                        
-                    String encryptedKeyID = (String)wser.get(WSSecurityEngineResult.TAG_ENCRYPTED_KEY_ID);
-
+                    && encryptedKeyID != null
+                    && encryptedKeyID.length() != 0) {
                     Date created = new Date();
                     Date expires = new Date();
                     expires.setTime(created.getTime() + 300000);

Modified: cxf/branches/wss4j-1.6-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/CustomProcessor.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j-1.6-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/CustomProcessor.java?rev=1050465&r1=1050464&r2=1050465&view=diff
==============================================================================
--- cxf/branches/wss4j-1.6-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/CustomProcessor.java
(original)
+++ cxf/branches/wss4j-1.6-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/CustomProcessor.java
Fri Dec 17 18:39:32 2010
@@ -32,14 +32,13 @@ import org.apache.ws.security.processor.
  */
 public class CustomProcessor implements Processor {
     
-    public final void 
+    public final java.util.List<WSSecurityEngineResult> 
     handleToken(
         final org.w3c.dom.Element elem, 
         final Crypto crypto, 
         final Crypto decCrypto,
         final javax.security.auth.callback.CallbackHandler cb, 
         final WSDocInfo wsDocInfo, 
-        final java.util.List<WSSecurityEngineResult> returnResults,
         final WSSConfig config
     ) throws WSSecurityException {
         final WSSecurityEngineResult result = 
@@ -48,10 +47,7 @@ public class CustomProcessor implements 
                 (SecurityContextToken) null
             );
         result.put("foo", this);
-        returnResults.add(result);
+        return java.util.Collections.singletonList(result);
     }
 
-    public final String getId() {
-        return getClass().getName();
-    }
 }



Mime
View raw message