Search in sources :

Example 1 with TokenRequestParams

use of org.apache.cxf.ws.security.trust.STSTokenRetriever.TokenRequestParams 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);
}
Also used : Bus(org.apache.cxf.Bus) STSClient(org.apache.cxf.ws.security.trust.STSClient) STSTokenOutInterceptor(org.apache.cxf.ws.security.policy.interceptors.STSTokenOutInterceptor) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) TokenRequestParams(org.apache.cxf.ws.security.trust.STSTokenRetriever.TokenRequestParams) WebClient(org.apache.cxf.jaxrs.client.WebClient) URL(java.net.URL)

Aggregations

URL (java.net.URL)1 Bus (org.apache.cxf.Bus)1 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)1 WebClient (org.apache.cxf.jaxrs.client.WebClient)1 STSTokenOutInterceptor (org.apache.cxf.ws.security.policy.interceptors.STSTokenOutInterceptor)1 STSClient (org.apache.cxf.ws.security.trust.STSClient)1 TokenRequestParams (org.apache.cxf.ws.security.trust.STSTokenRetriever.TokenRequestParams)1