cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1303443 - in /cxf/trunk/services/sts: sts-core/src/main/java/org/apache/cxf/sts/operation/ sts-core/src/main/java/org/apache/cxf/sts/token/validator/ sts-core/src/test/java/org/apache/cxf/sts/operation/ sts-core/src/test/java/org/apache/cx...
Date Wed, 21 Mar 2012 15:30:03 GMT
Author: coheigea
Date: Wed Mar 21 15:30:02 2012
New Revision: 1303443

URL: http://svn.apache.org/viewvc?rev=1303443&view=rev
Log:
Changed the TokenValidatorParameter and Response objects to contain the obtain to validate / the object that was validated directly

Modified:
    cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java
    cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java
    cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/SAMLTokenValidator.java
    cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/SCTValidator.java
    cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/TokenValidatorParameters.java
    cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/TokenValidatorResponse.java
    cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/UsernameTokenValidator.java
    cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/X509TokenValidator.java
    cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/DummyTokenValidator.java
    cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorCachedRealmTest.java
    cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorRealmTest.java
    cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorTest.java
    cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SCTValidatorTest.java
    cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/UsernameTokenValidatorTest.java
    cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/X509TokenValidatorTest.java
    cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/deployment/CustomBSTTokenValidator.java
    cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameTokenValidator.java

Modified: cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java (original)
+++ cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java Wed Mar 21 15:30:02 2012
@@ -537,6 +537,7 @@ public abstract class AbstractOperation 
         validatorParameters.setTokenStore(getTokenStore());
         validatorParameters.setKeyRequirements(null);
         validatorParameters.setTokenRequirements(validateRequirements);
