Search in sources :

Example 71 with STSClient

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;
}
Also used : STSClient(org.apache.cxf.ws.security.trust.STSClient) HashMap(java.util.HashMap) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor)

Example 72 with 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);
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) SecurityToken(org.apache.cxf.ws.security.tokenstore.SecurityToken) Bus(org.apache.cxf.Bus) TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) STSClient(org.apache.cxf.ws.security.trust.STSClient) STSTokenOutInterceptor(org.apache.cxf.ws.security.policy.interceptors.STSTokenOutInterceptor) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Example 73 with STSClient

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);
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) SecurityToken(org.apache.cxf.ws.security.tokenstore.SecurityToken) Bus(org.apache.cxf.Bus) TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) STSTokenOutInterceptor(org.apache.cxf.ws.security.policy.interceptors.STSTokenOutInterceptor) STSClient(org.apache.cxf.ws.security.trust.STSClient) STSAuthParams(org.apache.cxf.ws.security.trust.STSAuthParams) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Example 74 with STSClient

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);
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) SecurityToken(org.apache.cxf.ws.security.tokenstore.SecurityToken) Bus(org.apache.cxf.Bus) TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) STSClient(org.apache.cxf.ws.security.trust.STSClient) STSTokenRetriever(org.apache.cxf.ws.security.trust.STSTokenRetriever) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Example 75 with STSClient

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);
}
Also used : SecurityToken(org.apache.cxf.ws.security.tokenstore.SecurityToken) Bus(org.apache.cxf.Bus) STSClient(org.apache.cxf.ws.security.trust.STSClient) STSTokenRetriever(org.apache.cxf.ws.security.trust.STSTokenRetriever) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Aggregations

STSClient (org.apache.cxf.ws.security.trust.STSClient)89 Bus (org.apache.cxf.Bus)35 HashMap (java.util.HashMap)33 URL (java.net.URL)31 QName (javax.xml.namespace.QName)29 Service (javax.xml.ws.Service)27 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)24 DoubleItPortType (org.example.contract.doubleit.DoubleItPortType)21 SecurityToken (org.apache.cxf.ws.security.tokenstore.SecurityToken)14 BindingProvider (javax.xml.ws.BindingProvider)11 Test (org.junit.Test)11 Client (org.apache.cxf.endpoint.Client)9 WebService (javax.jws.WebService)5 BusException (org.apache.cxf.BusException)5 TLSClientParameters (org.apache.cxf.configuration.jsse.TLSClientParameters)5 EndpointException (org.apache.cxf.endpoint.EndpointException)5 MessageImpl (org.apache.cxf.message.MessageImpl)5 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)5 ClientCallbackHandler (org.jboss.as.test.integration.ws.wsse.trust.shared.ClientCallbackHandler)5 DOMSource (javax.xml.transform.dom.DOMSource)4