use of org.apache.cxf.rs.security.saml.SamlHeaderOutInterceptor in project tesb-rt-se by Talend.
the class SAMLRESTUtils method configureClient.
public static void configureClient(final AbstractJAXRSFactoryBean clientFactory, final STSClient stsClient) {
stsClient.setAllowRenewingAfterExpiry(true);
stsClient.setEnableLifetime(true);
stsClient.setTokenType(SAML2_TOKEN_TYPE);
stsClient.setKeyType(BEARER_KEYTYPE);
STSRESTOutInterceptor outInterceptor = new STSRESTOutInterceptor();
outInterceptor.setStsClient(stsClient);
clientFactory.getOutInterceptors().add(outInterceptor);
clientFactory.getOutInterceptors().add(new SamlHeaderOutInterceptor());
}
use of org.apache.cxf.rs.security.saml.SamlHeaderOutInterceptor in project cxf by apache.
the class JAXRSSamlTest method testGetBookPreviousSAMLTokenAsHeader.
@Test
public void testGetBookPreviousSAMLTokenAsHeader() throws Exception {
String address = "https://localhost:" + PORT + "/samlheader/bookstore/books/123";
WebClient wc = createWebClientForExistingToken(address, new SamlHeaderOutInterceptor(), null);
try {
Book book = wc.get(Book.class);
assertEquals(123L, book.getId());
} catch (WebApplicationException ex) {
fail(ex.getMessage());
} catch (ProcessingException ex) {
if (ex.getCause() != null && ex.getCause().getMessage() != null) {
fail(ex.getCause().getMessage());
} else {
fail(ex.getMessage());
}
}
}
use of org.apache.cxf.rs.security.saml.SamlHeaderOutInterceptor in project cxf by apache.
the class JAXRSSamlTest method testGetBookSAMLTokenAsHeader.
@Test
public void testGetBookSAMLTokenAsHeader() throws Exception {
String address = "https://localhost:" + PORT + "/samlheader/bookstore/books/123";
WebClient wc = createWebClient(address, new SamlHeaderOutInterceptor(), null);
try {
Book book = wc.get(Book.class);
assertEquals(123L, book.getId());
} catch (WebApplicationException ex) {
fail(ex.getMessage());
} catch (ProcessingException ex) {
if (ex.getCause() != null && ex.getCause().getMessage() != null) {
fail(ex.getCause().getMessage());
} else {
fail(ex.getMessage());
}
}
}
use of org.apache.cxf.rs.security.saml.SamlHeaderOutInterceptor in project tesb-rt-se by Talend.
the class AuxiliaryStorageRestClientSecurityProvider method getClientFactory.
protected JAXRSClientFactoryBean getClientFactory() {
if (null == cachedClientFactory) {
JAXRSClientFactoryBean factoryBean = new JAXRSClientFactoryBean();
factoryBean.setThreadSafe(true);
factoryBean.setAddress(getServerURL());
if (Authentication.BASIC == auxiliaryStorageAuthentication) {
factoryBean.setUsername(authenticationUser);
factoryBean.setPassword(authenticationPassword);
}
if (Authentication.SAML == auxiliaryStorageAuthentication) {
STSClient stsClient = STSClientCreator.create(factoryBean.getBus(), stsProps);
STSRESTOutInterceptor outInterceptor = new STSRESTOutInterceptor();
outInterceptor.setStsClient(stsClient);
factoryBean.getOutInterceptors().add(outInterceptor);
factoryBean.getOutInterceptors().add(new SamlHeaderOutInterceptor());
}
cachedClientFactory = factoryBean;
}
return cachedClientFactory;
}
Aggregations