+        validatorParameters.setToken(token);
 
         TokenValidatorResponse tokenResponse = null;
         for (TokenValidator tokenValidator : tokenValidators) {
@@ -549,9 +550,7 @@ public abstract class AbstractOperation 
             if (canHandle) {
                 try {
                     tokenResponse = tokenValidator.validateToken(validatorParameters);
-                    token.setValidationState(
-                            tokenResponse.isValid() ? STATE.VALID : STATE.INVALID
-                    );
+                    token = tokenResponse.getToken();
                     // The parsed principal is set if available. It's up to other components to
                     // deal with the STATE of the validation
                     token.setPrincipal(tokenResponse.getPrincipal());

Modified: cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java (original)
+++ cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java Wed Mar 21 15:30:02 2012
@@ -32,6 +32,7 @@ import org.apache.cxf.sts.RealmParser;
 import org.apache.cxf.sts.STSConstants;
 import org.apache.cxf.sts.claims.RequestClaimCollection;
 import org.apache.cxf.sts.request.ReceivedToken;
+import org.apache.cxf.sts.request.ReceivedToken.STATE;
 import org.apache.cxf.sts.request.RequestParser;
 import org.apache.cxf.sts.request.TokenRequirements;
 import org.apache.cxf.sts.token.provider.TokenProvider;
@@ -104,7 +105,8 @@ public class TokenValidateOperation exte
         if (tokenResponse == null) {
             LOG.fine("No Token Validator has been found that can handle this token");
             tokenResponse = new TokenValidatorResponse();
-            tokenResponse.setValid(false);
+            validateTarget.setValidationState(STATE.INVALID);
+            tokenResponse.setToken(validateTarget);
         }
         
         //
@@ -112,7 +114,8 @@ public class TokenValidateOperation exte
         //
         TokenProviderResponse tokenProviderResponse = null;
         String tokenType = tokenRequirements.getTokenType();
-        if (tokenResponse.isValid() && !STSConstants.STATUS.equals(tokenType)) {
+        if (tokenResponse.getToken().getValidationState() == STATE.VALID 
+            && !STSConstants.STATUS.equals(tokenType)) {
             TokenProviderParameters providerParameters = 
                  createTokenProviderParameters(requestParser, context);
             
@@ -182,7 +185,7 @@ public class TokenValidateOperation exte
         }
         
         // TokenType
-        boolean valid = tokenResponse.isValid();
+        boolean valid = tokenResponse.getToken().getValidationState() == STATE.VALID;
         String tokenType = tokenRequirements.getTokenType();
         if (valid || STSConstants.STATUS.equals(tokenType)) {
             JAXBElement<String> jaxbTokenType = 

Modified: cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/SAMLTokenValidator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/SAMLTokenValidator.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/SAMLTokenValidator.java (original)
+++ cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/SAMLTokenValidator.java Wed Mar 21 15:30:02 2012
@@ -35,7 +35,7 @@ import org.apache.cxf.common.logging.Log
 import org.apache.cxf.sts.STSConstants;
 import org.apache.cxf.sts.STSPropertiesMBean;
 import org.apache.cxf.sts.request.ReceivedToken;
-import org.apache.cxf.sts.request.TokenRequirements;
+import org.apache.cxf.sts.request.ReceivedToken.STATE;
 import org.apache.cxf.sts.token.realm.CertConstraintsParser;
 import org.apache.cxf.sts.token.realm.SAMLRealmCodec;
 import org.apache.cxf.ws.security.tokenstore.SecurityToken;
@@ -124,16 +124,16 @@ public class SAMLTokenValidator implemen
      */
     public TokenValidatorResponse validateToken(TokenValidatorParameters tokenParameters) {
         LOG.fine("Validating SAML Token");
-        TokenRequirements tokenRequirements = tokenParameters.getTokenRequirements();
-        ReceivedToken validateTarget = tokenRequirements.getValidateTarget();
         STSPropertiesMBean stsProperties = tokenParameters.getStsProperties();
         Crypto sigCrypto = stsProperties.getSignatureCrypto();
         CallbackHandler callbackHandler = stsProperties.getCallbackHandler();
         
         TokenValidatorResponse response = new TokenValidatorResponse();
-        response.setValid(false);
+        ReceivedToken validateTarget = tokenParameters.getToken();
+        validateTarget.setValidationState(STATE.INVALID);
+        response.setToken(validateTarget);
         
-        if (validateTarget == null || !validateTarget.isDOMElement()) {
+        if (!validateTarget.isDOMElement()) {
             return response;
         }
         
@@ -236,7 +236,7 @@ public class SAMLTokenValidator implemen
             response.setAdditionalProperties(addProps);
             
             response.setTokenRealm(tokenRealm);
-            response.setValid(true);
+            validateTarget.setValidationState(STATE.VALID);
         } catch (WSSecurityException ex) {
             LOG.log(Level.WARNING, "", ex);
         }

Modified: cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/SCTValidator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/SCTValidator.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/SCTValidator.java (original)
+++ cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/SCTValidator.java Wed Mar 21 15:30:02 2012
@@ -29,7 +29,7 @@ import org.w3c.dom.Element;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.sts.STSConstants;
 import org.apache.cxf.sts.request.ReceivedToken;
-import org.apache.cxf.sts.request.TokenRequirements;
+import org.apache.cxf.sts.request.ReceivedToken.STATE;
 
 import org.apache.cxf.ws.security.tokenstore.SecurityToken;
 import org.apache.cxf.ws.security.trust.STSUtils;
@@ -84,20 +84,17 @@ public class SCTValidator implements Tok
     public TokenValidatorResponse validateToken(TokenValidatorParameters tokenParameters) {
         LOG.fine("Validating SecurityContextToken");
         
+        TokenValidatorResponse response = new TokenValidatorResponse();
+        ReceivedToken validateTarget = tokenParameters.getToken();
+        validateTarget.setValidationState(STATE.INVALID);
+        response.setToken(validateTarget);
+        
         if (tokenParameters.getTokenStore() == null) {
             LOG.log(Level.FINE, "A cache must be configured to use the SCTValidator");
-            TokenValidatorResponse response = new TokenValidatorResponse();
-            response.setValid(false);
             return response;
         }
         
-        TokenRequirements tokenRequirements = tokenParameters.getTokenRequirements();
-        ReceivedToken validateTarget = tokenRequirements.getValidateTarget();
-
-        TokenValidatorResponse response = new TokenValidatorResponse();
-        response.setValid(false);
-        
-        if (validateTarget != null && validateTarget.isDOMElement()) {
+        if (validateTarget.isDOMElement()) {
             try {
                 Element validateTargetElement = (Element)validateTarget.getToken();
                 SecurityContextToken sct = new SecurityContextToken(validateTargetElement);
@@ -122,7 +119,7 @@ public class SCTValidator implements Tok
                     String realm = props.getProperty(STSConstants.TOKEN_REALM);
                     response.setTokenRealm(realm);
                 }
-                response.setValid(true);
+                validateTarget.setValidationState(STATE.VALID);
             } catch (WSSecurityException ex) {
                 LOG.log(Level.WARNING, "", ex);
             }

Modified: cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/TokenValidatorParameters.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/TokenValidatorParameters.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/TokenValidatorParameters.java (original)
+++ cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/TokenValidatorParameters.java Wed Mar 21 15:30:02 2012
@@ -25,6 +25,7 @@ import javax.xml.ws.WebServiceContext;
 
 import org.apache.cxf.sts.STSPropertiesMBean;
 import org.apache.cxf.sts.request.KeyRequirements;
+import org.apache.cxf.sts.request.ReceivedToken;
 import org.apache.cxf.sts.request.TokenRequirements;
 import org.apache.cxf.ws.security.tokenstore.TokenStore;
 
@@ -42,7 +43,16 @@ public class TokenValidatorParameters {
     private TokenRequirements tokenRequirements;
     private TokenStore tokenStore;
     private String realm;
+    private ReceivedToken token;
     
+    public ReceivedToken getToken() {
+        return token;
+    }
+
+    public void setToken(ReceivedToken token) {
+        this.token = token;
+    }
+
     public TokenStore getTokenStore() {
         return tokenStore;
     }

Modified: cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/TokenValidatorResponse.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/TokenValidatorResponse.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/TokenValidatorResponse.java (original)
+++ cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/TokenValidatorResponse.java Wed Mar 21 15:30:02 2012
@@ -21,22 +21,24 @@ package org.apache.cxf.sts.token.validat
 import java.security.Principal;
 import java.util.Map;
 
+import org.apache.cxf.sts.request.ReceivedToken;
+
 /**
  * This class encapsulates the response from a TokenValidator instance after validating a token.
  */
 public class TokenValidatorResponse {
 
-    private boolean valid;
     private Principal principal;
     private Map<String, Object> additionalProperties;
     private String realm;
+    private ReceivedToken token;
     
-    public void setValid(boolean valid) {
-        this.valid = valid;
+    public ReceivedToken getToken() {
+        return token;
     }
-    
-    public boolean isValid() {
-        return valid;
+
+    public void setToken(ReceivedToken token) {
+        this.token = token;
     }
     
     public void setPrincipal(Principal principal) {

Modified: cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/UsernameTokenValidator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/UsernameTokenValidator.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/UsernameTokenValidator.java (original)
+++ cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/UsernameTokenValidator.java Wed Mar 21 15:30:02 2012
@@ -38,7 +38,7 @@ import org.apache.cxf.sts.QNameConstants
 import org.apache.cxf.sts.STSConstants;
 import org.apache.cxf.sts.STSPropertiesMBean;
 import org.apache.cxf.sts.request.ReceivedToken;
-import org.apache.cxf.sts.request.TokenRequirements;
+import org.apache.cxf.sts.request.ReceivedToken.STATE;
 import org.apache.cxf.sts.token.realm.UsernameTokenRealmCodec;
 
 import org.apache.cxf.ws.security.sts.provider.model.secext.UsernameTokenType;
@@ -107,8 +107,6 @@ public class UsernameTokenValidator impl
      */
     public TokenValidatorResponse validateToken(TokenValidatorParameters tokenParameters) {
         LOG.fine("Validating UsernameToken");
-        TokenRequirements tokenRequirements = tokenParameters.getTokenRequirements();
-        ReceivedToken validateTarget = tokenRequirements.getValidateTarget();
         STSPropertiesMBean stsProperties = tokenParameters.getStsProperties();
         Crypto sigCrypto = stsProperties.getSignatureCrypto();
         CallbackHandler callbackHandler = stsProperties.getCallbackHandler();
@@ -118,11 +116,13 @@ public class UsernameTokenValidator impl
         WSSConfig wssConfig = WSSConfig.getNewInstance();
         requestData.setWssConfig(wssConfig);
         requestData.setCallbackHandler(callbackHandler);
-
-        TokenValidatorResponse response = new TokenValidatorResponse();
-        response.setValid(false);
         
-        if (validateTarget == null || !validateTarget.isUsernameToken()) {
+        TokenValidatorResponse response = new TokenValidatorResponse();
+        ReceivedToken validateTarget = tokenParameters.getToken();
+        validateTarget.setValidationState(STATE.INVALID);
+        response.setToken(validateTarget);
+
+        if (!validateTarget.isUsernameToken()) {
             return response;
         }
         
@@ -197,7 +197,7 @@ public class UsernameTokenValidator impl
             
             response.setPrincipal(principal);
             response.setTokenRealm(tokenRealm);
-            response.setValid(true);
+            validateTarget.setValidationState(STATE.VALID);
         } catch (WSSecurityException ex) {
             LOG.log(Level.WARNING, "", ex);
         }

Modified: cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/X509TokenValidator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/X509TokenValidator.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/X509TokenValidator.java (original)
+++ cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/validator/X509TokenValidator.java Wed Mar 21 15:30:02 2012
@@ -31,7 +31,7 @@ import org.apache.cxf.common.logging.Log
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.sts.STSPropertiesMBean;
 import org.apache.cxf.sts.request.ReceivedToken;
-import org.apache.cxf.sts.request.TokenRequirements;
+import org.apache.cxf.sts.request.ReceivedToken.STATE;
 
 import org.apache.cxf.ws.security.sts.provider.model.secext.BinarySecurityTokenType;
 
@@ -94,9 +94,6 @@ public class X509TokenValidator implemen
      */
     public TokenValidatorResponse validateToken(TokenValidatorParameters tokenParameters) {
         LOG.fine("Validating X.509 Token");
-        TokenRequirements tokenRequirements = tokenParameters.getTokenRequirements();
-        ReceivedToken validateTarget = tokenRequirements.getValidateTarget();
-
         STSPropertiesMBean stsProperties = tokenParameters.getStsProperties();
         Crypto sigCrypto = stsProperties.getSignatureCrypto();
         CallbackHandler callbackHandler = stsProperties.getCallbackHandler();
@@ -107,9 +104,11 @@ public class X509TokenValidator implemen
         requestData.setCallbackHandler(callbackHandler);
 
         TokenValidatorResponse response = new TokenValidatorResponse();
-        response.setValid(false);
+        ReceivedToken validateTarget = tokenParameters.getToken();
+        validateTarget.setValidationState(STATE.INVALID);
+        response.setToken(validateTarget);
         
-        if (validateTarget == null || !validateTarget.isBinarySecurityToken()) {
+        if (!validateTarget.isBinarySecurityToken()) {
             return response;
         }
 
@@ -145,7 +144,7 @@ public class X509TokenValidator implemen
 
             Credential returnedCredential = validator.validate(credential, requestData);
             response.setPrincipal(returnedCredential.getCertificates()[0].getSubjectX500Principal());
-            response.setValid(true);
+            validateTarget.setValidationState(STATE.VALID);
         } catch (WSSecurityException ex) {
             LOG.log(Level.WARNING, "", ex);
         }

Modified: cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/DummyTokenValidator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/DummyTokenValidator.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/DummyTokenValidator.java (original)
+++ cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/DummyTokenValidator.java Wed Mar 21 15:30:02 2012
@@ -20,7 +20,7 @@
 package org.apache.cxf.sts.operation;
 
 import org.apache.cxf.sts.request.ReceivedToken;
-import org.apache.cxf.sts.request.TokenRequirements;
+import org.apache.cxf.sts.request.ReceivedToken.STATE;
 import org.apache.cxf.sts.token.validator.TokenValidator;
 import org.apache.cxf.sts.token.validator.TokenValidatorParameters;
 import org.apache.cxf.sts.token.validator.TokenValidatorResponse;
@@ -49,17 +49,16 @@ public class DummyTokenValidator impleme
     }
 
     public TokenValidatorResponse validateToken(TokenValidatorParameters tokenParameters) {
-        TokenRequirements tokenRequirements = tokenParameters.getTokenRequirements();
-        ReceivedToken validateTarget = tokenRequirements.getValidateTarget();
-        
         TokenValidatorResponse response = new TokenValidatorResponse();
-        response.setValid(false);
+        ReceivedToken validateTarget = tokenParameters.getToken();
+        validateTarget.setValidationState(STATE.INVALID);
+        response.setToken(validateTarget);
         
         if (validateTarget != null && validateTarget.isBinarySecurityToken()) {
             BinarySecurityTokenType binarySecurity = 
                 (BinarySecurityTokenType)validateTarget.getToken();
             if ("12345678".equals(binarySecurity.getValue())) {
-                response.setValid(true);
+                validateTarget.setValidationState(STATE.VALID);
             }
         }
         

Modified: cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorCachedRealmTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorCachedRealmTest.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorCachedRealmTest.java (original)
+++ cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorCachedRealmTest.java Wed Mar 21 15:30:02 2012
@@ -37,6 +37,7 @@ import org.apache.cxf.sts.cache.DefaultI
 import org.apache.cxf.sts.common.PasswordCallbackHandler;
 import org.apache.cxf.sts.request.KeyRequirements;
 import org.apache.cxf.sts.request.ReceivedToken;
+import org.apache.cxf.sts.request.ReceivedToken.STATE;
 import org.apache.cxf.sts.request.TokenRequirements;
 import org.apache.cxf.sts.service.EncryptionProperties;
 import org.apache.cxf.sts.token.provider.SAMLTokenProvider;
@@ -85,6 +86,7 @@ public class SAMLTokenValidatorCachedRea
         
         ReceivedToken validateTarget = new ReceivedToken(samlToken);
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         // Now set the SAMLRealmCodec implementation on the Validator
         SAMLRealmCodec samlRealmCodec = new IssuerSAMLRealmCodec();
@@ -92,7 +94,8 @@ public class SAMLTokenValidatorCachedRea
         
         TokenValidatorResponse validatorResponse = samlTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertTrue(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.VALID);
         assertTrue(validatorResponse.getTokenRealm().equals("A"));
         
     }
@@ -116,6 +119,7 @@ public class SAMLTokenValidatorCachedRea
         
         ReceivedToken validateTarget = new ReceivedToken(samlToken);
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         // Now set the SAMLRealmCodec implementation on the Validator
         SAMLRealmCodec samlRealmCodec = new CacheSAMLRealmCodec();
@@ -123,7 +127,8 @@ public class SAMLTokenValidatorCachedRea
         
         TokenValidatorResponse validatorResponse = samlTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertFalse(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.INVALID);
         assertNull(validatorResponse.getTokenRealm());
         
     }

Modified: cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorRealmTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorRealmTest.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorRealmTest.java (original)
+++ cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorRealmTest.java Wed Mar 21 15:30:02 2012
@@ -36,6 +36,7 @@ import org.apache.cxf.sts.StaticSTSPrope
 import org.apache.cxf.sts.common.PasswordCallbackHandler;
 import org.apache.cxf.sts.request.KeyRequirements;
 import org.apache.cxf.sts.request.ReceivedToken;
+import org.apache.cxf.sts.request.ReceivedToken.STATE;
 import org.apache.cxf.sts.request.TokenRequirements;
 import org.apache.cxf.sts.service.EncryptionProperties;
 import org.apache.cxf.sts.token.provider.SAMLTokenProvider;
@@ -74,12 +75,14 @@ public class SAMLTokenValidatorRealmTest
         
         ReceivedToken validateTarget = new ReceivedToken(samlToken);
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         // Validate the token - no realm is returned
         TokenValidatorResponse validatorResponse = 
             samlTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertTrue(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.VALID);
         assertNull(validatorResponse.getTokenRealm());
 
         // Now set the SAMLRealmCodec implementation on the Validator
@@ -88,7 +91,8 @@ public class SAMLTokenValidatorRealmTest
         
         validatorResponse = samlTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertTrue(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.VALID);
         assertTrue(validatorResponse.getTokenRealm().equals("A"));
             
         Principal principal = validatorResponse.getPrincipal();
@@ -114,12 +118,14 @@ public class SAMLTokenValidatorRealmTest
         
         ReceivedToken validateTarget = new ReceivedToken(samlToken);
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         // Validate the token - no realm is returned
         TokenValidatorResponse validatorResponse = 
             samlTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertTrue(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.VALID);
         assertNull(validatorResponse.getTokenRealm());
 
         // Now set the SAMLRealmCodec implementation on the Validator
@@ -128,7 +134,8 @@ public class SAMLTokenValidatorRealmTest
         
         validatorResponse = samlTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertTrue(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.VALID);
         assertTrue(validatorResponse.getTokenRealm().equals("B"));
             
         Principal principal = validatorResponse.getPrincipal();

Modified: cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorTest.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorTest.java (original)
+++ cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SAMLTokenValidatorTest.java Wed Mar 21 15:30:02 2012
@@ -42,6 +42,7 @@ import org.apache.cxf.sts.common.Passwor
 import org.apache.cxf.sts.request.KeyRequirements;
 import org.apache.cxf.sts.request.Lifetime;
 import org.apache.cxf.sts.request.ReceivedToken;
+import org.apache.cxf.sts.request.ReceivedToken.STATE;
 import org.apache.cxf.sts.request.TokenRequirements;
 import org.apache.cxf.sts.service.EncryptionProperties;
 import org.apache.cxf.sts.token.provider.DefaultConditionsProvider;
@@ -91,13 +92,15 @@ public class SAMLTokenValidatorTest exte
         
         ReceivedToken validateTarget = new ReceivedToken(samlToken);
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         assertTrue(samlTokenValidator.canHandleToken(validateTarget));
         
         TokenValidatorResponse validatorResponse = 
             samlTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertTrue(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.VALID);
         
         Principal principal = validatorResponse.getPrincipal();
         assertTrue(principal != null && principal.getName() != null);
@@ -122,13 +125,15 @@ public class SAMLTokenValidatorTest exte
         
         ReceivedToken validateTarget = new ReceivedToken(samlToken);
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         assertTrue(samlTokenValidator.canHandleToken(validateTarget));
         
         TokenValidatorResponse validatorResponse = 
             samlTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertTrue(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.VALID);
         
         Principal principal = validatorResponse.getPrincipal();
         assertTrue(principal != null && principal.getName() != null);
@@ -153,6 +158,7 @@ public class SAMLTokenValidatorTest exte
         
         ReceivedToken validateTarget = new ReceivedToken(samlToken);
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         assertTrue(samlTokenValidator.canHandleToken(validateTarget));
         
@@ -162,7 +168,8 @@ public class SAMLTokenValidatorTest exte
         TokenValidatorResponse validatorResponse = 
             samlTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertFalse(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.INVALID);
     }
     
     /**
@@ -184,6 +191,7 @@ public class SAMLTokenValidatorTest exte
         
         ReceivedToken validateTarget = new ReceivedToken(samlToken);
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         assertTrue(samlTokenValidator.canHandleToken(validateTarget));
         
@@ -193,7 +201,8 @@ public class SAMLTokenValidatorTest exte
         TokenValidatorResponse validatorResponse = 
             samlTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertFalse(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.INVALID);
     }
 
     
@@ -216,13 +225,15 @@ public class SAMLTokenValidatorTest exte
         
         ReceivedToken validateTarget = new ReceivedToken(samlToken);
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         assertTrue(samlTokenValidator.canHandleToken(validateTarget));
         Thread.sleep(100);
         TokenValidatorResponse validatorResponse = 
             samlTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertFalse("SAML token is invalid", validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.INVALID);
     }
     
     /**
@@ -244,13 +255,15 @@ public class SAMLTokenValidatorTest exte
         
         ReceivedToken validateTarget = new ReceivedToken(samlToken);
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         assertTrue(samlTokenValidator.canHandleToken(validateTarget));
         Thread.sleep(100);
         TokenValidatorResponse validatorResponse = 
             samlTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertFalse("SAML token is invalid", validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.INVALID);
     }
     
     
@@ -274,6 +287,7 @@ public class SAMLTokenValidatorTest exte
         
         ReceivedToken validateTarget = new ReceivedToken(samlToken);
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         assertTrue(samlTokenValidator.canHandleToken(validateTarget));
         List<String> certConstraints = new ArrayList<String>();
@@ -284,14 +298,16 @@ public class SAMLTokenValidatorTest exte
         TokenValidatorResponse validatorResponse = 
             samlTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertTrue(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.VALID);
         
         certConstraints.clear();
         certConstraints.add("XYZ");
         ((SAMLTokenValidator)samlTokenValidator).setSubjectConstraints(certConstraints);
         validatorResponse = samlTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertFalse(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.INVALID);
     }
     
     private TokenValidatorParameters createValidatorParameters() throws WSSecurityException {

Modified: cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SCTValidatorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SCTValidatorTest.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SCTValidatorTest.java (original)
+++ cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/SCTValidatorTest.java Wed Mar 21 15:30:02 2012
@@ -32,6 +32,7 @@ import org.apache.cxf.sts.cache.DefaultI
 import org.apache.cxf.sts.common.PasswordCallbackHandler;
 import org.apache.cxf.sts.request.KeyRequirements;
 import org.apache.cxf.sts.request.ReceivedToken;
+import org.apache.cxf.sts.request.ReceivedToken.STATE;
 import org.apache.cxf.sts.request.TokenRequirements;
 import org.apache.cxf.sts.service.EncryptionProperties;
 import org.apache.cxf.sts.token.provider.SCTProvider;
@@ -67,13 +68,15 @@ public class SCTValidatorTest extends or
         TokenProviderResponse providerResponse = getSecurityContextToken();
         ReceivedToken validateTarget = new ReceivedToken(providerResponse.getToken());
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         assertTrue(sctValidator.canHandleToken(validateTarget));
         
         TokenValidatorResponse validatorResponse = 
             sctValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertTrue(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.VALID);
         assertTrue(
             validatorResponse.getAdditionalProperties().get(SCTValidator.SCT_VALIDATOR_SECRET) != null
         );
@@ -84,7 +87,8 @@ public class SCTValidatorTest extends or
         assertNull(tokenStore.getToken(providerResponse.getTokenId()));
         validatorResponse = sctValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertFalse(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.INVALID);
     }
     
     /**
@@ -101,13 +105,15 @@ public class SCTValidatorTest extends or
         SecurityContextToken sct = new SecurityContextToken(doc);
         ReceivedToken validateTarget = new ReceivedToken(sct.getElement());
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         assertTrue(sctValidator.canHandleToken(validateTarget));
         
         TokenValidatorResponse validatorResponse = 
             sctValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertFalse(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.INVALID);
     }
     
     private TokenProviderResponse getSecurityContextToken() throws Exception {

Modified: cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/UsernameTokenValidatorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/UsernameTokenValidatorTest.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/UsernameTokenValidatorTest.java (original)
+++ cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/UsernameTokenValidatorTest.java Wed Mar 21 15:30:02 2012
@@ -36,6 +36,7 @@ import org.apache.cxf.sts.StaticSTSPrope
 import org.apache.cxf.sts.common.PasswordCallbackHandler;
 import org.apache.cxf.sts.request.KeyRequirements;
 import org.apache.cxf.sts.request.ReceivedToken;
+import org.apache.cxf.sts.request.ReceivedToken.STATE;
 import org.apache.cxf.sts.request.TokenRequirements;
 import org.apache.cxf.ws.security.sts.provider.model.secext.AttributedString;
 import org.apache.cxf.ws.security.sts.provider.model.secext.EncodedString;
@@ -75,6 +76,7 @@ public class UsernameTokenValidatorTest 
         
         ReceivedToken validateTarget = new ReceivedToken(tokenType);
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         assertTrue(usernameTokenValidator.canHandleToken(validateTarget));
         
@@ -82,7 +84,8 @@ public class UsernameTokenValidatorTest 
         TokenValidatorResponse validatorResponse = 
                 usernameTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertFalse(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.INVALID);
 
         // Add a password
         PasswordString password = new PasswordString();
@@ -96,7 +99,8 @@ public class UsernameTokenValidatorTest 
         
         validatorResponse = usernameTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertTrue(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.VALID);
         
         Principal principal = validatorResponse.getPrincipal();
         assertTrue(principal != null && principal.getName() != null);
@@ -133,6 +137,7 @@ public class UsernameTokenValidatorTest 
         
         ReceivedToken validateTarget = new ReceivedToken(tokenType);
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         assertTrue(usernameTokenValidator.canHandleToken(validateTarget));
         
@@ -140,14 +145,16 @@ public class UsernameTokenValidatorTest 
         TokenValidatorResponse validatorResponse = 
             usernameTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertFalse(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.INVALID);
         
         // This will fail as the password is bad
         username.setValue("alice");
         password.setValue("badpassword");
         validatorResponse = usernameTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertFalse(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.INVALID);
     }
     
     /**
@@ -206,13 +213,15 @@ public class UsernameTokenValidatorTest 
         
         ReceivedToken validateTarget = new ReceivedToken(tokenType);
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         assertTrue(usernameTokenValidator.canHandleToken(validateTarget));
         
         TokenValidatorResponse validatorResponse = 
                 usernameTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertTrue(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.VALID);
         
         Principal principal = validatorResponse.getPrincipal();
         assertTrue(principal != null && principal.getName() != null);
@@ -221,7 +230,8 @@ public class UsernameTokenValidatorTest 
         password.setValue("badpassword");
         validatorResponse = usernameTokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertFalse(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.INVALID);
     }
     
     private TokenValidatorParameters createValidatorParameters() throws WSSecurityException {

Modified: cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/X509TokenValidatorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/X509TokenValidatorTest.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/X509TokenValidatorTest.java (original)
+++ cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/validator/X509TokenValidatorTest.java Wed Mar 21 15:30:02 2012
@@ -33,6 +33,7 @@ import org.apache.cxf.sts.StaticSTSPrope
 import org.apache.cxf.sts.common.PasswordCallbackHandler;
 import org.apache.cxf.sts.request.KeyRequirements;
 import org.apache.cxf.sts.request.ReceivedToken;
+import org.apache.cxf.sts.request.ReceivedToken.STATE;
 import org.apache.cxf.sts.request.TokenRequirements;
 import org.apache.cxf.ws.security.sts.provider.model.secext.BinarySecurityTokenType;
 import org.apache.ws.security.CustomTokenPrincipal;
@@ -73,6 +74,7 @@ public class X509TokenValidatorTest exte
         
         ReceivedToken validateTarget = new ReceivedToken(tokenType);
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         // It can't handle the token as the value type is not set
         assertFalse(x509TokenValidator.canHandleToken(validateTarget));
@@ -84,13 +86,14 @@ public class X509TokenValidatorTest exte
         TokenValidatorResponse validatorResponse = null;
         validatorResponse = x509TokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertFalse(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.INVALID);
         
         binarySecurityToken.setEncodingType(WSConstants.SOAPMESSAGE_NS + "#Base64Binary");
         
         validatorResponse = x509TokenValidator.validateToken(validatorParameters);
-        assertTrue(validatorResponse != null);
-        assertTrue(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.VALID);
         
         Principal principal = validatorResponse.getPrincipal();
         assertTrue(principal != null && principal.getName() != null);
@@ -124,12 +127,14 @@ public class X509TokenValidatorTest exte
         
         ReceivedToken validateTarget = new ReceivedToken(tokenType);
         tokenRequirements.setValidateTarget(validateTarget);
+        validatorParameters.setToken(validateTarget);
         
         assertTrue(x509TokenValidator.canHandleToken(validateTarget));
         
         TokenValidatorResponse validatorResponse = x509TokenValidator.validateToken(validatorParameters);
         assertTrue(validatorResponse != null);
-        assertFalse(validatorResponse.isValid());
+        assertTrue(validatorResponse.getToken() != null);
+        assertTrue(validatorResponse.getToken().getValidationState() == STATE.INVALID);
     }
     
     private TokenValidatorParameters createValidatorParameters() throws WSSecurityException {

Modified: cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/deployment/CustomBSTTokenValidator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/deployment/CustomBSTTokenValidator.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/deployment/CustomBSTTokenValidator.java (original)
+++ cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/deployment/CustomBSTTokenValidator.java Wed Mar 21 15:30:02 2012
@@ -20,7 +20,7 @@
 package org.apache.cxf.systest.sts.deployment;
 
 import org.apache.cxf.sts.request.ReceivedToken;
-import org.apache.cxf.sts.request.TokenRequirements;
+import org.apache.cxf.sts.request.ReceivedToken.STATE;
 import org.apache.cxf.sts.token.validator.TokenValidator;
 import org.apache.cxf.sts.token.validator.TokenValidatorParameters;
 import org.apache.cxf.sts.token.validator.TokenValidatorResponse;
@@ -51,21 +51,21 @@ public class CustomBSTTokenValidator imp
     }
     
     public TokenValidatorResponse validateToken(TokenValidatorParameters tokenParameters) {
-        TokenRequirements tokenRequirements = tokenParameters.getTokenRequirements();
-        ReceivedToken validateTarget = tokenRequirements.getValidateTarget();
-        if (validateTarget == null || !validateTarget.isBinarySecurityToken()) {
-            TokenValidatorResponse response = new TokenValidatorResponse();
-            response.setValid(false);
+        TokenValidatorResponse response = new TokenValidatorResponse();
+        ReceivedToken validateTarget = tokenParameters.getToken();
+        validateTarget.setValidationState(STATE.INVALID);
+        response.setToken(validateTarget);
+        
+        if (!validateTarget.isBinarySecurityToken()) {
             return response;
         }
         BinarySecurityTokenType binarySecurityToken = (BinarySecurityTokenType)validateTarget.getToken();
         
-        TokenValidatorResponse response = new TokenValidatorResponse();
         //
         // Do some validation of the token here
         //
         if (Base64.encode("12345678".getBytes()).equals(binarySecurityToken.getValue())) {
-            response.setValid(true);
+            validateTarget.setValidationState(STATE.VALID);
         }
         response.setPrincipal(new CustomTokenPrincipal("alice"));
         

Modified: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameTokenValidator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameTokenValidator.java?rev=1303443&r1=1303442&r2=1303443&view=diff
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameTokenValidator.java (original)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameTokenValidator.java Wed Mar 21 15:30:02 2012
@@ -19,7 +19,7 @@
 package org.apache.cxf.systest.sts.username_onbehalfof;
 
 import org.apache.cxf.sts.request.ReceivedToken;
-import org.apache.cxf.sts.request.TokenRequirements;
+import org.apache.cxf.sts.request.ReceivedToken.STATE;
 import org.apache.cxf.sts.token.validator.TokenValidator;
 import org.apache.cxf.sts.token.validator.TokenValidatorParameters;
 import org.apache.cxf.sts.token.validator.TokenValidatorResponse;
@@ -51,15 +51,16 @@ public class UsernameTokenValidator impl
      * Validate a Token using the given TokenValidatorParameters.
      */
     public TokenValidatorResponse validateToken(TokenValidatorParameters tokenParameters) {
-        TokenRequirements tokenRequirements = tokenParameters.getTokenRequirements();
-        ReceivedToken validateTarget = tokenRequirements.getValidateTarget();
+        TokenValidatorResponse response = new TokenValidatorResponse();
+        ReceivedToken validateTarget = tokenParameters.getToken();
+        validateTarget.setValidationState(STATE.INVALID);
+        response.setToken(validateTarget);
         
         UsernameTokenType usernameTokenType = (UsernameTokenType)validateTarget.getToken();
         // Ignore the fact that no password is provided
         // Some other requirements must be met to issue a token onbehalfof a subject
-        // whose authentication is not proofen
-        TokenValidatorResponse response = new TokenValidatorResponse();
-        response.setValid(true);
+        // whose authentication is not proved
+        validateTarget.setValidationState(STATE.VALID);
         response.setPrincipal(new CustomTokenPrincipal(usernameTokenType.getUsername().getValue()));
         
         return response;



Mime
View raw message