use of org.apache.cxf.jaxrs.security.KerberosAuthOutInterceptor in project cxf by apache.
the class JAXRSKerberosBookTest method testGetBookWithInterceptor.
@Test
public void testGetBookWithInterceptor() throws Exception {
if (!runTests) {
return;
}
WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/books/123");
KerberosAuthOutInterceptor kbInterceptor = new KerberosAuthOutInterceptor();
AuthorizationPolicy policy = new AuthorizationPolicy();
policy.setAuthorizationType(HttpAuthHeader.AUTH_TYPE_NEGOTIATE);
policy.setAuthorization("alice");
policy.setUserName("alice");
policy.setPassword("alice");
kbInterceptor.setPolicy(policy);
kbInterceptor.setCredDelegation(true);
WebClient.getConfig(wc).getOutInterceptors().add(new LoggingOutInterceptor());
WebClient.getConfig(wc).getOutInterceptors().add(kbInterceptor);
// Required so as to get it working with our KDC
kbInterceptor.setServicePrincipalName("bob@service.ws.apache.org");
kbInterceptor.setServiceNameType(GSSName.NT_HOSTBASED_SERVICE);
Book b = wc.get(Book.class);
Assert.assertEquals(b.getId(), 123);
}
Aggregations