Search in sources :

Example 1 with SamlHeaderOutInterceptor

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());
}
Also used : SamlHeaderOutInterceptor(org.apache.cxf.rs.security.saml.SamlHeaderOutInterceptor)

Example 2 with 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());
        }
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Book(org.apache.cxf.systest.jaxrs.security.Book) WebClient(org.apache.cxf.jaxrs.client.WebClient) SamlHeaderOutInterceptor(org.apache.cxf.rs.security.saml.SamlHeaderOutInterceptor) ProcessingException(javax.ws.rs.ProcessingException) Test(org.junit.Test)

Example 3 with SamlHeaderOutInterceptor

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());
        }
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Book(org.apache.cxf.systest.jaxrs.security.Book) WebClient(org.apache.cxf.jaxrs.client.WebClient) SamlHeaderOutInterceptor(org.apache.cxf.rs.security.saml.SamlHeaderOutInterceptor) ProcessingException(javax.ws.rs.ProcessingException) Test(org.junit.Test)

Example 4 with SamlHeaderOutInterceptor

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;
}
Also used : STSClient(org.apache.cxf.ws.security.trust.STSClient) JAXRSClientFactoryBean(org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean) STSRESTOutInterceptor(org.talend.esb.security.saml.STSRESTOutInterceptor) SamlHeaderOutInterceptor(org.apache.cxf.rs.security.saml.SamlHeaderOutInterceptor)

Aggregations

SamlHeaderOutInterceptor (org.apache.cxf.rs.security.saml.SamlHeaderOutInterceptor)4 ProcessingException (javax.ws.rs.ProcessingException)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 WebClient (org.apache.cxf.jaxrs.client.WebClient)2 Book (org.apache.cxf.systest.jaxrs.security.Book)2 Test (org.junit.Test)2 JAXRSClientFactoryBean (org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean)1 STSClient (org.apache.cxf.ws.security.trust.STSClient)1 STSRESTOutInterceptor (org.talend.esb.security.saml.STSRESTOutInterceptor)1