Search in sources :

Example 1 with STSAuthParams

use of org.apache.cxf.ws.security.trust.STSAuthParams 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);
}
Also used : SecurityToken(org.apache.cxf.ws.security.tokenstore.SecurityToken) Bus(org.apache.cxf.Bus) STSTokenOutInterceptor(org.apache.cxf.ws.security.policy.interceptors.STSTokenOutInterceptor) STSAuthParams(org.apache.cxf.ws.security.trust.STSAuthParams) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Example 2 with STSAuthParams

use of org.apache.cxf.ws.security.trust.STSAuthParams 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)

Aggregations

Bus (org.apache.cxf.Bus)2 MessageImpl (org.apache.cxf.message.MessageImpl)2 STSTokenOutInterceptor (org.apache.cxf.ws.security.policy.interceptors.STSTokenOutInterceptor)2 SecurityToken (org.apache.cxf.ws.security.tokenstore.SecurityToken)2 STSAuthParams (org.apache.cxf.ws.security.trust.STSAuthParams)2 Test (org.junit.Test)2 TLSClientParameters (org.apache.cxf.configuration.jsse.TLSClientParameters)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1 STSClient (org.apache.cxf.ws.security.trust.STSClient)1