Author: coheigea
Date: Wed Mar 6 17:02:55 2013
New Revision: 1453427
URL: http://svn.apache.org/r1453427
Log:
Fixed source + test compile, and got most of the tests to pass
Modified:
cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/CryptoCoverageUtil.java
cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JOutInterceptor.java
cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/SamlTokenInterceptor.java
cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractPolicySecurityTest.java
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/RoundTripTest.java
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/SignatureConfirmationTest.java
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JInOutTest.java
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SAML1CallbackHandler.java
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SAML2CallbackHandler.java
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SamlTokenTest.java
Modified:
cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/CryptoCoverageUtil.java
URL:
http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/CryptoCoverageUtil.java?rev=1453427&r1=1453426&r2=1453427&view=diff
==============================================================================
---
cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/CryptoCoverageUtil.java
(original)
+++
cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/CryptoCoverageUtil.java
Wed Mar 6 17:02:55 2013
@@ -125,7 +125,7 @@ public final class CryptoCoverageUtil {
CoverageScope scope
) throws WSSecurityException {
if (!CryptoCoverageUtil.matchElement(refs, type, scope, soapBody)) {
- throw new
WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
+ throw new
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, null,
"The " + getCoverageTypeString(type)
+ " does not cover the required elements (soap:Body).");
}
@@ -173,7 +173,7 @@ public final class CryptoCoverageUtil {
for (Element el : elements) {
if (!CryptoCoverageUtil.matchElement(refs, type, scope, el)) {
- throw new
WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
+ throw new
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, null,
"The " + getCoverageTypeString(type)
+ " does not cover the required elements ({"
+ namespace + "}" + name + ").");
@@ -300,7 +300,7 @@ public final class CryptoCoverageUtil {
// We looked through all of the refs, but the element was
// not signed.
if (!instanceMatched) {
- throw new
WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
+ throw new
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, null,
"The " + getCoverageTypeString(type)
+ " does not cover the required elements ("
+ xpathString + ").");
Modified:
cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JOutInterceptor.java
URL:
http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JOutInterceptor.java?rev=1453427&r1=1453426&r2=1453427&view=diff
==============================================================================
---
cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JOutInterceptor.java
(original)
+++
cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JOutInterceptor.java
Wed Mar 6 17:02:55 2013
@@ -52,6 +52,7 @@ import org.apache.cxf.ws.security.wss4j.
import org.apache.cxf.ws.security.wss4j.policyhandlers.TransportBindingHandler;
import org.apache.wss4j.common.ext.WSSecurityException;
import org.apache.wss4j.dom.WSSConfig;
+import org.apache.wss4j.dom.handler.WSHandlerConstants;
import org.apache.wss4j.dom.message.WSSecHeader;
public class PolicyBasedWSS4JOutInterceptor extends
AbstractPhaseInterceptor<SoapMessage> {
@@ -153,7 +154,7 @@ public class PolicyBasedWSS4JOutIntercep
if (config == null) {
config = WSSConfig.getNewInstance();
}
- translateProperties(message, config);
+ translateProperties(message);
if (transport instanceof TransportBinding) {
new TransportBindingHandler(config,
(TransportBinding)transport, saaj,
@@ -213,12 +214,10 @@ public class PolicyBasedWSS4JOutIntercep
return null;
}
- private void translateProperties(SoapMessage msg, WSSConfig config) {
+ private void translateProperties(SoapMessage msg) {
String bspCompliant =
(String)msg.getContextualProperty(SecurityConstants.IS_BSP_COMPLIANT);
- if ("1".equals(bspCompliant) || "true".equals(bspCompliant)) {
- config.setWsiBSPCompliant(true);
- } else if ("0".equals(bspCompliant) ||
"false".equals(bspCompliant)) {
- config.setWsiBSPCompliant(false);
+ if (bspCompliant != null) {
+ msg.setContextualProperty(WSHandlerConstants.IS_BSP_COMPLIANT,
bspCompliant);
}
}
}
Modified:
cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/SamlTokenInterceptor.java
URL:
http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/SamlTokenInterceptor.java?rev=1453427&r1=1453426&r2=1453427&view=diff
==============================================================================
---
cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/SamlTokenInterceptor.java
(original)
+++
cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/SamlTokenInterceptor.java
Wed Mar 6 17:02:55 2013
@@ -51,6 +51,13 @@ import org.apache.cxf.ws.security.Securi
import org.apache.cxf.ws.security.policy.SP12Constants;
import org.apache.cxf.ws.security.policy.model.SamlToken;
import org.apache.cxf.ws.security.policy.model.Token;
+import org.apache.wss4j.common.crypto.Crypto;
+import org.apache.wss4j.common.crypto.CryptoFactory;
+import org.apache.wss4j.common.ext.WSPasswordCallback;
+import org.apache.wss4j.common.ext.WSSecurityException;
+import org.apache.wss4j.common.saml.SAMLCallback;
+import org.apache.wss4j.common.saml.SAMLUtil;
+import org.apache.wss4j.common.saml.SamlAssertionWrapper;
import org.apache.wss4j.dom.WSConstants;
import org.apache.wss4j.dom.WSDocInfo;
import org.apache.wss4j.dom.WSSConfig;
@@ -98,8 +105,8 @@ public class SamlTokenInterceptor extend
boolean signed = false;
for (WSSecurityEngineResult result : samlResults) {
- AssertionWrapper wrapper =
-
(AssertionWrapper)result.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
+ SamlAssertionWrapper wrapper =
+
(SamlAssertionWrapper)result.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
if (wrapper.isSigned()) {
signed = true;
break;
@@ -153,8 +160,8 @@ public class SamlTokenInterceptor extend
}
} catch (RuntimeException t) {
throw t;
- } catch (Throwable t) {
- throw new WSSecurityException(t.getMessage(), t);
+ } catch (Exception ex) {
+ throw new
WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex);
}
}
return super.getValidator(qName);
@@ -178,7 +185,7 @@ public class SamlTokenInterceptor extend
Header h = findSecurityHeader(message, true);
try {
- AssertionWrapper wrapper = addSamlToken(tok, message);
+ SamlAssertionWrapper wrapper = addSamlToken(tok, message);
if (wrapper == null) {
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
Collection<AssertionInfo> ais =
aim.getAssertionInfo(SP12Constants.SAML_TOKEN);
@@ -197,7 +204,7 @@ public class SamlTokenInterceptor extend
}
- private AssertionWrapper addSamlToken(
+ private SamlAssertionWrapper addSamlToken(
SamlToken token, SoapMessage message
) throws WSSecurityException {
//
@@ -220,14 +227,14 @@ public class SamlTokenInterceptor extend
return null;
}
- SAMLParms samlParms = new SAMLParms();
- samlParms.setCallbackHandler(handler);
+ SAMLCallback samlCallback = new SAMLCallback();
if (token.isUseSamlVersion11Profile10() ||
token.isUseSamlVersion11Profile11()) {
- samlParms.setSAMLVersion(SAMLVersion.VERSION_11);
+ samlCallback.setSamlVersion(SAMLVersion.VERSION_11);
} else if (token.isUseSamlVersion20Profile11()) {
- samlParms.setSAMLVersion(SAMLVersion.VERSION_20);
+ samlCallback.setSamlVersion(SAMLVersion.VERSION_20);
}
- AssertionWrapper assertion = new AssertionWrapper(samlParms);
+ SAMLUtil.doSAMLCallback(handler, samlCallback);
+ SamlAssertionWrapper assertion = new
SamlAssertionWrapper(samlCallback);
boolean selfSignAssertion =
MessageUtils.getContextualBoolean(
@@ -255,7 +262,7 @@ public class SamlTokenInterceptor extend
String password =
(String)message.getContextualProperty(SecurityConstants.PASSWORD);
if (StringUtils.isEmpty(password)) {
- password = getPassword(user, token,
WSPasswordCallback.SIGNATURE, message);
+ password = getPassword(user, token,
WSPasswordCallback.Usage.SIGNATURE, message);
}
if (password == null) {
password = "";
Modified:
cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java
URL:
http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java?rev=1453427&r1=1453426&r2=1453427&view=diff
==============================================================================
---
cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java
(original)
+++
cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/UsernameTokenInterceptor.java
Wed Mar 6 17:02:55 2013
@@ -46,12 +46,14 @@ import org.apache.cxf.ws.security.policy
import org.apache.cxf.ws.security.policy.SPConstants;
import org.apache.cxf.ws.security.policy.model.SupportingToken;
import org.apache.cxf.ws.security.policy.model.UsernameToken;
+import org.apache.wss4j.common.ext.WSPasswordCallback;
import org.apache.wss4j.common.ext.WSSecurityException;
import org.apache.wss4j.dom.WSConstants;
import org.apache.wss4j.dom.WSDocInfo;
import org.apache.wss4j.dom.WSSConfig;
import org.apache.wss4j.dom.WSSecurityEngineResult;
import org.apache.wss4j.dom.WSUsernameTokenPrincipal;
+import org.apache.wss4j.dom.bsp.BSPEnforcer;
import org.apache.wss4j.dom.cache.ReplayCache;
import org.apache.wss4j.dom.handler.RequestData;
import org.apache.wss4j.dom.handler.WSHandlerConstants;
@@ -149,9 +151,11 @@ public class UsernameTokenInterceptor ex
data.setNonceReplayCache(nonceCache);
WSSConfig config = WSSConfig.getNewInstance();
- config.setWsiBSPCompliant(bspCompliant);
config.setAllowUsernameTokenNoPassword(allowNoPassword);
data.setWssConfig(config);
+ if (!bspCompliant) {
+ data.setDisableBSPEnforcement(true);
+ }
List<WSSecurityEngineResult> results =
p.handleToken(tokenElement, data, wsDocInfo);
return
(WSUsernameTokenPrincipal)results.get(0).get(WSSecurityEngineResult.TAG_PRINCIPAL);
@@ -164,8 +168,9 @@ public class UsernameTokenInterceptor ex
protected WSUsernameTokenPrincipal parseTokenAndCreatePrincipal(Element
tokenElement, boolean bspCompliant)
throws WSSecurityException {
+ BSPEnforcer bspEnforcer = new BSPEnforcer(!bspCompliant);
org.apache.wss4j.dom.message.token.UsernameToken ut =
- new org.apache.wss4j.dom.message.token.UsernameToken(tokenElement,
false, bspCompliant);
+ new org.apache.wss4j.dom.message.token.UsernameToken(tokenElement,
false, bspEnforcer);
WSUsernameTokenPrincipal principal = new
WSUsernameTokenPrincipal(ut.getName(), ut.isHashed());
principal.setNonce(ut.getNonce());
Modified:
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractPolicySecurityTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractPolicySecurityTest.java?rev=1453427&r1=1453426&r2=1453427&view=diff
==============================================================================
---
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractPolicySecurityTest.java
(original)
+++
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractPolicySecurityTest.java
Wed Mar 6 17:02:55 2013
@@ -387,7 +387,7 @@ public abstract class AbstractPolicySecu
}
}
inHandler.setProperty(WSHandlerConstants.ACTION, action);
- inHandler.setProperty(WSHandlerConstants.SIG_PROP_FILE,
+ inHandler.setProperty(WSHandlerConstants.SIG_VER_PROP_FILE,
"insecurity.properties");
inHandler.setProperty(WSHandlerConstants.DEC_PROP_FILE,
"insecurity.properties");
Modified:
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/RoundTripTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/RoundTripTest.java?rev=1453427&r1=1453426&r2=1453427&view=diff
==============================================================================
---
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/RoundTripTest.java
(original)
+++
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/RoundTripTest.java
Wed Mar 6 17:02:55 2013
@@ -55,7 +55,7 @@ public class RoundTripTest extends Abstr
service.getOutInterceptors().add(new LoggingOutInterceptor());
wsIn = new WSS4JInInterceptor();
- wsIn.setProperty(WSHandlerConstants.SIG_PROP_FILE,
"insecurity.properties");
+ wsIn.setProperty(WSHandlerConstants.SIG_VER_PROP_FILE,
"insecurity.properties");
wsIn.setProperty(WSHandlerConstants.DEC_PROP_FILE,
"insecurity.properties");
wsIn.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS,
TestPwdCallback.class.getName());
Modified:
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/SignatureConfirmationTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/SignatureConfirmationTest.java?rev=1453427&r1=1453426&r2=1453427&view=diff
==============================================================================
---
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/SignatureConfirmationTest.java
(original)
+++
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/SignatureConfirmationTest.java
Wed Mar 6 17:02:55 2013
@@ -122,7 +122,7 @@ public class SignatureConfirmationTest e
inmsg.setContent(SOAPMessage.class, saajMsg);
inHandler.setProperty(WSHandlerConstants.ACTION,
WSHandlerConstants.SIGNATURE);
- inHandler.setProperty(WSHandlerConstants.SIG_PROP_FILE,
"insecurity.properties");
+ inHandler.setProperty(WSHandlerConstants.SIG_VER_PROP_FILE,
"insecurity.properties");
inHandler.setProperty(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION, "true");
inHandler.handleMessage(inmsg);
Modified:
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JInOutTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JInOutTest.java?rev=1453427&r1=1453426&r2=1453427&view=diff
==============================================================================
---
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JInOutTest.java
(original)
+++
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JInOutTest.java
Wed Mar 6 17:02:55 2013
@@ -102,7 +102,7 @@ public class WSS4JInOutTest extends Abst
Map<String, String> inProperties = new HashMap<String, String>();
inProperties.put(WSHandlerConstants.ACTION,
WSHandlerConstants.SIGNATURE);
- inProperties.put(WSHandlerConstants.SIG_PROP_FILE,
"insecurity.properties");
+ inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,
"insecurity.properties");
List<String> xpaths = new ArrayList<String>();
xpaths.add("//wsse:Security");
@@ -129,7 +129,7 @@ public class WSS4JInOutTest extends Abst
Map<String, String> inProperties = new HashMap<String, String>();
inProperties.put(WSHandlerConstants.ACTION,
WSHandlerConstants.SIGNATURE);
- inProperties.put(WSHandlerConstants.SIG_PROP_FILE,
"insecurity.properties");
+ inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,
"insecurity.properties");
List<String> xpaths = new ArrayList<String>();
xpaths.add("//wsse:Security");
@@ -444,7 +444,7 @@ public class WSS4JInOutTest extends Abst
Map<String, String> inProperties = new HashMap<String, String>();
inProperties.put(WSHandlerConstants.ACTION,
WSHandlerConstants.SIGNATURE);
- inProperties.put(WSHandlerConstants.SIG_PROP_FILE, "cxfca.properties");
+ inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,
"cxfca.properties");
List<String> xpaths = new ArrayList<String>();
xpaths.add("//wsse:Security");
@@ -487,7 +487,7 @@ public class WSS4JInOutTest extends Abst
WSHandlerConstants.PW_CALLBACK_CLASS,
"org.apache.cxf.ws.security.wss4j.TestPwdCallback"
);
- inProperties.put(WSHandlerConstants.SIG_PROP_FILE,
"insecurity.properties");
+ inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,
"insecurity.properties");
List<String> xpaths = new ArrayList<String>();
xpaths.add("//wsse:Security");
Modified:
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SAML1CallbackHandler.java
URL:
http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SAML1CallbackHandler.java?rev=1453427&r1=1453426&r2=1453427&view=diff
==============================================================================
---
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SAML1CallbackHandler.java
(original)
+++
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SAML1CallbackHandler.java
Wed Mar 6 17:02:55 2013
@@ -27,6 +27,7 @@ import javax.security.auth.callback.Unsu
import org.apache.wss4j.common.crypto.Crypto;
import org.apache.wss4j.common.crypto.CryptoFactory;
import org.apache.wss4j.common.crypto.CryptoType;
+import org.apache.wss4j.common.ext.WSSecurityException;
import org.apache.wss4j.common.saml.SAMLCallback;
import org.apache.wss4j.common.saml.bean.KeyInfoBean;
import org.apache.wss4j.common.saml.bean.SubjectBean;
@@ -57,6 +58,7 @@ public class SAML1CallbackHandler extend
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof SAMLCallback) {
SAMLCallback callback = (SAMLCallback) callbacks[i];
+ callback.setIssuer("www.example.com");
callback.setSamlVersion(SAMLVersion.VERSION_11);
SubjectBean subjectBean =
new SubjectBean(
@@ -71,6 +73,16 @@ public class SAML1CallbackHandler extend
}
}
createAndSetStatement(subjectBean, callback);
+
+ try {
+ Crypto crypto =
CryptoFactory.getInstance("outsecurity.properties");
+ callback.setIssuerCrypto(crypto);
+ callback.setIssuerKeyName("myalias");
+ callback.setIssuerKeyPassword("myAliasPassword");
+ } catch (WSSecurityException e) {
+ throw new IOException(e);
+ }
+
} else {
throw new UnsupportedCallbackException(callbacks[i],
"Unrecognized Callback");
}
Modified:
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SAML2CallbackHandler.java
URL:
http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SAML2CallbackHandler.java?rev=1453427&r1=1453426&r2=1453427&view=diff
==============================================================================
---
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SAML2CallbackHandler.java
(original)
+++
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SAML2CallbackHandler.java
Wed Mar 6 17:02:55 2013
@@ -27,6 +27,7 @@ import javax.security.auth.callback.Unsu
import org.apache.wss4j.common.crypto.Crypto;
import org.apache.wss4j.common.crypto.CryptoFactory;
import org.apache.wss4j.common.crypto.CryptoType;
+import org.apache.wss4j.common.ext.WSSecurityException;
import org.apache.wss4j.common.saml.SAMLCallback;
import org.apache.wss4j.common.saml.bean.KeyInfoBean;
import org.apache.wss4j.common.saml.bean.SubjectBean;
@@ -62,6 +63,7 @@ public class SAML2CallbackHandler extend
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof SAMLCallback) {
SAMLCallback callback = (SAMLCallback) callbacks[i];
+ callback.setIssuer("www.example.com");
callback.setSamlVersion(SAMLVersion.VERSION_20);
SubjectBean subjectBean =
new SubjectBean(
@@ -77,6 +79,15 @@ public class SAML2CallbackHandler extend
}
callback.setSubject(subjectBean);
createAndSetStatement(null, callback);
+
+ try {
+ Crypto crypto =
CryptoFactory.getInstance("outsecurity.properties");
+ callback.setIssuerCrypto(crypto);
+ callback.setIssuerKeyName("myalias");
+ callback.setIssuerKeyPassword("myAliasPassword");
+ } catch (WSSecurityException e) {
+ throw new IOException(e);
+ }
} else {
throw new UnsupportedCallbackException(callbacks[i],
"Unrecognized Callback");
}
Modified:
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SamlTokenTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SamlTokenTest.java?rev=1453427&r1=1453426&r2=1453427&view=diff
==============================================================================
---
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SamlTokenTest.java
(original)
+++
cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/SamlTokenTest.java
Wed Mar 6 17:02:55 2013
@@ -82,7 +82,6 @@ public class SamlTokenTest extends Abstr
public void testSaml1Token() throws Exception {
Map<String, Object> outProperties = new HashMap<String, Object>();
outProperties.put(WSHandlerConstants.ACTION,
WSHandlerConstants.SAML_TOKEN_UNSIGNED);
- outProperties.put(WSHandlerConstants.SAML_PROP_FILE,
"saml_sv.properties");
outProperties.put(
WSHandlerConstants.SAML_CALLBACK_CLASS,
"org.apache.cxf.ws.security.wss4j.saml.SAML1CallbackHandler"
@@ -122,7 +121,6 @@ public class SamlTokenTest extends Abstr
public void testSaml2Token() throws Exception {
Map<String, Object> outProperties = new HashMap<String, Object>();
outProperties.put(WSHandlerConstants.ACTION,
WSHandlerConstants.SAML_TOKEN_UNSIGNED);
- outProperties.put(WSHandlerConstants.SAML_PROP_FILE,
"saml_sv.properties");
outProperties.put(
WSHandlerConstants.SAML_CALLBACK_CLASS,
"org.apache.cxf.ws.security.wss4j.saml.SAML2CallbackHandler"
@@ -164,7 +162,6 @@ public class SamlTokenTest extends Abstr
public void testSaml1TokenSignedSenderVouches() throws Exception {
Map<String, Object> outProperties = new HashMap<String, Object>();
outProperties.put(WSHandlerConstants.ACTION,
WSHandlerConstants.SAML_TOKEN_SIGNED);
- outProperties.put(WSHandlerConstants.SAML_PROP_FILE,
"saml_sv.properties");
outProperties.put(WSHandlerConstants.SIG_KEY_ID, "DirectReference");
outProperties.put(WSHandlerConstants.USER, "myalias");
outProperties.put("password", "myAliasPassword");
@@ -177,7 +174,7 @@ public class SamlTokenTest extends Abstr
WSHandlerConstants.ACTION,
WSHandlerConstants.SAML_TOKEN_UNSIGNED + " " +
WSHandlerConstants.SIGNATURE
);
- inProperties.put(WSHandlerConstants.SIG_PROP_FILE,
"insecurity.properties");
+ inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,
"insecurity.properties");
final Map<QName, Object> customMap = new HashMap<QName, Object>();
CustomSamlValidator validator = new CustomSamlValidator();
customMap.put(WSSecurityEngine.SAML_TOKEN, validator);
@@ -212,7 +209,6 @@ public class SamlTokenTest extends Abstr
public void testSaml2TokenSignedSenderVouches() throws Exception {
Map<String, Object> outProperties = new HashMap<String, Object>();
outProperties.put(WSHandlerConstants.ACTION,
WSHandlerConstants.SAML_TOKEN_SIGNED);
- outProperties.put(WSHandlerConstants.SAML_PROP_FILE,
"saml_sv.properties");
outProperties.put(WSHandlerConstants.SIG_KEY_ID, "DirectReference");
outProperties.put(WSHandlerConstants.USER, "myalias");
outProperties.put("password", "myAliasPassword");
@@ -225,7 +221,7 @@ public class SamlTokenTest extends Abstr
WSHandlerConstants.ACTION,
WSHandlerConstants.SAML_TOKEN_UNSIGNED + " " +
WSHandlerConstants.SIGNATURE
);
- inProperties.put(WSHandlerConstants.SIG_PROP_FILE,
"insecurity.properties");
+ inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,
"insecurity.properties");
final Map<QName, Object> customMap = new HashMap<QName, Object>();
CustomSamlValidator validator = new CustomSamlValidator();
validator.setRequireSAML1Assertion(false);
@@ -262,7 +258,6 @@ public class SamlTokenTest extends Abstr
public void testSaml1TokenHOK() throws Exception {
Map<String, Object> outProperties = new HashMap<String, Object>();
outProperties.put(WSHandlerConstants.ACTION,
WSHandlerConstants.SAML_TOKEN_SIGNED);
- outProperties.put(WSHandlerConstants.SAML_PROP_FILE,
"saml_hok.properties");
outProperties.put(WSHandlerConstants.SIG_KEY_ID, "DirectReference");
outProperties.put(WSHandlerConstants.USER, "alice");
outProperties.put("password", "password");
@@ -278,7 +273,7 @@ public class SamlTokenTest extends Abstr
WSHandlerConstants.ACTION,
WSHandlerConstants.SAML_TOKEN_SIGNED + " " +
WSHandlerConstants.SIGNATURE
);
- inProperties.put(WSHandlerConstants.SIG_PROP_FILE,
"insecurity.properties");
+ inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,
"insecurity.properties");
final Map<QName, Object> customMap = new HashMap<QName, Object>();
CustomSamlValidator validator = new CustomSamlValidator();
customMap.put(WSSecurityEngine.SAML_TOKEN, validator);
@@ -321,7 +316,6 @@ public class SamlTokenTest extends Abstr
public void testSaml2TokenHOK() throws Exception {
Map<String, Object> outProperties = new HashMap<String, Object>();
outProperties.put(WSHandlerConstants.ACTION,
WSHandlerConstants.SAML_TOKEN_SIGNED);
- outProperties.put(WSHandlerConstants.SAML_PROP_FILE,
"saml_hok.properties");
outProperties.put(WSHandlerConstants.SIG_KEY_ID, "DirectReference");
outProperties.put(WSHandlerConstants.USER, "alice");
outProperties.put("password", "password");
@@ -337,7 +331,7 @@ public class SamlTokenTest extends Abstr
WSHandlerConstants.ACTION,
WSHandlerConstants.SAML_TOKEN_SIGNED + " " +
WSHandlerConstants.SIGNATURE
);
- inProperties.put(WSHandlerConstants.SIG_PROP_FILE,
"insecurity.properties");
+ inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE,
"insecurity.properties");
final Map<QName, Object> customMap = new HashMap<QName, Object>();
CustomSamlValidator validator = new CustomSamlValidator();
customMap.put(WSSecurityEngine.SAML_TOKEN, validator);
@@ -388,7 +382,6 @@ public class SamlTokenTest extends Abstr
public void testSaml2TokenWithRoles() throws Exception {
Map<String, Object> outProperties = new HashMap<String, Object>();
outProperties.put(WSHandlerConstants.ACTION,
WSHandlerConstants.SAML_TOKEN_UNSIGNED);
- outProperties.put(WSHandlerConstants.SAML_PROP_FILE,
"saml_sv.properties");
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(Statement.ATTR);
@@ -438,7 +431,6 @@ public class SamlTokenTest extends Abstr
public void testSaml2TokenWithRolesSingleValue() throws Exception {
Map<String, Object> outProperties = new HashMap<String, Object>();
outProperties.put(WSHandlerConstants.ACTION,
WSHandlerConstants.SAML_TOKEN_UNSIGNED);
- outProperties.put(WSHandlerConstants.SAML_PROP_FILE,
"saml_sv.properties");
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler(false);
callbackHandler.setStatement(Statement.ATTR);
@@ -488,7 +480,6 @@ public class SamlTokenTest extends Abstr
public void testSaml1TokenWithRoles() throws Exception {
Map<String, Object> outProperties = new HashMap<String, Object>();
outProperties.put(WSHandlerConstants.ACTION,
WSHandlerConstants.SAML_TOKEN_UNSIGNED);
- outProperties.put(WSHandlerConstants.SAML_PROP_FILE,
"saml_sv.properties");
SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
callbackHandler.setStatement(Statement.ATTR);