Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/str/SignatureSTRParser.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/str/SignatureSTRParser.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/str/SignatureSTRParser.java (original) +++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/str/SignatureSTRParser.java Tue Mar 8 16:57:34 2011 @@ -23,11 +23,11 @@ import org.apache.ws.security.CustomToke import org.apache.ws.security.WSConstants; import org.apache.ws.security.WSDocInfo; import org.apache.ws.security.WSPasswordCallback; -import org.apache.ws.security.WSSConfig; import org.apache.ws.security.WSSecurityEngine; import org.apache.ws.security.WSSecurityEngineResult; import org.apache.ws.security.WSSecurityException; import org.apache.ws.security.components.crypto.Crypto; +import org.apache.ws.security.handler.RequestData; import org.apache.ws.security.message.token.BinarySecurity; import org.apache.ws.security.message.token.DerivedKeyToken; import org.apache.ws.security.message.token.PKIPathSecurity; @@ -50,7 +50,6 @@ import java.util.List; import java.util.Map; import javax.security.auth.callback.Callback; -import javax.security.auth.callback.CallbackHandler; import javax.xml.namespace.QName; /** @@ -91,15 +90,14 @@ public class SignatureSTRParser implemen */ public void parseSecurityTokenReference( Element strElement, - Crypto crypto, - CallbackHandler cb, + RequestData data, WSDocInfo wsDocInfo, - WSSConfig config, Map<String, Object> parameters ) throws WSSecurityException { boolean bspCompliant = true; - if (config != null) { - bspCompliant = config.isWsiBSPCompliant(); + Crypto crypto = data.getSigCrypto(); + if (data.getWssConfig() != null) { + bspCompliant = data.getWssConfig().isWsiBSPCompliant(); } SecurityTokenReference secRef = new SecurityTokenReference(strElement, bspCompliant); // @@ -117,31 +115,32 @@ public class SignatureSTRParser implemen WSSecurityEngineResult result = wsDocInfo.getResult(uri); if (result == null) { Element token = - secRef.getTokenElement(strElement.getOwnerDocument(), wsDocInfo, cb); + secRef.getTokenElement(strElement.getOwnerDocument(), wsDocInfo, data.getCallbackHandler()); QName el = new QName(token.getNamespaceURI(), token.getLocalName()); if (el.equals(WSSecurityEngine.BINARY_TOKEN)) { certs = getCertificatesTokenReference(secRef, token, crypto, bspCompliant); } else if (el.equals(WSSecurityEngine.SAML_TOKEN) || el.equals(WSSecurityEngine.SAML2_TOKEN)) { - Processor proc = config.getProcessor(WSSecurityEngine.SAML_TOKEN); + Processor proc = data.getWssConfig().getProcessor(WSSecurityEngine.SAML_TOKEN); // // Just check to see whether the token was processed or not // Element processedToken = secRef.findProcessedTokenElement( - strElement.getOwnerDocument(), wsDocInfo, cb, uri, ref.getValueType() + strElement.getOwnerDocument(), wsDocInfo, + data.getCallbackHandler(), uri, ref.getValueType() ); AssertionWrapper assertion = null; if (processedToken == null) { List<WSSecurityEngineResult> samlResult = - proc.handleToken(token, null, crypto, cb, wsDocInfo, config); + proc.handleToken(token, data, wsDocInfo); assertion = (AssertionWrapper)samlResult.get(0).get( WSSecurityEngineResult.TAG_SAML_ASSERTION ); } else { assertion = new AssertionWrapper(processedToken); - assertion.parseHOKSubject(crypto, cb, wsDocInfo, config); + assertion.parseHOKSubject(data, wsDocInfo); } if (bspCompliant) { BSPEnforcer.checkSamlTokenBSPCompliance(secRef, assertion); @@ -157,9 +156,9 @@ public class SignatureSTRParser implemen if (bspCompliant) { BSPEnforcer.checkEncryptedKeyBSPCompliance(secRef); } - Processor proc = config.getProcessor(WSSecurityEngine.ENCRYPTED_KEY); + Processor proc = data.getWssConfig().getProcessor(WSSecurityEngine.ENCRYPTED_KEY); List<WSSecurityEngineResult> encrResult = - proc.handleToken(token, null, crypto, cb, wsDocInfo, config); + proc.handleToken(token, data, wsDocInfo); secretKey = (byte[])encrResult.get(0).get( WSSecurityEngineResult.TAG_SECRET @@ -167,7 +166,7 @@ public class SignatureSTRParser implemen principal = new CustomTokenPrincipal(token.getAttribute("Id")); } else { String id = secRef.getReference().getURI(); - secretKey = getSecretKeyFromToken(id, null, cb); + secretKey = getSecretKeyFromToken(id, null, data); principal = new CustomTokenPrincipal(id); } } else { @@ -179,7 +178,7 @@ public class SignatureSTRParser implemen UsernameToken usernameToken = (UsernameToken)result.get(WSSecurityEngineResult.TAG_USERNAME_TOKEN); - usernameToken.setRawPassword(cb); + usernameToken.setRawPassword(data); if (usernameToken.isDerivedKey()) { secretKey = usernameToken.getDerivedKey(); } else { @@ -250,19 +249,21 @@ public class SignatureSTRParser implemen } String id = secRef.getKeyIdentifierValue(); secretKey = - getSecretKeyFromToken(id, SecurityTokenReference.ENC_KEY_SHA1_URI, cb); + getSecretKeyFromToken(id, SecurityTokenReference.ENC_KEY_SHA1_URI, + data); principal = new CustomTokenPrincipal(id); } else if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(secRef.getKeyIdentifierValueType()) || WSConstants.WSS_SAML2_KI_VALUE_TYPE.equals(secRef.getKeyIdentifierValueType())) { AssertionWrapper assertion = SAMLUtil.getAssertionFromKeyIdentifier( - secRef, strElement, crypto, cb, wsDocInfo, config + secRef, strElement, data, wsDocInfo ); if (bspCompliant) { BSPEnforcer.checkSamlTokenBSPCompliance(secRef, assertion); } SAMLKeyInfo samlKi = - SAMLUtil.getCredentialFromSubject(assertion, crypto, cb, wsDocInfo, bspCompliant); + SAMLUtil.getCredentialFromSubject(assertion, data, + wsDocInfo, bspCompliant); X509Certificate[] foundCerts = samlKi.getCerts(); if (foundCerts != null) { certs = new X509Certificate[]{foundCerts[0]}; @@ -413,16 +414,16 @@ public class SignatureSTRParser implemen private byte[] getSecretKeyFromToken( String id, String type, - CallbackHandler cb + RequestData data ) throws WSSecurityException { if (id.charAt(0) == '#') { id = id.substring(1); } WSPasswordCallback pwcb = - new WSPasswordCallback(id, null, type, WSPasswordCallback.SECRET_KEY); + new WSPasswordCallback(id, null, type, WSPasswordCallback.SECRET_KEY, data); try { Callback[] callbacks = new Callback[]{pwcb}; - cb.handle(callbacks); + data.getCallbackHandler().handle(callbacks); } catch (Exception e) { throw new WSSecurityException( WSSecurityException.FAILURE,
Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/NoOpValidator.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/NoOpValidator.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/NoOpValidator.java (original) +++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/NoOpValidator.java Tue Mar 8 16:57:34 2011 @@ -19,11 +19,9 @@ package org.apache.ws.security.validate; -import javax.security.auth.callback.CallbackHandler; -import org.apache.ws.security.WSSConfig; import org.apache.ws.security.WSSecurityException; -import org.apache.ws.security.components.crypto.Crypto; +import org.apache.ws.security.handler.RequestData; /** * This class does not do any Validation at all. @@ -34,37 +32,11 @@ public class NoOpValidator implements Va * Validate the credential argument. * * @param credential the Credential to be validated + * @param RequestData associated with the request * @throws WSSecurityException on a failed validation */ - public Credential validate(Credential credential) throws WSSecurityException { + public Credential validate(Credential credential, RequestData data) throws WSSecurityException { return credential; } - /** - * Set a WSSConfig instance used to extract configured options used to - * validate credentials. This method is not currently used for this implementation. - * @param wssConfig a WSSConfig instance - */ - public void setWSSConfig(WSSConfig wssConfig) { - // - } - - /** - * Set a Crypto instance used to validate credentials. This method is not currently - * used for this implementation. - * @param crypto a Crypto instance used to validate credentials - */ - public void setCrypto(Crypto crypto) { - // - } - - /** - * Set a CallbackHandler instance used to validate credentials. This method is not - * currently used for this implementation. - * @param callbackHandler a CallbackHandler instance used to validate credentials - */ - public void setCallbackHandler(CallbackHandler callbackHandler) { - // - } - } Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/SamlAssertionValidator.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/SamlAssertionValidator.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/SamlAssertionValidator.java (original) +++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/SamlAssertionValidator.java Tue Mar 8 16:57:34 2011 @@ -22,6 +22,7 @@ package org.apache.ws.security.validate; import java.util.List; import org.apache.ws.security.WSSecurityException; +import org.apache.ws.security.handler.RequestData; import org.apache.ws.security.saml.SAMLKeyInfo; import org.apache.ws.security.saml.ext.AssertionWrapper; import org.apache.ws.security.saml.ext.OpenSAMLUtil; @@ -40,9 +41,10 @@ public class SamlAssertionValidator exte * A Crypto and a CallbackHandler implementation is also required to be set. * * @param credential the Credential to be validated + * @param RequestData associated with the request * @throws WSSecurityException on a failed validation */ - public Credential validate(Credential credential) throws WSSecurityException { + public Credential validate(Credential credential, RequestData data) throws WSSecurityException { if (credential == null || credential.getAssertion() == null) { throw new WSSecurityException(WSSecurityException.FAILURE, "noCredential"); } @@ -70,7 +72,7 @@ public class SamlAssertionValidator exte SAMLKeyInfo samlKeyInfo = assertion.getSignatureKeyInfo(); trustCredential.setPublicKey(samlKeyInfo.getPublicKey()); trustCredential.setCertificates(samlKeyInfo.getCerts()); - super.validate(trustCredential); + super.validate(trustCredential, data); } return credential; } Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/SignatureTrustValidator.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/SignatureTrustValidator.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/SignatureTrustValidator.java (original) +++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/SignatureTrustValidator.java Tue Mar 8 16:57:34 2011 @@ -25,14 +25,13 @@ import java.security.cert.CertificateExp import java.security.cert.CertificateNotYetValidException; import java.security.cert.X509Certificate; -import javax.security.auth.callback.CallbackHandler; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.ws.security.WSSConfig; import org.apache.ws.security.WSSecurityException; import org.apache.ws.security.components.crypto.Crypto; import org.apache.ws.security.components.crypto.CryptoType; +import org.apache.ws.security.handler.RequestData; /** * This class verifies trust in a credential used to verify a signature, which is extracted @@ -41,7 +40,6 @@ import org.apache.ws.security.components public class SignatureTrustValidator implements Validator { private static Log LOG = LogFactory.getLog(SignatureTrustValidator.class.getName()); - protected Crypto crypto; /** * Validate the credential argument. It must contain a non-null X509Certificate chain @@ -53,12 +51,13 @@ public class SignatureTrustValidator imp * @param credential the Credential to be validated * @throws WSSecurityException on a failed validation */ - public Credential validate(Credential credential) throws WSSecurityException { + public Credential validate(Credential credential, RequestData data) throws WSSecurityException { if (credential == null) { throw new WSSecurityException(WSSecurityException.FAILURE, "noCredential"); } X509Certificate[] certs = credential.getCertificates(); PublicKey publicKey = credential.getPublicKey(); + Crypto crypto = getCrypto(data); if (crypto == null) { throw new WSSecurityException(WSSecurityException.FAILURE, "noSigCryptoFile"); } @@ -67,50 +66,29 @@ public class SignatureTrustValidator imp validateCertificates(certs); boolean trust = false; if (certs.length == 1) { - trust = verifyTrustInCert(certs); + trust = verifyTrustInCert(certs, crypto); } else { - trust = verifyTrustInCerts(certs); + trust = verifyTrustInCerts(certs, crypto); } if (trust) { return credential; } } if (publicKey != null) { - boolean trust = validatePublicKey(publicKey); + boolean trust = validatePublicKey(publicKey, crypto); if (trust) { return credential; } } throw new WSSecurityException(WSSecurityException.FAILED_AUTHENTICATION); } - - /** - * Set a WSSConfig instance used to extract configured options used to - * validate credentials. This method is not currently used for this implementation. - * @param wssConfig a WSSConfig instance - */ - public void setWSSConfig(WSSConfig wssConfig) { - // - } - - /** - * Set a Crypto instance used to validate credentials. This is required for this - * implementation. - * @param crypto a Crypto instance used to validate credentials - */ - public void setCrypto(Crypto crypto) { - this.crypto = crypto; - } - - /** - * Set a CallbackHandler instance used to validate credentials. This method is not - * currently used for this implementation. - * @param callbackHandler a CallbackHandler instance used to validate credentials - */ - public void setCallbackHandler(CallbackHandler callbackHandler) { - // + + + protected Crypto getCrypto(RequestData data) { + return data.getSigCrypto(); } - + + /** * Validate the certificates by checking the validity of each cert * @throws WSSecurityException @@ -145,7 +123,7 @@ public class SignatureTrustValidator imp * @return true if the certificate is trusted, false if not * @throws WSSecurityException */ - private boolean verifyTrustInCert(X509Certificate[] certificates) throws WSSecurityException { + private boolean verifyTrustInCert(X509Certificate[] certificates, Crypto crypto) throws WSSecurityException { X509Certificate cert = certificates[0]; String subjectString = cert.getSubjectX500Principal().getName(); @@ -275,7 +253,7 @@ public class SignatureTrustValidator imp * @return true if the certificate chain is trusted, false if not * @throws WSSecurityException */ - private boolean verifyTrustInCerts(X509Certificate[] certificates) throws WSSecurityException { + private boolean verifyTrustInCerts(X509Certificate[] certificates, Crypto crypto) throws WSSecurityException { String subjectString = certificates[0].getSubjectX500Principal().getName(); // // Use the validation method from the crypto to check whether the subjects' @@ -306,7 +284,7 @@ public class SignatureTrustValidator imp * Validate a public key * @throws WSSecurityException */ - private boolean validatePublicKey(PublicKey publicKey) throws WSSecurityException { + private boolean validatePublicKey(PublicKey publicKey, Crypto crypto) throws WSSecurityException { return crypto.verifyTrust(publicKey); } Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/TimestampValidator.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/TimestampValidator.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/TimestampValidator.java (original) +++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/TimestampValidator.java Tue Mar 8 16:57:34 2011 @@ -19,11 +19,10 @@ package org.apache.ws.security.validate; -import javax.security.auth.callback.CallbackHandler; import org.apache.ws.security.WSSConfig; import org.apache.ws.security.WSSecurityException; -import org.apache.ws.security.components.crypto.Crypto; +import org.apache.ws.security.handler.RequestData; import org.apache.ws.security.message.token.Timestamp; /** @@ -32,22 +31,21 @@ import org.apache.ws.security.message.to */ public class TimestampValidator implements Validator { - private WSSConfig wssConfig; - /** * Validate the credential argument. It must contain a non-null Timestamp. * * @param credential the Credential to be validated + * @param RequestData associated with the request * @throws WSSecurityException on a failed validation */ - public Credential validate(Credential credential) throws WSSecurityException { + public Credential validate(Credential credential, RequestData data) throws WSSecurityException { if (credential == null || credential.getTimestamp() == null) { throw new WSSecurityException(WSSecurityException.FAILURE, "noCredential"); } - if (wssConfig == null) { + if (data.getWssConfig() == null) { throw new WSSecurityException("WSSConfig cannot be null"); } - + WSSConfig wssConfig = data.getWssConfig(); boolean timeStampStrict = true; int timeStampTTL = 300; if (wssConfig != null) { @@ -68,31 +66,6 @@ public class TimestampValidator implemen return credential; } - /** - * Set a WSSConfig instance used to extract configured options used to - * validate credentials. This is optional for this implementation. - * @param wssConfig a WSSConfig instance - */ - public void setWSSConfig(WSSConfig wssConfig) { - this.wssConfig = wssConfig; - } - - /** - * Set a Crypto instance used to validate credentials. This method is not currently - * used for this implementation. - * @param crypto a Crypto instance used to validate credentials - */ - public void setCrypto(Crypto crypto) { - // - } - - /** - * Set a CallbackHandler instance used to validate credentials. This method is not - * currently used for this implementation. - * @param callbackHandler a CallbackHandler instance used to validate credentials - */ - public void setCallbackHandler(CallbackHandler callbackHandler) { - // - } + } Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/UsernameTokenValidator.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/UsernameTokenValidator.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/UsernameTokenValidator.java (original) +++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/UsernameTokenValidator.java Tue Mar 8 16:57:34 2011 @@ -22,7 +22,6 @@ package org.apache.ws.security.validate; import java.io.IOException; import javax.security.auth.callback.Callback; -import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.UnsupportedCallbackException; import org.apache.commons.logging.Log; @@ -31,7 +30,7 @@ import org.apache.ws.security.WSConstant import org.apache.ws.security.WSPasswordCallback; import org.apache.ws.security.WSSConfig; import org.apache.ws.security.WSSecurityException; -import org.apache.ws.security.components.crypto.Crypto; +import org.apache.ws.security.handler.RequestData; import org.apache.ws.security.message.token.UsernameToken; import org.apache.ws.security.util.Base64; @@ -43,9 +42,6 @@ public class UsernameTokenValidator impl private static Log log = LogFactory.getLog(UsernameTokenValidator.class.getName()); - protected WSSConfig wssConfig; - protected CallbackHandler callbackHandler; - /** * Validate the credential argument. It must contain a non-null UsernameToken. A * CallbackHandler implementation is also required to be set. @@ -57,9 +53,10 @@ public class UsernameTokenValidator impl * of this type. * * @param credential the Credential to be validated + * @param RequestData associated with the request * @throws WSSecurityException on a failed validation */ - public Credential validate(Credential credential) throws WSSecurityException { + public Credential validate(Credential credential, RequestData data) throws WSSecurityException { if (credential == null || credential.getUsernametoken() == null) { throw new WSSecurityException(WSSecurityException.FAILURE, "noCredential"); } @@ -67,6 +64,7 @@ public class UsernameTokenValidator impl boolean handleCustomPasswordTypes = false; boolean passwordsAreEncoded = false; String requiredPasswordType = null; + WSSConfig wssConfig = data.getWssConfig(); if (wssConfig != null) { handleCustomPasswordTypes = wssConfig.getHandleCustomPasswordTypes(); passwordsAreEncoded = wssConfig.getPasswordsAreEncoded(); @@ -97,10 +95,10 @@ public class UsernameTokenValidator impl // String password = usernameToken.getPassword(); if (usernameToken.isHashed()) { - verifyDigestPassword(usernameToken); + verifyDigestPassword(usernameToken, data); } else if (WSConstants.PASSWORD_TEXT.equals(pwType) || (password != null && (pwType == null || "".equals(pwType.trim())))) { - verifyPlaintextPassword(usernameToken); + verifyPlaintextPassword(usernameToken, data); } else if (password != null) { if (!handleCustomPasswordTypes) { if (log.isDebugEnabled()) { @@ -108,41 +106,14 @@ public class UsernameTokenValidator impl } throw new WSSecurityException(WSSecurityException.FAILED_AUTHENTICATION); } - verifyCustomPassword(usernameToken); + verifyCustomPassword(usernameToken, data); } else { - verifyUnknownPassword(usernameToken); + verifyUnknownPassword(usernameToken, data); } return credential; } /** - * Set a WSSConfig instance used to extract configured options used to - * validate credentials. This is optional for this implementation. - * @param wssConfig a WSSConfig instance - */ - public void setWSSConfig(WSSConfig wssConfig) { - this.wssConfig = wssConfig; - } - - /** - * Set a Crypto instance used to validate credentials. This method is not currently - * used for this implementation. - * @param crypto a Crypto instance used to validate credentials - */ - public void setCrypto(Crypto crypto) { - // - } - - /** - * Set a CallbackHandler instance used to validate credentials. This is required for - * this implementation. - * @param callbackHandler a CallbackHandler instance used to validate credentials - */ - public void setCallbackHandler(CallbackHandler callbackHandler) { - this.callbackHandler = callbackHandler; - } - - /** * Verify a UsernameToken containing a password of some unknown (but specified) password * type. It does this by querying a CallbackHandler instance to obtain a password for the * given username, and then comparing it against the received password. @@ -152,8 +123,9 @@ public class UsernameTokenValidator impl * @param usernameToken The UsernameToken instance to verify * @throws WSSecurityException on a failed authentication. */ - protected void verifyCustomPassword(UsernameToken usernameToken) throws WSSecurityException { - verifyPlaintextPassword(usernameToken); + protected void verifyCustomPassword(UsernameToken usernameToken, + RequestData data) throws WSSecurityException { + verifyPlaintextPassword(usernameToken, data); } /** @@ -166,8 +138,9 @@ public class UsernameTokenValidator impl * @param usernameToken The UsernameToken instance to verify * @throws WSSecurityException on a failed authentication. */ - protected void verifyPlaintextPassword(UsernameToken usernameToken) throws WSSecurityException { - verifyDigestPassword(usernameToken); + protected void verifyPlaintextPassword(UsernameToken usernameToken, + RequestData data) throws WSSecurityException { + verifyDigestPassword(usernameToken, data); } /** @@ -177,8 +150,9 @@ public class UsernameTokenValidator impl * @param usernameToken The UsernameToken instance to verify * @throws WSSecurityException on a failed authentication. */ - protected void verifyDigestPassword(UsernameToken usernameToken) throws WSSecurityException { - if (callbackHandler == null) { + protected void verifyDigestPassword(UsernameToken usernameToken, + RequestData data) throws WSSecurityException { + if (data.getCallbackHandler() == null) { throw new WSSecurityException(WSSecurityException.FAILURE, "noCallback"); } @@ -190,9 +164,9 @@ public class UsernameTokenValidator impl boolean passwordsAreEncoded = usernameToken.getPasswordsAreEncoded(); WSPasswordCallback pwCb = - new WSPasswordCallback(user, null, pwType, WSPasswordCallback.USERNAME_TOKEN); + new WSPasswordCallback(user, null, pwType, WSPasswordCallback.USERNAME_TOKEN, data); try { - callbackHandler.handle(new Callback[]{pwCb}); + data.getCallbackHandler().handle(new Callback[]{pwCb}); } catch (IOException e) { if (log.isDebugEnabled()) { log.debug(e); @@ -238,7 +212,8 @@ public class UsernameTokenValidator impl * @param usernameToken The UsernameToken instance to verify * @throws WSSecurityException on a failed authentication. */ - protected void verifyUnknownPassword(UsernameToken usernameToken) throws WSSecurityException { + protected void verifyUnknownPassword(UsernameToken usernameToken, + RequestData data) throws WSSecurityException { // } Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/Validator.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/Validator.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/Validator.java (original) +++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/validate/Validator.java Tue Mar 8 16:57:34 2011 @@ -19,11 +19,9 @@ package org.apache.ws.security.validate; -import javax.security.auth.callback.CallbackHandler; -import org.apache.ws.security.WSSConfig; import org.apache.ws.security.WSSecurityException; -import org.apache.ws.security.components.crypto.Crypto; +import org.apache.ws.security.handler.RequestData; /** * This interface describes a pluggable way of validating credentials that have been extracted @@ -37,28 +35,11 @@ public interface Validator { * that was validated, or it can represent some transformation of the initial Credential * instance. * @param credential the Credential to be validated + * @param RequestData associated with the request * @return a validated Credential * @throws WSSecurityException on a failed validation */ - public Credential validate(Credential credential) throws WSSecurityException; + public Credential validate(Credential credential, RequestData data) throws WSSecurityException; - /** - * Set a Crypto instance used to validate credentials - * @param crypto a Crypto instance used to validate credentials - */ - public void setCrypto(Crypto crypto); - - /** - * Set a CallbackHandler instance used to validate credentials - * @param callbackHandler a CallbackHandler instance used to validate credentials - */ - public void setCallbackHandler(CallbackHandler callbackHandler); - - /** - * Set a WSSConfig instance used to extract configured options used to - * validate credentials - * @param wssConfig a WSSConfig instance - */ - public void setWSSConfig(WSSConfig wssConfig); } Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomProcessor.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomProcessor.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomProcessor.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomProcessor.java Tue Mar 8 16:57:34 2011 @@ -19,13 +19,11 @@ package org.apache.ws.security.common; -import org.apache.ws.security.components.crypto.Crypto; +import org.apache.ws.security.handler.RequestData; import org.apache.ws.security.message.token.SecurityContextToken; import org.apache.ws.security.processor.Processor; -import org.apache.ws.security.validate.Validator; import org.apache.ws.security.WSConstants; import org.apache.ws.security.WSDocInfo; -import org.apache.ws.security.WSSConfig; import org.apache.ws.security.WSSecurityEngineResult; import org.apache.ws.security.WSSecurityException; @@ -37,11 +35,8 @@ public class CustomProcessor implements 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 WSSConfig config + final RequestData data, + final WSDocInfo wsDocInfo ) throws WSSecurityException { final WSSecurityEngineResult result = new WSSecurityEngineResult( @@ -51,12 +46,5 @@ public class CustomProcessor implements result.put("foo", this); return java.util.Collections.singletonList(result); } - - /** - * Set a Validator implementation to validate the credential - * @param validator the Validator implementation to set - */ - public void setValidator(Validator validator) { - // - } + } Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/CertificateStoreTest.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/CertificateStoreTest.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/CertificateStoreTest.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/CertificateStoreTest.java Tue Mar 8 16:57:34 2011 @@ -28,9 +28,6 @@ import org.apache.ws.security.WSSecurity import org.apache.ws.security.WSSecurityException; import org.apache.ws.security.common.KeystoreCallbackHandler; import org.apache.ws.security.common.SOAPUtil; -import org.apache.ws.security.components.crypto.Crypto; -import org.apache.ws.security.components.crypto.CryptoType; -import org.apache.ws.security.components.crypto.CryptoFactory; import org.apache.ws.security.message.WSSecHeader; import org.apache.ws.security.message.WSSecSignature; import org.apache.ws.security.util.WSSecurityUtil; Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/CustomActionProcessorTest.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/CustomActionProcessorTest.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/CustomActionProcessorTest.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/CustomActionProcessorTest.java Tue Mar 8 16:57:34 2011 @@ -32,8 +32,6 @@ import org.apache.ws.security.common.Cus import org.apache.ws.security.common.SOAPUtil; import org.apache.ws.security.components.crypto.Crypto; import org.apache.ws.security.components.crypto.CryptoFactory; -import org.apache.ws.security.handler.RequestData; -import org.apache.ws.security.handler.WSHandlerConstants; import org.apache.ws.security.message.WSSecSignature; import org.apache.ws.security.message.WSSecHeader; import org.apache.ws.security.util.WSSecurityUtil; Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureUTAliasTest.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureUTAliasTest.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureUTAliasTest.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureUTAliasTest.java Tue Mar 8 16:57:34 2011 @@ -36,8 +36,6 @@ import org.apache.ws.security.WSSecurity import org.apache.ws.security.common.CustomHandler; import org.apache.ws.security.common.SOAPUtil; import org.apache.ws.security.components.crypto.CryptoFactory; -import org.apache.ws.security.handler.RequestData; -import org.apache.ws.security.handler.WSHandlerConstants; import org.w3c.dom.Document; Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/NoSoapPrefixSignatureTest.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/NoSoapPrefixSignatureTest.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/NoSoapPrefixSignatureTest.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/NoSoapPrefixSignatureTest.java Tue Mar 8 16:57:34 2011 @@ -26,8 +26,6 @@ import org.apache.ws.security.WSConstant import org.apache.ws.security.common.SOAPUtil; import org.apache.ws.security.components.crypto.Crypto; import org.apache.ws.security.components.crypto.CryptoFactory; -import org.apache.ws.security.message.WSSecSignature; -import org.apache.ws.security.message.WSSecHeader; import org.w3c.dom.Document; /** Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SKISignatureTest.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SKISignatureTest.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SKISignatureTest.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SKISignatureTest.java Tue Mar 8 16:57:34 2011 @@ -26,8 +26,6 @@ import org.apache.ws.security.WSConstant import org.apache.ws.security.common.SOAPUtil; import org.apache.ws.security.components.crypto.Crypto; import org.apache.ws.security.components.crypto.CryptoFactory; -import org.apache.ws.security.message.WSSecSignature; -import org.apache.ws.security.message.WSSecHeader; import org.w3c.dom.Document; /** Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignaturePartsTest.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignaturePartsTest.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignaturePartsTest.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignaturePartsTest.java Tue Mar 8 16:57:34 2011 @@ -33,8 +33,6 @@ import org.apache.ws.security.common.SOA import org.apache.ws.security.components.crypto.Crypto; import org.apache.ws.security.components.crypto.CryptoFactory; import org.apache.ws.security.components.crypto.Merlin; -import org.apache.ws.security.message.WSSecSignature; -import org.apache.ws.security.message.WSSecHeader; import org.apache.ws.security.saml.SAMLIssuer; import org.apache.ws.security.saml.SAMLIssuerImpl; import org.apache.ws.security.saml.SignedSamlTokenHOKTest; Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SymmetricSignatureTest.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SymmetricSignatureTest.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SymmetricSignatureTest.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SymmetricSignatureTest.java Tue Mar 8 16:57:34 2011 @@ -42,10 +42,6 @@ import org.apache.ws.security.common.SOA import org.apache.ws.security.common.SecretKeyCallbackHandler; import org.apache.ws.security.handler.RequestData; import org.apache.ws.security.handler.WSHandlerConstants; -import org.apache.ws.security.message.WSSecEncrypt; -import org.apache.ws.security.message.WSSecEncryptedKey; -import org.apache.ws.security.message.WSSecHeader; -import org.apache.ws.security.message.WSSecSignature; import org.apache.ws.security.util.Base64; import org.apache.ws.security.util.WSSecurityUtil; import org.w3c.dom.Document; Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UsernameTokenTest.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UsernameTokenTest.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UsernameTokenTest.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UsernameTokenTest.java Tue Mar 8 16:57:34 2011 @@ -683,7 +683,7 @@ public class UsernameTokenTest extends o String outputString = org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(utDoc); LOG.debug(outputString); - }; + } WSSecurityEngine newEngine = new WSSecurityEngine(); try { @@ -725,7 +725,7 @@ public class UsernameTokenTest extends o String outputString = org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(utDoc); LOG.debug(outputString); - }; + } WSSecurityEngine newEngine = new WSSecurityEngine(); try { @@ -767,7 +767,7 @@ public class UsernameTokenTest extends o String outputString = org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(utDoc); LOG.debug(outputString); - }; + } WSSecurityEngine newEngine = new WSSecurityEngine(); try { @@ -810,7 +810,7 @@ public class UsernameTokenTest extends o String outputString = org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(utDoc); LOG.debug(outputString); - }; + } WSSecurityEngine newEngine = new WSSecurityEngine(); try { Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/BSTKerberosTest.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/BSTKerberosTest.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/BSTKerberosTest.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/BSTKerberosTest.java Tue Mar 8 16:57:34 2011 @@ -31,10 +31,10 @@ import org.apache.ws.security.common.Key import org.apache.ws.security.common.SOAPUtil; import org.apache.ws.security.components.crypto.Crypto; import org.apache.ws.security.components.crypto.CryptoFactory; +import org.apache.ws.security.handler.RequestData; import org.apache.ws.security.message.WSSecSignature; import org.apache.ws.security.message.WSSecHeader; import org.apache.ws.security.message.WSSecTimestamp; -import org.apache.ws.security.message.token.BinarySecurity; import org.apache.ws.security.util.WSSecurityUtil; import org.apache.ws.security.validate.Credential; import org.apache.ws.security.validate.Validator; @@ -262,7 +262,7 @@ public class BSTKerberosTest extends org */ private static class KerberosValidator implements Validator { - public Credential validate(Credential credential) throws WSSecurityException { + public Credential validate(Credential credential, RequestData data) throws WSSecurityException { BinarySecurity token = credential.getBinarySecurityToken(); if (token == null) { throw new WSSecurityException(WSSecurityException.FAILURE); @@ -279,17 +279,6 @@ public class BSTKerberosTest extends org return credential; } - public void setCrypto(Crypto crypto) { - // - } - - public void setCallbackHandler(CallbackHandler callbackHandler) { - // - } - - public void setWSSConfig(WSSConfig wssConfig) { - // - } } } Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/BinarySecurityTokenTest.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/BinarySecurityTokenTest.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/BinarySecurityTokenTest.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/BinarySecurityTokenTest.java Tue Mar 8 16:57:34 2011 @@ -31,7 +31,6 @@ import org.apache.ws.security.components import org.apache.ws.security.components.crypto.CryptoFactory; import org.apache.ws.security.components.crypto.CryptoType; import org.apache.ws.security.message.WSSecHeader; -import org.apache.ws.security.message.token.BinarySecurity; import org.apache.ws.security.util.WSSecurityUtil; import org.w3c.dom.Document; Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlNegativeTest.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlNegativeTest.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlNegativeTest.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlNegativeTest.java Tue Mar 8 16:57:34 2011 @@ -19,8 +19,6 @@ package org.apache.ws.security.saml; -import org.apache.ws.security.saml.SAMLIssuer; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.ws.security.WSConstants; Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlReferenceTest.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlReferenceTest.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlReferenceTest.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlReferenceTest.java Tue Mar 8 16:57:34 2011 @@ -821,7 +821,7 @@ public class SamlReferenceTest extends o saml.setIssuerKeyPassword("security"); saml.setSignAssertion(true); saml.setSamlVersion("2.0"); - saml.setCallbackHandler(callbackHandler);; + saml.setCallbackHandler(callbackHandler); AssertionWrapper assertion = saml.newAssertion(); Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG); @@ -900,7 +900,7 @@ public class SamlReferenceTest extends o saml.setIssuerKeyPassword("security"); saml.setSignAssertion(true); saml.setSamlVersion("2.0"); - saml.setCallbackHandler(callbackHandler);; + saml.setCallbackHandler(callbackHandler); AssertionWrapper assertion = saml.newAssertion(); Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG); Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlTokenHOKTest.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlTokenHOKTest.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlTokenHOKTest.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlTokenHOKTest.java Tue Mar 8 16:57:34 2011 @@ -25,7 +25,6 @@ import org.apache.commons.logging.LogFac import org.apache.ws.security.WSConstants; import org.apache.ws.security.WSSecurityEngine; import org.apache.ws.security.WSSecurityEngineResult; -import org.apache.ws.security.common.KeystoreCallbackHandler; import org.apache.ws.security.common.SAML1CallbackHandler; import org.apache.ws.security.common.SAML2CallbackHandler; import org.apache.ws.security.common.SOAPUtil; @@ -33,8 +32,6 @@ import org.apache.ws.security.components import org.apache.ws.security.components.crypto.CryptoFactory; import org.apache.ws.security.message.WSSecHeader; import org.apache.ws.security.message.WSSecSAMLToken; -import org.apache.ws.security.saml.SAMLIssuerFactory; -import org.apache.ws.security.saml.SAMLIssuer; import org.apache.ws.security.saml.ext.AssertionWrapper; import org.apache.ws.security.saml.ext.builder.SAML1Constants; import org.apache.ws.security.saml.ext.builder.SAML2Constants; @@ -44,8 +41,6 @@ import org.w3c.dom.Document; import java.util.List; -import javax.security.auth.callback.CallbackHandler; - /** * Test-case for sending and processing a signed (holder-of-key) SAML Assertion. These tests * just cover the case of creating and signing the Assertion, and not using the credential Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlTokenSVTest.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlTokenSVTest.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlTokenSVTest.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlTokenSVTest.java Tue Mar 8 16:57:34 2011 @@ -37,8 +37,6 @@ import org.apache.ws.security.components import org.apache.ws.security.handler.RequestData; import org.apache.ws.security.handler.WSHandlerConstants; import org.apache.ws.security.message.WSSecHeader; -import org.apache.ws.security.saml.SAMLIssuerFactory; -import org.apache.ws.security.saml.SAMLIssuer; import org.apache.ws.security.saml.ext.AssertionWrapper; import org.apache.ws.security.saml.ext.builder.SAML1Constants; import org.apache.ws.security.saml.ext.builder.SAML2Constants; Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlTokenTest.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlTokenTest.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlTokenTest.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlTokenTest.java Tue Mar 8 16:57:34 2011 @@ -34,8 +34,6 @@ import org.apache.ws.security.handler.Re import org.apache.ws.security.handler.WSHandlerConstants; import org.apache.ws.security.message.WSSecHeader; import org.apache.ws.security.message.WSSecSAMLToken; -import org.apache.ws.security.saml.SAMLIssuerFactory; -import org.apache.ws.security.saml.SAMLIssuer; import org.apache.ws.security.saml.ext.AssertionWrapper; import org.apache.ws.security.util.WSSecurityUtil; Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SignedSamlTokenHOKTest.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SignedSamlTokenHOKTest.java?rev=1079437&r1=1079436&r2=1079437&view=diff ============================================================================== --- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SignedSamlTokenHOKTest.java (original) +++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SignedSamlTokenHOKTest.java Tue Mar 8 16:57:34 2011 @@ -19,8 +19,6 @@ package org.apache.ws.security.saml; -import org.apache.ws.security.saml.SAMLIssuer; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.ws.security.WSConstants;
