use of org.apache.cxf.ws.security.policy.interceptors.STSTokenOutInterceptor in project cxf by apache.
the class STSTokenOutInterceptorTest method testBasicAsymmetricBinding.
@Test
public void testBasicAsymmetricBinding() throws Exception {
Bus bus = BusFactory.getThreadDefaultBus();
STSAuthParams authParams = new STSAuthParams(AuthMode.X509_ASSYMETRIC, null, "org.apache.cxf.systest.sts.common.CommonCallbackHandler", "mystskey", "clientKeystore.properties");
STSTokenOutInterceptor interceptor = new STSTokenOutInterceptor(authParams, "http://localhost:" + STSPORT2 + STS_X509_WSDL_LOCATION_RELATIVE, bus);
MessageImpl message = prepareMessage(bus, null, SERVICE_ENDPOINT_ASSYMETRIC);
interceptor.handleMessage(message);
SecurityToken token = (SecurityToken) message.getExchange().get(SecurityConstants.TOKEN);
validateSecurityToken(token);
}
use of org.apache.cxf.ws.security.policy.interceptors.STSTokenOutInterceptor in project cxf by apache.
the class STSTokenOutInterceptorTest method testSTSClientAsymmetricBinding.
@Test
public void testSTSClientAsymmetricBinding() throws Exception {
Bus bus = BusFactory.getThreadDefaultBus();
STSClient stsClient = initStsClientAsymmeticBinding(bus);
STSTokenOutInterceptor interceptor = new STSTokenOutInterceptor(stsClient);
MessageImpl message = prepareMessage(bus, null, SERVICE_ENDPOINT_ASSYMETRIC);
interceptor.handleMessage(message);
SecurityToken token = (SecurityToken) message.getExchange().get(SecurityConstants.TOKEN);
validateSecurityToken(token);
}
use of org.apache.cxf.ws.security.policy.interceptors.STSTokenOutInterceptor in project cxf by apache.
the class JaxrsJWTTest method testSuccessfulInvocation.
@org.junit.Test
public void testSuccessfulInvocation() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = JaxrsJWTTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
final String address = "https://localhost:" + PORT + "/doubleit/services/doubleit-rs";
final int numToDouble = 25;
List<Object> providers = Collections.singletonList(new JwtOutFilter());
WebClient client = WebClient.create(address, providers);
client.type("text/plain").accept("text/plain");
STSClient stsClient = getSTSClient(JWT_TOKEN_TYPE, bus);
STSTokenOutInterceptor stsInterceptor = new STSTokenOutInterceptor(Phase.PRE_LOGICAL, stsClient, new TokenRequestParams());
stsInterceptor.getBefore().add(JwtOutFilter.class.getName());
WebClient.getConfig(client).getOutInterceptors().add(stsInterceptor);
int resp = client.post(numToDouble, Integer.class);
org.junit.Assert.assertEquals(2 * numToDouble, resp);
bus.shutdown(true);
}
use of org.apache.cxf.ws.security.policy.interceptors.STSTokenOutInterceptor in project cxf by apache.
the class STSTokenOutInterceptorTest method testSTSClientTransportBinding.
@Test
public void testSTSClientTransportBinding() throws Exception {
// Setup HttpsURLConnection to get STS WSDL
configureDefaultHttpsConnection();
Bus bus = BusFactory.getThreadDefaultBus();
STSClient stsClient = initStsClientTransportBinding(bus);
STSTokenOutInterceptor interceptor = new STSTokenOutInterceptor(stsClient);
TLSClientParameters tlsParams = prepareTLSParams();
((HTTPConduit) stsClient.getClient().getConduit()).setTlsClientParameters(tlsParams);
MessageImpl message = prepareMessage(bus, null, SERVICE_ENDPOINT_TRANSPORT);
interceptor.handleMessage(message);
SecurityToken token = (SecurityToken) message.getExchange().get(SecurityConstants.TOKEN);
validateSecurityToken(token);
}
use of org.apache.cxf.ws.security.policy.interceptors.STSTokenOutInterceptor in project cxf by apache.
the class STSTokenOutInterceptorTest method testBasicTransportBinding.
@Test
public void testBasicTransportBinding() throws Exception {
// Setup HttpsURLConnection to get STS WSDL
configureDefaultHttpsConnection();
Bus bus = BusFactory.getThreadDefaultBus();
STSAuthParams authParams = new STSAuthParams(AuthMode.UT_TRANSPORT, "alice", "org.apache.cxf.systest.sts.common.CommonCallbackHandler", null, null);
STSTokenOutInterceptor interceptor = new STSTokenOutInterceptor(authParams, "https://localhost:" + STSPORT + STS_TRANSPORT_WSDL_LOCATION_RELATIVE, bus);
TLSClientParameters tlsParams = prepareTLSParams();
STSClient stsClient = interceptor.getSTSClient();
((HTTPConduit) stsClient.getClient().getConduit()).setTlsClientParameters(tlsParams);
MessageImpl message = prepareMessage(bus, null, SERVICE_ENDPOINT_TRANSPORT);
interceptor.handleMessage(message);
SecurityToken token = (SecurityToken) message.getExchange().get(SecurityConstants.TOKEN);
validateSecurityToken(token);
}
Aggregations