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);
}
Aggregations