use of org.apache.cxf.ws.security.trust.STSClient in project cxf by apache.
the class STSTokenOutInterceptorTest method initStsClientAsymmeticBinding.
private STSClient initStsClientAsymmeticBinding(Bus bus) {
bus.getInInterceptors().add(new LoggingOutInterceptor());
bus.getOutInterceptors().add(new LoggingInInterceptor());
bus.getOutFaultInterceptors().add(new LoggingInInterceptor());
STSClient stsClient = new STSClient(bus);
stsClient.setWsdlLocation("http://localhost:" + STSPORT2 + STS_X509_WSDL_LOCATION_RELATIVE);
stsClient.setServiceName(STS_SERVICE_NAME);
stsClient.setEndpointName(STS_X509_ENDPOINT_NAME);
stsClient.setTokenType(TOKEN_TYPE_SAML_2_0);
stsClient.setKeyType(KEY_TYPE_X509);
stsClient.setAllowRenewingAfterExpiry(true);
stsClient.setEnableLifetime(true);
Map<String, Object> props = new HashMap<>();
props.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler");
props.put(SecurityConstants.ENCRYPT_USERNAME, "mystskey");
props.put(SecurityConstants.ENCRYPT_PROPERTIES, "clientKeystore.properties");
props.put(SecurityConstants.SIGNATURE_PROPERTIES, "clientKeystore.properties");
props.put(SecurityConstants.STS_TOKEN_USERNAME, "mystskey");
props.put(SecurityConstants.STS_TOKEN_PROPERTIES, "clientKeystore.properties");
props.put(SecurityConstants.STS_TOKEN_USE_CERT_FOR_KEYINFO, "true");
stsClient.setProperties(props);
return stsClient;
}
use of org.apache.cxf.ws.security.trust.STSClient 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.trust.STSClient 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);
}
use of org.apache.cxf.ws.security.trust.STSClient in project cxf by apache.
the class STSTokenRetrieverTest method testSTSTransportBinding.
@Test
public void testSTSTransportBinding() throws Exception {
// Setup HttpsURLConnection to get STS WSDL
configureDefaultHttpsConnection();
Bus bus = BusFactory.getThreadDefaultBus();
STSClient stsClient = initStsClientTransportBinding(bus);
TLSClientParameters tlsParams = prepareTLSParams();
((HTTPConduit) stsClient.getClient().getConduit()).setTlsClientParameters(tlsParams);
MessageImpl message = prepareMessage(bus, stsClient, SERVICE_ENDPOINT_TRANSPORT);
STSTokenRetriever.TokenRequestParams params = new STSTokenRetriever.TokenRequestParams();
SecurityToken token = STSTokenRetriever.getToken(message, params);
validateSecurityToken(token);
}
use of org.apache.cxf.ws.security.trust.STSClient in project cxf by apache.
the class STSTokenRetrieverTest method testSTSAsymmetricBinding.
@Test
public void testSTSAsymmetricBinding() throws Exception {
Bus bus = BusFactory.getThreadDefaultBus();
STSClient stsClient = initStsClientAsymmeticBinding(bus);
MessageImpl message = prepareMessage(bus, stsClient, SERVICE_ENDPOINT_ASSYMETRIC);
STSTokenRetriever.TokenRequestParams params = new STSTokenRetriever.TokenRequestParams();
SecurityToken token = STSTokenRetriever.getToken(message, params);
validateSecurityToken(token);
}
Aggregations