Switching to use security constants in the tests instead of strings
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/428f7700 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/428f7700 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/428f7700 Branch: refs/heads/master Commit: 428f7700de80d4d6ea09158f42d057e9f24abe48 Parents: 0ffcd50 Author: Colm O hEigeartaigh <cohei...@apache.org> Authored: Tue Mar 28 16:27:09 2017 +0100 Committer: Colm O hEigeartaigh <cohei...@apache.org> Committed: Tue Mar 28 16:27:09 2017 +0100 ---------------------------------------------------------------------- .../java/org/apache/cxf/ws/rm/RMManager.java | 2 +- .../systest/sts/custom/CustomParameterTest.java | 16 +-- .../custom_onbehalfof/CustomOnBehalfOfTest.java | 5 +- .../cxf/systest/sts/renew/SAMLRenewTest.java | 2 +- .../SecurityContextTokenCancelTest.java | 2 +- .../sts/sendervouches/DoubleItPortTypeImpl.java | 3 +- .../sts/symmetric/SymmetricBindingTest.java | 8 +- .../cxf/systest/sts/template/TemplateTest.java | 4 +- .../sts/transport/TransportBindingTest.java | 4 +- .../UsernameActAsCachingTest.java | 34 +++--- .../sts/username_actas/UsernameActAsTest.java | 7 +- .../UsernameOnBehalfOfCachingTest.java | 34 +++--- .../UsernameOnBehalfOfTest.java | 7 +- .../security/oauth2/grants/JAXRSOAuth2Test.java | 9 +- .../saml/JAXRSSamlAuthorizationTest.java | 3 +- .../jaxrs/security/xml/JAXRSXmlSecTest.java | 113 ++++++++++--------- .../ws/rm/sec/WSRMWithWSSecurityPolicyTest.java | 16 +-- .../apache/cxf/systest/ws/fault/FaultTest.java | 31 ++--- .../ws/policy/handler/HelloServiceImpl.java | 7 +- .../cxf/systest/ws/saml/SamlTokenTest.java | 62 +++++----- .../saml/subjectconf/SamlSubjectConfTest.java | 19 ++-- .../cxf/systest/ws/wssc/WSSCUnitTest.java | 17 +-- .../systest/ws/x509/DoubleItPropertiesImpl.java | 9 +- 23 files changed, 214 insertions(+), 200 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java ---------------------------------------------------------------------- diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java index ecf41f9..0f1ac27 100644 --- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java +++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java @@ -475,7 +475,7 @@ public class RMManager { Map<String, Object> context = new HashMap<>(16); for (String key : message.getContextualPropertyKeys()) { //copy other properties? - if (key.startsWith("ws-security")) { + if (key.startsWith("ws-security") || key.startsWith("security.")) { context.put(key, message.getContextualProperty(key)); } } http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/custom/CustomParameterTest.java ---------------------------------------------------------------------- diff --git a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/custom/CustomParameterTest.java b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/custom/CustomParameterTest.java index f59f1e3..f6ff291 100644 --- a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/custom/CustomParameterTest.java +++ b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/custom/CustomParameterTest.java @@ -98,8 +98,8 @@ public class CustomParameterTest extends AbstractBusClientServerTestBase { stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}UT_Port"); Map<String, Object> properties = new HashMap<>(); - properties.put("security.username", "alice"); - properties.put("security.callback-handler", "org.apache.cxf.systest.sts.common.CommonCallbackHandler"); + properties.put(SecurityConstants.USERNAME, "alice"); + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler"); properties.put("security.sts.token.username", "myclientkey"); properties.put("security.sts.token.properties", "clientKeystore.properties"); properties.put("security.sts.token.usecert", "true"); @@ -143,8 +143,8 @@ public class CustomParameterTest extends AbstractBusClientServerTestBase { stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}UT_Port"); Map<String, Object> properties = new HashMap<>(); - properties.put("security.username", "alice"); - properties.put("security.callback-handler", "org.apache.cxf.systest.sts.common.CommonCallbackHandler"); + properties.put(SecurityConstants.USERNAME, "alice"); + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler"); properties.put("security.sts.token.username", "myclientkey"); properties.put("security.sts.token.properties", "clientKeystore.properties"); properties.put("security.sts.token.usecert", "true"); @@ -193,8 +193,8 @@ public class CustomParameterTest extends AbstractBusClientServerTestBase { stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}Transport_Port"); Map<String, Object> properties = new HashMap<>(); - properties.put("security.username", "alice"); - properties.put("security.callback-handler", "org.apache.cxf.systest.sts.common.CommonCallbackHandler"); + properties.put(SecurityConstants.USERNAME, "alice"); + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler"); properties.put("security.sts.token.username", "myclientkey"); properties.put("security.sts.token.properties", "clientKeystore.properties"); properties.put("security.sts.token.usecert", "true"); @@ -238,8 +238,8 @@ public class CustomParameterTest extends AbstractBusClientServerTestBase { stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}Transport_Port"); Map<String, Object> properties = new HashMap<>(); - properties.put("security.username", "alice"); - properties.put("security.callback-handler", "org.apache.cxf.systest.sts.common.CommonCallbackHandler"); + properties.put(SecurityConstants.USERNAME, "alice"); + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler"); properties.put("security.sts.token.username", "myclientkey"); properties.put("security.sts.token.properties", "clientKeystore.properties"); properties.put("security.sts.token.usecert", "true"); http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/custom_onbehalfof/CustomOnBehalfOfTest.java ---------------------------------------------------------------------- diff --git a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/custom_onbehalfof/CustomOnBehalfOfTest.java b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/custom_onbehalfof/CustomOnBehalfOfTest.java index e0a988f..f4e6902 100644 --- a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/custom_onbehalfof/CustomOnBehalfOfTest.java +++ b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/custom_onbehalfof/CustomOnBehalfOfTest.java @@ -26,6 +26,7 @@ import javax.xml.ws.Service; import org.apache.cxf.Bus; import org.apache.cxf.bus.spring.SpringBusFactory; +import org.apache.cxf.rt.security.SecurityConstants; import org.apache.cxf.systest.sts.common.SecurityTestUtil; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; @@ -35,7 +36,7 @@ import org.junit.BeforeClass; /** * In this test case, a CXF client requests a Security Token from an STS, passing a username that * it has obtained from an unknown client as an "OnBehalfOf" element. This username is obtained - * by parsing the "security.username" property. The client then invokes on the service + * by parsing the SecurityConstants.USERNAME property. The client then invokes on the service * provider using the returned (custom BinarySecurityToken) token from the STS. The service * provider dispatches the received BinarySecurityToken to the STS for validation, and receives * a transformed SAML Token in response. @@ -89,7 +90,7 @@ public class CustomOnBehalfOfTest extends AbstractBusClientServerTestBase { // Transport port ((BindingProvider)transportPort).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); doubleIt(transportPort, 25); http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/renew/SAMLRenewTest.java ---------------------------------------------------------------------- diff --git a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/renew/SAMLRenewTest.java b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/renew/SAMLRenewTest.java index 96f401e..f1c836c 100644 --- a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/renew/SAMLRenewTest.java +++ b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/renew/SAMLRenewTest.java @@ -111,7 +111,7 @@ public class SAMLRenewTest extends AbstractBusClientServerTestBase { updateAddressPort(saml2IntermediaryPort, PORT); ((BindingProvider)saml2IntermediaryPort).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); // Make initial successful invocation(s) http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/secure_conv/SecurityContextTokenCancelTest.java ---------------------------------------------------------------------- diff --git a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/secure_conv/SecurityContextTokenCancelTest.java b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/secure_conv/SecurityContextTokenCancelTest.java index 9c11236..58cebf8 100644 --- a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/secure_conv/SecurityContextTokenCancelTest.java +++ b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/secure_conv/SecurityContextTokenCancelTest.java @@ -97,7 +97,7 @@ public class SecurityContextTokenCancelTest extends AbstractBusClientServerTestB Map<String, Object> properties = new HashMap<>(); properties.put(SecurityConstants.USERNAME, "alice"); properties.put( - "security.callback-handler", + SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler" ); properties.put("ws-security.sts.token.properties", "serviceKeystore.properties"); http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/sendervouches/DoubleItPortTypeImpl.java ---------------------------------------------------------------------- diff --git a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/sendervouches/DoubleItPortTypeImpl.java b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/sendervouches/DoubleItPortTypeImpl.java index 5bb0d95..4eaf08b 100644 --- a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/sendervouches/DoubleItPortTypeImpl.java +++ b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/sendervouches/DoubleItPortTypeImpl.java @@ -28,6 +28,7 @@ import javax.xml.ws.Service; import javax.xml.ws.WebServiceContext; import org.apache.cxf.feature.Features; +import org.apache.cxf.rt.security.SecurityConstants; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; import org.example.contract.doubleit.DoubleItPortType; @@ -63,7 +64,7 @@ public class DoubleItPortTypeImpl extends AbstractBusClientServerTestBase implem // Saml2CallbackHandler callbackHandler = new Saml2CallbackHandler(wsc.getUserPrincipal()); ((BindingProvider)transportSAML2SupportingPort).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); return transportSAML2SupportingPort.doubleIt(numberToDouble); http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/symmetric/SymmetricBindingTest.java ---------------------------------------------------------------------- diff --git a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/symmetric/SymmetricBindingTest.java b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/symmetric/SymmetricBindingTest.java index 638cac0..44e136d 100644 --- a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/symmetric/SymmetricBindingTest.java +++ b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/symmetric/SymmetricBindingTest.java @@ -353,11 +353,11 @@ public class SymmetricBindingTest extends AbstractBusClientServerTestBase { stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}UT_Port"); Map<String, Object> properties = new HashMap<>(); - properties.put("security.username", "alice"); - properties.put("security.callback-handler", + properties.put(SecurityConstants.USERNAME, "alice"); + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler"); - properties.put("security.encryption.username", "mystskey"); - properties.put("security.encryption.properties", "clientKeystore.properties"); + properties.put(SecurityConstants.ENCRYPT_USERNAME, "mystskey"); + properties.put(SecurityConstants.ENCRYPT_PROPERTIES, "clientKeystore.properties"); properties.put("ws-security.is-bsp-compliant", "false"); stsClient.setProperties(properties); http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/template/TemplateTest.java ---------------------------------------------------------------------- diff --git a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/template/TemplateTest.java b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/template/TemplateTest.java index b98c7b6..b8dd073 100644 --- a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/template/TemplateTest.java +++ b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/template/TemplateTest.java @@ -348,8 +348,8 @@ public class TemplateTest extends AbstractBusClientServerTestBase { stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}Transport_Port"); Map<String, Object> properties = new HashMap<>(); - properties.put("security.username", "alice"); - properties.put("security.callback-handler", + properties.put(SecurityConstants.USERNAME, "alice"); + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler"); properties.put("ws-security.sts.token.username", "myclientkey"); properties.put("ws-security.sts.token.properties", "clientKeystore.properties"); http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/transport/TransportBindingTest.java ---------------------------------------------------------------------- diff --git a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/transport/TransportBindingTest.java b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/transport/TransportBindingTest.java index d190577..fe42d38 100644 --- a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/transport/TransportBindingTest.java +++ b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/transport/TransportBindingTest.java @@ -437,8 +437,8 @@ public class TransportBindingTest extends AbstractBusClientServerTestBase { stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}Transport_Port"); Map<String, Object> properties = new HashMap<>(); - properties.put("security.username", "alice"); - properties.put("security.callback-handler", + properties.put(SecurityConstants.USERNAME, "alice"); + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler"); properties.put("ws-security.sts.token.username", "myclientkey"); properties.put("ws-security.sts.token.properties", "clientKeystore.properties"); http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/UsernameActAsCachingTest.java ---------------------------------------------------------------------- diff --git a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/UsernameActAsCachingTest.java b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/UsernameActAsCachingTest.java index 6907fae..cc496d7 100644 --- a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/UsernameActAsCachingTest.java +++ b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/UsernameActAsCachingTest.java @@ -44,7 +44,7 @@ import org.junit.BeforeClass; /** * In this test case, a CXF client requests a Security Token from an STS, passing a username that * it has obtained from an unknown client as an "ActAs" element. This username is obtained - * by parsing the "security.username" property. The client then invokes on the service + * by parsing the SecurityConstants.USERNAME property. The client then invokes on the service * provider using the returned token from the STS. */ public class UsernameActAsCachingTest extends AbstractBusClientServerTestBase { @@ -109,7 +109,7 @@ public class UsernameActAsCachingTest extends AbstractBusClientServerTestBase { // Make a successful invocation ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); doubleIt(port, 25); @@ -145,7 +145,7 @@ public class UsernameActAsCachingTest extends AbstractBusClientServerTestBase { p.getRequestContext().put(TokenStore.class.getName(), tokenStore); // Make another invocation - this should succeed as the token is cached - p.getRequestContext().put("security.username", "alice"); + p.getRequestContext().put(SecurityConstants.USERNAME, "alice"); doubleIt(port2, 40); // Reset the cache - this invocation should fail @@ -192,17 +192,17 @@ public class UsernameActAsCachingTest extends AbstractBusClientServerTestBase { // Make a successful invocation ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); doubleIt(port, 25); ((BindingProvider)port).getRequestContext().put( - "security.username", "bob" + SecurityConstants.USERNAME, "bob" ); doubleIt(port, 30); ((BindingProvider)port).getRequestContext().put( - "security.username", "eve" + SecurityConstants.USERNAME, "eve" ); try { doubleIt(port, 30); @@ -217,17 +217,17 @@ public class UsernameActAsCachingTest extends AbstractBusClientServerTestBase { // Make a successful invocation ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); doubleIt(port, 25); ((BindingProvider)port).getRequestContext().put( - "security.username", "bob" + SecurityConstants.USERNAME, "bob" ); doubleIt(port, 30); ((BindingProvider)port).getRequestContext().put( - "security.username", "eve2" + SecurityConstants.USERNAME, "eve2" ); try { doubleIt(port, 30); @@ -239,7 +239,7 @@ public class UsernameActAsCachingTest extends AbstractBusClientServerTestBase { // Reset the cache - this invocation should fail p.getRequestContext().put(TokenStore.class.getName(), new MemoryTokenStore()); ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); try { doubleIt(port, 30); @@ -282,7 +282,7 @@ public class UsernameActAsCachingTest extends AbstractBusClientServerTestBase { // Make a successful invocation ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); BindingProvider p = (BindingProvider)port; p.getRequestContext().put( @@ -293,7 +293,7 @@ public class UsernameActAsCachingTest extends AbstractBusClientServerTestBase { // Make a successful invocation ((BindingProvider)port).getRequestContext().put( - "security.username", "bob" + SecurityConstants.USERNAME, "bob" ); p.getRequestContext().put( SecurityConstants.STS_APPLIES_TO, @@ -306,7 +306,7 @@ public class UsernameActAsCachingTest extends AbstractBusClientServerTestBase { // Make a successful invocation - should work as token is cached ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); p.getRequestContext().put( SecurityConstants.STS_APPLIES_TO, @@ -316,7 +316,7 @@ public class UsernameActAsCachingTest extends AbstractBusClientServerTestBase { // Make a successful invocation - should work as token is cached ((BindingProvider)port).getRequestContext().put( - "security.username", "bob" + SecurityConstants.USERNAME, "bob" ); p.getRequestContext().put( SecurityConstants.STS_APPLIES_TO, @@ -326,7 +326,7 @@ public class UsernameActAsCachingTest extends AbstractBusClientServerTestBase { // Change appliesTo - should fail ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); p.getRequestContext().put( SecurityConstants.STS_APPLIES_TO, @@ -373,7 +373,7 @@ public class UsernameActAsCachingTest extends AbstractBusClientServerTestBase { // Make a successful invocation ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); // Disable appliesTo BindingProvider p = (BindingProvider)port; @@ -392,7 +392,7 @@ public class UsernameActAsCachingTest extends AbstractBusClientServerTestBase { // Bob should fail ((BindingProvider)port).getRequestContext().put( - "security.username", "bob" + SecurityConstants.USERNAME, "bob" ); try { doubleIt(port, 30); http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/UsernameActAsTest.java ---------------------------------------------------------------------- diff --git a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/UsernameActAsTest.java b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/UsernameActAsTest.java index d3a064a..6caf9b4 100644 --- a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/UsernameActAsTest.java +++ b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/UsernameActAsTest.java @@ -28,6 +28,7 @@ import javax.xml.ws.Service; import org.apache.cxf.Bus; import org.apache.cxf.bus.spring.SpringBusFactory; +import org.apache.cxf.rt.security.SecurityConstants; import org.apache.cxf.systest.sts.common.SecurityTestUtil; import org.apache.cxf.systest.sts.common.TestParam; import org.apache.cxf.systest.sts.common.TokenTestUtils; @@ -43,7 +44,7 @@ import org.junit.runners.Parameterized.Parameters; /** * In this test case, a CXF client requests a Security Token from an STS, passing a username that * it has obtained from an unknown client as an "ActAs" element. This username is obtained - * by parsing the "security.username" property. The client then invokes on the service + * by parsing the SecurityConstants.USERNAME property. The client then invokes on the service * provider using the returned token from the STS. */ @RunWith(value = org.junit.runners.Parameterized.class) @@ -126,7 +127,7 @@ public class UsernameActAsTest extends AbstractBusClientServerTestBase { // Transport port ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); doubleIt(port, 25); @@ -144,7 +145,7 @@ public class UsernameActAsTest extends AbstractBusClientServerTestBase { } ((BindingProvider)port2).getRequestContext().put( - "security.username", "eve" + SecurityConstants.USERNAME, "eve" ); // This time we expect a failure as the server validator doesn't accept "eve". try { http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameOnBehalfOfCachingTest.java ---------------------------------------------------------------------- diff --git a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameOnBehalfOfCachingTest.java b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameOnBehalfOfCachingTest.java index afeed9e..583dbe7 100644 --- a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameOnBehalfOfCachingTest.java +++ b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameOnBehalfOfCachingTest.java @@ -43,7 +43,7 @@ import org.junit.BeforeClass; /** * In this test case, a CXF client requests a Security Token from an STS, passing a username that * it has obtained from an unknown client as an "OnBehalfOf" element. This username is obtained - * by parsing the "security.username" property. The client then invokes on the service + * by parsing the SecurityConstants.USERNAME property. The client then invokes on the service * provider using the returned token from the STS. */ public class UsernameOnBehalfOfCachingTest extends AbstractBusClientServerTestBase { @@ -108,7 +108,7 @@ public class UsernameOnBehalfOfCachingTest extends AbstractBusClientServerTestBa // Make a successful invocation ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); doubleIt(port, 25); @@ -145,7 +145,7 @@ public class UsernameOnBehalfOfCachingTest extends AbstractBusClientServerTestBa p.getRequestContext().put(TokenStore.class.getName(), tokenStore); // Make another invocation - this should succeed as the token is cached - p.getRequestContext().put("security.username", "alice"); + p.getRequestContext().put(SecurityConstants.USERNAME, "alice"); doubleIt(port2, 40); // Reset the cache - this invocation should fail @@ -192,17 +192,17 @@ public class UsernameOnBehalfOfCachingTest extends AbstractBusClientServerTestBa // Make a successful invocation ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); doubleIt(port, 25); ((BindingProvider)port).getRequestContext().put( - "security.username", "bob" + SecurityConstants.USERNAME, "bob" ); doubleIt(port, 30); ((BindingProvider)port).getRequestContext().put( - "security.username", "eve" + SecurityConstants.USERNAME, "eve" ); try { doubleIt(port, 30); @@ -217,17 +217,17 @@ public class UsernameOnBehalfOfCachingTest extends AbstractBusClientServerTestBa // Make a successful invocation ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); doubleIt(port, 25); ((BindingProvider)port).getRequestContext().put( - "security.username", "bob" + SecurityConstants.USERNAME, "bob" ); doubleIt(port, 30); ((BindingProvider)port).getRequestContext().put( - "security.username", "eve2" + SecurityConstants.USERNAME, "eve2" ); try { doubleIt(port, 30); @@ -239,7 +239,7 @@ public class UsernameOnBehalfOfCachingTest extends AbstractBusClientServerTestBa // Reset the cache - this invocation should fail p.getRequestContext().put(TokenStore.class.getName(), new MemoryTokenStore()); ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); try { doubleIt(port, 30); @@ -282,7 +282,7 @@ public class UsernameOnBehalfOfCachingTest extends AbstractBusClientServerTestBa // Make a successful invocation ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); BindingProvider p = (BindingProvider)port; p.getRequestContext().put( @@ -293,7 +293,7 @@ public class UsernameOnBehalfOfCachingTest extends AbstractBusClientServerTestBa // Make a successful invocation ((BindingProvider)port).getRequestContext().put( - "security.username", "bob" + SecurityConstants.USERNAME, "bob" ); p.getRequestContext().put( SecurityConstants.STS_APPLIES_TO, @@ -306,7 +306,7 @@ public class UsernameOnBehalfOfCachingTest extends AbstractBusClientServerTestBa // Make a successful invocation - should work as token is cached ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); p.getRequestContext().put( SecurityConstants.STS_APPLIES_TO, @@ -316,7 +316,7 @@ public class UsernameOnBehalfOfCachingTest extends AbstractBusClientServerTestBa // Make a successful invocation - should work as token is cached ((BindingProvider)port).getRequestContext().put( - "security.username", "bob" + SecurityConstants.USERNAME, "bob" ); p.getRequestContext().put( SecurityConstants.STS_APPLIES_TO, @@ -326,7 +326,7 @@ public class UsernameOnBehalfOfCachingTest extends AbstractBusClientServerTestBa // Change appliesTo - should fail ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); p.getRequestContext().put( SecurityConstants.STS_APPLIES_TO, @@ -373,7 +373,7 @@ public class UsernameOnBehalfOfCachingTest extends AbstractBusClientServerTestBa // Make a successful invocation ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); // Disable appliesTo BindingProvider p = (BindingProvider)port; @@ -392,7 +392,7 @@ public class UsernameOnBehalfOfCachingTest extends AbstractBusClientServerTestBa // Bob should fail ((BindingProvider)port).getRequestContext().put( - "security.username", "bob" + SecurityConstants.USERNAME, "bob" ); try { doubleIt(port, 30); http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameOnBehalfOfTest.java ---------------------------------------------------------------------- diff --git a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameOnBehalfOfTest.java b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameOnBehalfOfTest.java index 9616f39..d7874e4 100644 --- a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameOnBehalfOfTest.java +++ b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameOnBehalfOfTest.java @@ -28,6 +28,7 @@ import javax.xml.ws.Service; import org.apache.cxf.Bus; import org.apache.cxf.bus.spring.SpringBusFactory; +import org.apache.cxf.rt.security.SecurityConstants; import org.apache.cxf.systest.sts.common.SecurityTestUtil; import org.apache.cxf.systest.sts.common.TestParam; import org.apache.cxf.systest.sts.common.TokenTestUtils; @@ -42,7 +43,7 @@ import org.junit.runners.Parameterized.Parameters; /** * In this test case, a CXF client requests a Security Token from an STS, passing a username that * it has obtained from an unknown client as an "OnBehalfOf" element. This username is obtained - * by parsing the "security.username" property. The client then invokes on the service + * by parsing the SecurityConstants.USERNAME property. The client then invokes on the service * provider using the returned token from the STS. */ @RunWith(value = org.junit.runners.Parameterized.class) @@ -124,7 +125,7 @@ public class UsernameOnBehalfOfTest extends AbstractBusClientServerTestBase { // Transport port ((BindingProvider)port).getRequestContext().put( - "security.username", "alice" + SecurityConstants.USERNAME, "alice" ); doubleIt(port, 25); @@ -142,7 +143,7 @@ public class UsernameOnBehalfOfTest extends AbstractBusClientServerTestBase { } ((BindingProvider)port2).getRequestContext().put( - "security.username", "eve" + SecurityConstants.USERNAME, "eve" ); // This time we expect a failure as the server validator doesn't accept "eve". try { http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/grants/JAXRSOAuth2Test.java ---------------------------------------------------------------------- diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/grants/JAXRSOAuth2Test.java b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/grants/JAXRSOAuth2Test.java index b81015d..901063a 100644 --- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/grants/JAXRSOAuth2Test.java +++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth2/grants/JAXRSOAuth2Test.java @@ -50,6 +50,7 @@ import org.apache.cxf.rs.security.oauth2.saml.Constants; import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants; import org.apache.cxf.rs.security.saml.SAMLUtils; import org.apache.cxf.rs.security.saml.SAMLUtils.SelfSignInfo; +import org.apache.cxf.rt.security.SecurityConstants; import org.apache.cxf.systest.jaxrs.security.oauth2.common.OAuth2TestUtils; import org.apache.cxf.systest.jaxrs.security.oauth2.common.SamlCallbackHandler; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; @@ -482,17 +483,17 @@ public class JAXRSOAuth2Test extends AbstractBusClientServerTestBase { bean.setBus(springBus); Map<String, Object> properties = new HashMap<>(); - properties.put("security.callback-handler", + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); SamlCallbackHandler samlCallbackHandler = new SamlCallbackHandler(true); samlCallbackHandler.setIssuer("alice"); String audienceURI = "https://localhost:" + PORT + "/oauth2-auth/token"; samlCallbackHandler.setAudience(audienceURI); - properties.put("security.saml-callback-handler", samlCallbackHandler); + properties.put(SecurityConstants.SAML_CALLBACK_HANDLER, samlCallbackHandler); - properties.put("security.signature.username", "alice"); - properties.put("security.signature.properties", CRYPTO_RESOURCE_PROPERTIES); + properties.put(SecurityConstants.SIGNATURE_USERNAME, "alice"); + properties.put(SecurityConstants.SIGNATURE_PROPERTIES, CRYPTO_RESOURCE_PROPERTIES); bean.setProperties(properties); bean.getOutInterceptors().add(new Saml2BearerAuthOutInterceptor()); http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/saml/JAXRSSamlAuthorizationTest.java ---------------------------------------------------------------------- diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/saml/JAXRSSamlAuthorizationTest.java b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/saml/JAXRSSamlAuthorizationTest.java index bb6340e..7c00fa2 100644 --- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/saml/JAXRSSamlAuthorizationTest.java +++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/saml/JAXRSSamlAuthorizationTest.java @@ -32,6 +32,7 @@ import org.apache.cxf.bus.spring.SpringBusFactory; import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean; import org.apache.cxf.jaxrs.client.WebClient; import org.apache.cxf.rs.security.saml.SamlEnvelopedOutInterceptor; +import org.apache.cxf.rt.security.SecurityConstants; import org.apache.cxf.systest.jaxrs.security.Book; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; @@ -154,7 +155,7 @@ public class JAXRSSamlAuthorizationTest extends AbstractBusClientServerTestBase bean.setBus(springBus); Map<String, Object> properties = new HashMap<>(); - properties.put("security.saml-callback-handler", + properties.put(SecurityConstants.SAML_CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.SamlCallbackHandler"); if (extraProperties != null) { properties.putAll(extraProperties); http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java ---------------------------------------------------------------------- diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java index 67abc0c..ea6f547 100644 --- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java +++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java @@ -41,6 +41,7 @@ import org.apache.cxf.rs.security.xml.XmlSecInInterceptor; import org.apache.cxf.rs.security.xml.XmlSecOutInterceptor; import org.apache.cxf.rs.security.xml.XmlSigInInterceptor; import org.apache.cxf.rs.security.xml.XmlSigOutInterceptor; +import org.apache.cxf.rt.security.SecurityConstants; import org.apache.cxf.systest.jaxrs.security.Book; import org.apache.cxf.systest.jaxrs.security.BookStore; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; @@ -98,12 +99,12 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase { bean.setBus(springBus); Map<String, Object> newProperties = new HashMap<>(); - newProperties.put("ws-security.callback-handler", + newProperties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); - newProperties.put("ws-security.signature.username", "alice"); + newProperties.put(SecurityConstants.SIGNATURE_USERNAME, "alice"); String cryptoUrl = "org/apache/cxf/systest/jaxrs/security/alice.properties"; - newProperties.put("ws-security.signature.properties", cryptoUrl); + newProperties.put(SecurityConstants.SIGNATURE_PROPERTIES, cryptoUrl); bean.setProperties(newProperties); if (test.streaming) { @@ -143,22 +144,22 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase { // Successful test with "bob" Map<String, Object> newProperties = new HashMap<>(); - newProperties.put("security.callback-handler", + newProperties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); - newProperties.put("security.signature.username", "bob"); + newProperties.put(SecurityConstants.SIGNATURE_USERNAME, "bob"); String cryptoUrl = "org/apache/cxf/systest/jaxrs/security/bob.properties"; - newProperties.put("security.signature.properties", cryptoUrl); + newProperties.put(SecurityConstants.SIGNATURE_PROPERTIES, cryptoUrl); doTestSignatureProxy(address, false, null, test.streaming, newProperties); // Constraint validation fails with "alice" newProperties.clear(); - newProperties.put("security.callback-handler", + newProperties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); - newProperties.put("security.signature.username", "alice"); + newProperties.put(SecurityConstants.SIGNATURE_USERNAME, "alice"); cryptoUrl = "org/apache/cxf/systest/jaxrs/security/alice.properties"; - newProperties.put("security.signature.properties", cryptoUrl); + newProperties.put(SecurityConstants.SIGNATURE_PROPERTIES, cryptoUrl); try { doTestSignatureProxy(address, false, null, test.streaming, newProperties); fail("Failure expected on a failing cert constraint"); @@ -186,15 +187,15 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase { Map<String, Object> newProperties = new HashMap<>(properties); if (newProperties.isEmpty()) { - newProperties.put("security.callback-handler", + newProperties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); - newProperties.put("security.signature.username", "alice"); + newProperties.put(SecurityConstants.SIGNATURE_USERNAME, "alice"); String cryptoUrl = "org/apache/cxf/systest/jaxrs/security/alice.properties"; if (cryptoUrlPrefix != null) { cryptoUrl = cryptoUrlPrefix + this.getClass().getResource("/" + cryptoUrl).toURI().getPath(); } - newProperties.put("security.signature.properties", cryptoUrl); + newProperties.put(SecurityConstants.SIGNATURE_PROPERTIES, cryptoUrl); } bean.setProperties(newProperties); @@ -262,10 +263,10 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase { bean.setBus(springBus); Map<String, Object> properties = new HashMap<>(); - properties.put("security.callback-handler", + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); - properties.put("security.signature.username", "alice"); - properties.put("security.signature.properties", + properties.put(SecurityConstants.SIGNATURE_USERNAME, "alice"); + properties.put(SecurityConstants.SIGNATURE_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/alice.properties"); bean.setProperties(properties); if (streaming) { @@ -317,10 +318,10 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase { bean.setBus(springBus); Map<String, Object> properties = new HashMap<>(); - properties.put("security.callback-handler", + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); - properties.put("security.signature.username", "bethal"); - properties.put("security.signature.properties", + properties.put(SecurityConstants.SIGNATURE_USERNAME, "bethal"); + properties.put(SecurityConstants.SIGNATURE_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/bethal.properties"); bean.setProperties(properties); if (test.streaming) { @@ -362,10 +363,10 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase { bean.setBus(springBus); Map<String, Object> properties = new HashMap<>(); - properties.put("security.callback-handler", + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); - properties.put("security.signature.username", "bethal"); - properties.put("security.signature.properties", + properties.put(SecurityConstants.SIGNATURE_USERNAME, "bethal"); + properties.put(SecurityConstants.SIGNATURE_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/bethal.properties"); bean.setProperties(properties); if (test.streaming) { @@ -398,10 +399,10 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase { public void testPostEncryptedBook() throws Exception { String address = "https://localhost:" + test.port + "/xmlenc/bookstore/books"; Map<String, Object> properties = new HashMap<>(); - properties.put("security.callback-handler", + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); - properties.put("security.encryption.username", "bob"); - properties.put("security.encryption.properties", + properties.put(SecurityConstants.ENCRYPT_USERNAME, "bob"); + properties.put(SecurityConstants.ENCRYPT_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/bob.properties"); doTestPostEncryptedBook(address, false, properties, test.streaming); } @@ -422,10 +423,10 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase { String address = "https://localhost:" + test.port + "/xmlenc/bookstore/books"; Map<String, Object> properties = new HashMap<>(); - properties.put("security.callback-handler", + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); - properties.put("security.encryption.username", "bob"); - properties.put("security.encryption.properties", + properties.put(SecurityConstants.ENCRYPT_USERNAME, "bob"); + properties.put(SecurityConstants.ENCRYPT_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/bob.properties"); EncryptionProperties encryptionProperties = new EncryptionProperties(); @@ -440,10 +441,10 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase { public void testPostEncryptedBookSHA256() throws Exception { String address = "https://localhost:" + test.port + "/xmlenc/bookstore/books"; Map<String, Object> properties = new HashMap<>(); - properties.put("security.callback-handler", + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); - properties.put("security.encryption.username", "bob"); - properties.put("security.encryption.properties", + properties.put(SecurityConstants.ENCRYPT_USERNAME, "bob"); + properties.put(SecurityConstants.ENCRYPT_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/bob.properties"); EncryptionProperties encryptionProperties = new EncryptionProperties(); @@ -460,10 +461,10 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase { public void testPostEncryptedBookIssuerSerial() throws Exception { String address = "https://localhost:" + test.port + "/xmlenc/bookstore/books"; Map<String, Object> properties = new HashMap<>(); - properties.put("security.callback-handler", + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); - properties.put("security.encryption.username", "bob"); - properties.put("security.encryption.properties", + properties.put(SecurityConstants.ENCRYPT_USERNAME, "bob"); + properties.put(SecurityConstants.ENCRYPT_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/bob.properties"); EncryptionProperties encryptionProperties = new EncryptionProperties(); @@ -479,13 +480,13 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase { public void testPostEncryptedSignedBook() throws Exception { String address = "https://localhost:" + test.port + "/xmlsec-validate/bookstore/books"; Map<String, Object> properties = new HashMap<>(); - properties.put("security.callback-handler", + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); - properties.put("security.encryption.username", "bob"); - properties.put("security.encryption.properties", + properties.put(SecurityConstants.ENCRYPT_USERNAME, "bob"); + properties.put(SecurityConstants.ENCRYPT_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/bob.properties"); - properties.put("security.signature.username", "alice"); - properties.put("security.signature.properties", + properties.put(SecurityConstants.SIGNATURE_USERNAME, "alice"); + properties.put(SecurityConstants.SIGNATURE_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/alice.properties"); doTestPostEncryptedBook(address, true, properties, test.streaming); @@ -495,13 +496,13 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase { public void testPostEncryptedSignedBookInvalid() throws Exception { String address = "https://localhost:" + test.port + "/xmlsec-validate/bookstore/books"; Map<String, Object> properties = new HashMap<>(); - properties.put("security.callback-handler", + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); - properties.put("security.encryption.username", "bob"); - properties.put("security.encryption.properties", + properties.put(SecurityConstants.ENCRYPT_USERNAME, "bob"); + properties.put(SecurityConstants.ENCRYPT_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/bob.properties"); - properties.put("security.signature.username", "alice"); - properties.put("security.signature.properties", + properties.put(SecurityConstants.SIGNATURE_USERNAME, "alice"); + properties.put(SecurityConstants.SIGNATURE_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/alice.properties"); EncryptionProperties encryptionProperties = new EncryptionProperties(); @@ -521,13 +522,13 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase { public void testPostEncryptedSignedBookUseReqSigCert() throws Exception { String address = "https://localhost:" + test.port + "/xmlsec-useReqSigCert/bookstore/books"; Map<String, Object> properties = new HashMap<>(); - properties.put("security.callback-handler", + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); - properties.put("security.encryption.username", "bob"); - properties.put("security.encryption.properties", + properties.put(SecurityConstants.ENCRYPT_USERNAME, "bob"); + properties.put(SecurityConstants.ENCRYPT_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/bob.properties"); - properties.put("security.signature.username", "alice"); - properties.put("security.signature.properties", + properties.put(SecurityConstants.SIGNATURE_USERNAME, "alice"); + properties.put(SecurityConstants.SIGNATURE_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/alice.properties"); doTestPostEncryptedBook(address, true, properties, test.streaming); } @@ -650,12 +651,12 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase { bean.setBus(springBus); Map<String, Object> properties = new HashMap<>(); - properties.put("security.callback-handler", + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); - properties.put("security.encryption.username", "bob"); - properties.put("security.encryption.properties", + properties.put(SecurityConstants.ENCRYPT_USERNAME, "bob"); + properties.put(SecurityConstants.ENCRYPT_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/bob.properties"); - properties.put("security.signature.properties", + properties.put(SecurityConstants.SIGNATURE_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/alice.properties"); bean.setProperties(properties); @@ -694,12 +695,12 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase { bean.setBus(springBus); Map<String, Object> properties = new HashMap<>(); - properties.put("security.callback-handler", + properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"); - properties.put("security.encryption.username", "bob"); - properties.put("security.encryption.properties", + properties.put(SecurityConstants.ENCRYPT_USERNAME, "bob"); + properties.put(SecurityConstants.ENCRYPT_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/bob.properties"); - properties.put("security.signature.properties", + properties.put(SecurityConstants.SIGNATURE_PROPERTIES, "org/apache/cxf/systest/jaxrs/security/alice.properties"); bean.setProperties(properties); http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/sec/WSRMWithWSSecurityPolicyTest.java ---------------------------------------------------------------------- diff --git a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/sec/WSRMWithWSSecurityPolicyTest.java b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/sec/WSRMWithWSSecurityPolicyTest.java index aa392c2..dfd48f7 100644 --- a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/sec/WSRMWithWSSecurityPolicyTest.java +++ b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/sec/WSRMWithWSSecurityPolicyTest.java @@ -33,6 +33,7 @@ import org.apache.cxf.endpoint.Client; import org.apache.cxf.frontend.ClientProxy; import org.apache.cxf.greeter_control.Greeter; import org.apache.cxf.greeter_control.types.GreetMe; +import org.apache.cxf.rt.security.SecurityConstants; import org.apache.cxf.service.model.BindingOperationInfo; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; import org.apache.cxf.testutil.common.AbstractBusTestServerBase; @@ -45,7 +46,7 @@ import org.junit.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; /** - * Tests the correct interaction of ws-rm calls with ws-security when policy validator verifies the calls. + * Tests the correct interaction of ws-rm calls with security.when policy validator verifies the calls. */ public class WSRMWithWSSecurityPolicyTest extends AbstractBusClientServerTestBase { public static final String PORT = allocatePort(Server.class); @@ -110,12 +111,13 @@ public class WSRMWithWSSecurityPolicyTest extends AbstractBusClientServerTestBas invocationContext.put(Client.REQUEST_CONTEXT, requestContext); invocationContext.put(Client.RESPONSE_CONTEXT, responseContext); - requestContext.put("ws-security.username", "Alice"); - requestContext.put("ws-security.callback-handler", "org.apache.cxf.systest.ws.rm.sec.UTPasswordCallback"); - requestContext.put("ws-security.encryption.properties", "bob.properties"); - requestContext.put("ws-security.encryption.username", "bob"); - requestContext.put("ws-security.signature.properties", "alice.properties"); - requestContext.put("ws-security.signature.username", "alice"); + requestContext.put(SecurityConstants.USERNAME, "Alice"); + requestContext.put(SecurityConstants.CALLBACK_HANDLER, + "org.apache.cxf.systest.ws.rm.sec.UTPasswordCallback"); + requestContext.put(SecurityConstants.ENCRYPT_PROPERTIES, "bob.properties"); + requestContext.put(SecurityConstants.ENCRYPT_USERNAME, "bob"); + requestContext.put(SecurityConstants.SIGNATURE_PROPERTIES, "alice.properties"); + requestContext.put(SecurityConstants.SIGNATURE_USERNAME, "alice"); RMManager manager = bus.getExtension(RMManager.class); boolean empty = manager.getRetransmissionQueue().isEmpty(); assertTrue("RetransmissionQueue is not empty", empty); http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java index aee2111..7fc8353 100644 --- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java +++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java @@ -37,6 +37,7 @@ import org.apache.cxf.BusFactory; import org.apache.cxf.bus.spring.SpringBusFactory; import org.apache.cxf.endpoint.Client; import org.apache.cxf.jaxws.DispatchImpl; +import org.apache.cxf.rt.security.SecurityConstants; import org.apache.cxf.systest.ws.common.SecurityTestUtil; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; import org.apache.wss4j.dom.WSConstants; @@ -86,11 +87,11 @@ public class FaultTest extends AbstractBusClientServerTestBase { updateAddressPort(utPort, PORT); // Make a successful invocation - ((BindingProvider)utPort).getRequestContext().put("security.username", "alice"); + ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "alice"); utPort.doubleIt(25); // Now make an invocation using another username - ((BindingProvider)utPort).getRequestContext().put("security.username", "bob"); + ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "bob"); ((BindingProvider)utPort).getRequestContext().put("security.password", "password"); try { utPort.doubleIt(25); @@ -119,11 +120,11 @@ public class FaultTest extends AbstractBusClientServerTestBase { updateAddressPort(utPort, PORT); // Make a successful invocation - ((BindingProvider)utPort).getRequestContext().put("security.username", "alice"); + ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "alice"); utPort.doubleIt(25); // Now make an invocation using another username - ((BindingProvider)utPort).getRequestContext().put("security.username", "bob"); + ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "bob"); ((BindingProvider)utPort).getRequestContext().put("security.password", "password"); try { utPort.doubleIt(25); @@ -152,11 +153,11 @@ public class FaultTest extends AbstractBusClientServerTestBase { updateAddressPort(utPort, PORT); // Make a successful invocation - ((BindingProvider)utPort).getRequestContext().put("security.username", "alice"); + ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "alice"); utPort.doubleIt(25); // Now make an invocation using another username - ((BindingProvider)utPort).getRequestContext().put("security.username", "bob"); + ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "bob"); ((BindingProvider)utPort).getRequestContext().put("security.password", "password"); try { utPort.doubleIt(25); @@ -195,24 +196,24 @@ public class FaultTest extends AbstractBusClientServerTestBase { // Add WS-Security configuration Client client = ((DispatchImpl<DOMSource>) dispatch).getClient(); client.getRequestContext().put( - "security.callback-handler", + SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.ws.common.KeystorePasswordCallback" ); client.getRequestContext().put( - "security.encryption.properties", + SecurityConstants.ENCRYPT_PROPERTIES, "bob.properties" ); - client.getRequestContext().put("security.encryption.username", "bob"); + client.getRequestContext().put(SecurityConstants.ENCRYPT_USERNAME, "bob"); updateAddressPort(dispatch, PORT); // Make a successful request - client.getRequestContext().put("security.username", "alice"); + client.getRequestContext().put(SecurityConstants.USERNAME, "alice"); DOMSource response = dispatch.invoke(request); assertNotNull(response); // Now make an invocation using another username - client.getRequestContext().put("security.username", "bob"); + client.getRequestContext().put(SecurityConstants.USERNAME, "bob"); client.getRequestContext().put("security.password", "password"); try { dispatch.invoke(request); @@ -242,11 +243,11 @@ public class FaultTest extends AbstractBusClientServerTestBase { updateAddressPort(utPort, PORT); // Make a successful invocation - ((BindingProvider)utPort).getRequestContext().put("security.username", "alice"); + ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "alice"); utPort.doubleIt(25); // Now make an invocation using another username - ((BindingProvider)utPort).getRequestContext().put("security.username", "bob"); + ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "bob"); ((BindingProvider)utPort).getRequestContext().put("security.password", "password"); try { utPort.doubleIt(25); @@ -278,11 +279,11 @@ public class FaultTest extends AbstractBusClientServerTestBase { updateAddressPort(utPort, PORT); // Make a successful invocation - ((BindingProvider)utPort).getRequestContext().put("security.username", "alice"); + ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "alice"); utPort.doubleIt(25); // Now make an invocation using another username - ((BindingProvider)utPort).getRequestContext().put("security.username", "bob"); + ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "bob"); ((BindingProvider)utPort).getRequestContext().put("security.password", "password"); try { utPort.doubleIt(25); http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/handler/HelloServiceImpl.java ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/handler/HelloServiceImpl.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/handler/HelloServiceImpl.java index ac2e594..38c8f13 100644 --- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/handler/HelloServiceImpl.java +++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/policy/handler/HelloServiceImpl.java @@ -25,14 +25,15 @@ import javax.jws.WebService; import org.apache.cxf.annotations.EndpointProperties; import org.apache.cxf.annotations.EndpointProperty; +import org.apache.cxf.rt.security.SecurityConstants; @WebService(name = "HelloPolicyService", serviceName = "HelloPolicyService") @EndpointProperties(value = { - @EndpointProperty(key = "security.callback-handler", + @EndpointProperty(key = SecurityConstants.CALLBACK_HANDLER, value = "org.apache.cxf.systest.ws.policy.handler.CommonPasswordCallback"), @EndpointProperty(key = "ws-security.is-bsp-compliant", value = "false"), - @EndpointProperty(key = "security.signature.properties", value = "alice.properties"), - @EndpointProperty(key = "security.signature.username", value = "alice") + @EndpointProperty(key = SecurityConstants.SIGNATURE_PROPERTIES, value = "alice.properties"), + @EndpointProperty(key = SecurityConstants.SIGNATURE_USERNAME, value = "alice") }) @HandlerChain(file = "handlers.xml") public class HelloServiceImpl implements HelloService { http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/SamlTokenTest.java ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/SamlTokenTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/SamlTokenTest.java index 313336b..575be41 100644 --- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/SamlTokenTest.java +++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/SamlTokenTest.java @@ -138,7 +138,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { } ((BindingProvider)saml1Port).getRequestContext().put( - "security.saml-callback-handler", new SamlCallbackHandler() + SecurityConstants.SAML_CALLBACK_HANDLER, new SamlCallbackHandler() ); try { saml1Port.doubleIt(25); @@ -149,7 +149,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { } ((BindingProvider)saml1Port).getRequestContext().put( - "security.saml-callback-handler", new SamlCallbackHandler(false) + SecurityConstants.SAML_CALLBACK_HANDLER, new SamlCallbackHandler(false) ); int result = saml1Port.doubleIt(25); assertTrue(result == 50); @@ -160,7 +160,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { updateAddressPort(saml1Port, PORT2); ((BindingProvider)saml1Port).getRequestContext().put( - "security.saml-callback-handler", new SamlCallbackHandler(false) + SecurityConstants.SAML_CALLBACK_HANDLER, new SamlCallbackHandler(false) ); try { @@ -203,7 +203,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { SamlCallbackHandler samlCallbackHandler = new SamlCallbackHandler(false, true); samlCallbackHandler.setConfirmationMethod(SAML1Constants.CONF_BEARER); ((BindingProvider)saml1Port).getRequestContext().put( - "security.saml-callback-handler", samlCallbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, samlCallbackHandler ); int result = saml1Port.doubleIt(25); @@ -242,7 +242,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { SamlCallbackHandler callbackHandler = new SamlCallbackHandler(false, true); callbackHandler.setConfirmationMethod(SAML1Constants.CONF_BEARER); ((BindingProvider)saml1Port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); ((BindingProvider)saml1Port).getRequestContext().put( @@ -296,7 +296,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { } ((BindingProvider)saml1Port).getRequestContext().put( - "security.saml-callback-handler", new SamlElementCallbackHandler(false) + SecurityConstants.SAML_CALLBACK_HANDLER, new SamlElementCallbackHandler(false) ); int result = saml1Port.doubleIt(25); assertTrue(result == 50); @@ -334,7 +334,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { } ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", new SamlCallbackHandler(false) + SecurityConstants.SAML_CALLBACK_HANDLER, new SamlCallbackHandler(false) ); try { saml2Port.doubleIt(25); @@ -347,7 +347,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { SamlCallbackHandler samlCallbackHandler = new SamlCallbackHandler(); samlCallbackHandler.setSignAssertion(true); ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", samlCallbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, samlCallbackHandler ); int result = saml2Port.doubleIt(25); assertTrue(result == 50); @@ -381,7 +381,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { } ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", new SamlCallbackHandler() + SecurityConstants.SAML_CALLBACK_HANDLER, new SamlCallbackHandler() ); try { @@ -425,7 +425,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { } ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", new SamlCallbackHandler(false) + SecurityConstants.SAML_CALLBACK_HANDLER, new SamlCallbackHandler(false) ); try { saml2Port.doubleIt(25); @@ -436,7 +436,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { } ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", new SamlCallbackHandler() + SecurityConstants.SAML_CALLBACK_HANDLER, new SamlCallbackHandler() ); int result = saml2Port.doubleIt(25); assertTrue(result == 50); @@ -447,7 +447,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { updateAddressPort(saml2Port, PORT); ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", new SamlCallbackHandler() + SecurityConstants.SAML_CALLBACK_HANDLER, new SamlCallbackHandler() ); try { @@ -488,7 +488,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { } ((BindingProvider)saml1Port).getRequestContext().put( - "security.saml-callback-handler", new SamlCallbackHandler(false, true) + SecurityConstants.SAML_CALLBACK_HANDLER, new SamlCallbackHandler(false, true) ); int result = saml1Port.doubleIt(25); assertTrue(result == 50); @@ -523,7 +523,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { } ((BindingProvider)saml1Port).getRequestContext().put( - "security.saml-callback-handler", new SamlCallbackHandler(false, true) + SecurityConstants.SAML_CALLBACK_HANDLER, new SamlCallbackHandler(false, true) ); int result = saml1Port.doubleIt(25); assertTrue(result == 50); @@ -556,7 +556,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { SamlCallbackHandler callbackHandler = new SamlCallbackHandler(true, true); callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY); ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); int result = saml2Port.doubleIt(25); assertTrue(result == 50); @@ -590,7 +590,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { if (!test.isStreaming() && PORT.equals(test.getPort())) { SamlCallbackHandler samlCallbackHandler = new SamlCallbackHandler(); ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", samlCallbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, samlCallbackHandler ); int result = saml2Port.doubleIt(25); assertTrue(result == 50); @@ -628,7 +628,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { SamlCallbackHandler callbackHandler = new SamlCallbackHandler(true, true); callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY); ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); int result = saml2Port.doubleIt(25); @@ -667,7 +667,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY); callbackHandler.setKeyInfoIdentifier(CERT_IDENTIFIER.KEY_VALUE); ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); int result = saml2Port.doubleIt(25); @@ -705,7 +705,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { SamlCallbackHandler callbackHandler = new SamlCallbackHandler(true, true); callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY); ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); int result = saml2Port.doubleIt(25); @@ -737,7 +737,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { } ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", new SamlCallbackHandler() + SecurityConstants.SAML_CALLBACK_HANDLER, new SamlCallbackHandler() ); int result = saml2Port.doubleIt(25); assertTrue(result == 50); @@ -771,7 +771,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { // TODO Only working for DOM client + server atm if (!test.isStreaming() && PORT.equals(test.getPort())) { ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", new SamlCallbackHandler() + SecurityConstants.SAML_CALLBACK_HANDLER, new SamlCallbackHandler() ); int result = saml2Port.doubleIt(25); assertTrue(result == 50); @@ -805,7 +805,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { SamlCallbackHandler callbackHandler = new SamlCallbackHandler(true, true); callbackHandler.setConfirmationMethod(SAML2Constants.CONF_BEARER); ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); int result = saml2Port.doubleIt(25); assertTrue(result == 50); @@ -842,7 +842,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { SamlCallbackHandler callbackHandler = new SamlCallbackHandler(true, true); callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY); ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); int result = saml2Port.doubleIt(25); @@ -921,7 +921,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { roleCallbackHandler.setSignAssertion(true); roleCallbackHandler.setRoleName("manager"); ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", roleCallbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, roleCallbackHandler ); int result = saml2Port.doubleIt(25); @@ -963,7 +963,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { // Create a SAML Token with no "OneTimeUse" Condition ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", new SamlCallbackHandler() + SecurityConstants.SAML_CALLBACK_HANDLER, new SamlCallbackHandler() ); Client cxfClient = ClientProxy.getClient(saml2Port); @@ -984,7 +984,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { callbackHandler.setConditions(conditions); ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); cxfClient.getOutInterceptors().remove(cacheInterceptor); @@ -1038,7 +1038,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { SamlCallbackHandler callbackHandler = new SamlCallbackHandler(); callbackHandler.setConditions(conditions); ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); saml2Port.doubleIt(25); @@ -1093,7 +1093,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { SamlCallbackHandler callbackHandler = new SamlCallbackHandler(); callbackHandler.setConditions(conditions); ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); saml2Port.doubleIt(25); @@ -1132,7 +1132,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { SamlCallbackHandler callbackHandler = new SamlCallbackHandler(); callbackHandler.setConditions(conditions); ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); // It should fail with validation enabled @@ -1149,7 +1149,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { updateAddressPort(saml2Port, portNumber); ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); saml2Port.doubleIt(25); } @@ -1184,7 +1184,7 @@ public class SamlTokenTest extends AbstractBusClientServerTestBase { callbackHandler.setDigestAlgorithm(WSConstants.SHA256); callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY); ((BindingProvider)saml2Port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); int result = saml2Port.doubleIt(25); http://git-wip-us.apache.org/repos/asf/cxf/blob/428f7700/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/subjectconf/SamlSubjectConfTest.java ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/subjectconf/SamlSubjectConfTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/subjectconf/SamlSubjectConfTest.java index 19d3b1a..cbf5219 100644 --- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/subjectconf/SamlSubjectConfTest.java +++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/saml/subjectconf/SamlSubjectConfTest.java @@ -29,6 +29,7 @@ import javax.xml.ws.Service; import org.apache.cxf.Bus; import org.apache.cxf.bus.spring.SpringBusFactory; +import org.apache.cxf.rt.security.SecurityConstants; import org.apache.cxf.systest.ws.common.SecurityTestUtil; import org.apache.cxf.systest.ws.common.TestParam; import org.apache.cxf.systest.ws.saml.client.SamlCallbackHandler; @@ -117,7 +118,7 @@ public class SamlSubjectConfTest extends AbstractBusClientServerTestBase { callbackHandler.setCryptoPropertiesFile("morpit.properties"); ((BindingProvider)port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); int result = port.doubleIt(25); assertTrue(result == 50); @@ -131,7 +132,7 @@ public class SamlSubjectConfTest extends AbstractBusClientServerTestBase { callbackHandler.setCryptoPropertiesFile("morpit.properties"); ((BindingProvider)port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); try { port.doubleIt(25); @@ -165,7 +166,7 @@ public class SamlSubjectConfTest extends AbstractBusClientServerTestBase { SamlCallbackHandler callbackHandler = new SamlCallbackHandler(true, true); callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY); ((BindingProvider)port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); try { @@ -205,7 +206,7 @@ public class SamlSubjectConfTest extends AbstractBusClientServerTestBase { callbackHandler.setCryptoPropertiesFile("morpit.properties"); ((BindingProvider)port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); try { port.doubleIt(25); @@ -244,7 +245,7 @@ public class SamlSubjectConfTest extends AbstractBusClientServerTestBase { callbackHandler.setConfirmationMethod(SAML2Constants.CONF_SENDER_VOUCHES); ((BindingProvider)port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); int result = port.doubleIt(25); assertTrue(result == 50); @@ -275,7 +276,7 @@ public class SamlSubjectConfTest extends AbstractBusClientServerTestBase { callbackHandler.setConfirmationMethod(SAML2Constants.CONF_SENDER_VOUCHES); ((BindingProvider)port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); try { port.doubleIt(25); @@ -318,7 +319,7 @@ public class SamlSubjectConfTest extends AbstractBusClientServerTestBase { callbackHandler.setCryptoPropertiesFile("morpit.properties"); ((BindingProvider)port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); int result = port.doubleIt(25); assertTrue(result == 50); @@ -349,7 +350,7 @@ public class SamlSubjectConfTest extends AbstractBusClientServerTestBase { callbackHandler.setConfirmationMethod(SAML2Constants.CONF_BEARER); ((BindingProvider)port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); try { @@ -385,7 +386,7 @@ public class SamlSubjectConfTest extends AbstractBusClientServerTestBase { callbackHandler.setConfirmationMethod("urn:oasis:names:tc:SAML:2.0:cm:custom"); ((BindingProvider)port).getRequestContext().put( - "security.saml-callback-handler", callbackHandler + SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler ); try {