Search in sources :

Example 1 with ClientInterceptor

use of org.springframework.ws.client.support.interceptor.ClientInterceptor in project powerauth-restful-integration by lime-company.

the class PowerAuthWebServiceConfiguration method powerAuthClient.

/**
 * Prepare a correctly configured PowerAuthServiceClient instance with the service
 * URL specified using 'powerauth.service.url' server property.
 * @param marshaller JAXB marshaller
 * @return Correctly configured PowerAuthServiceClient instance with the service
 * URL specified using 'powerauth.service.url' server property
 */
@Bean
public PowerAuthServiceClient powerAuthClient(Jaxb2Marshaller marshaller) {
    PowerAuthServiceClient client = new PowerAuthServiceClient();
    client.setDefaultUri(powerAuthServiceUrl);
    client.setMarshaller(marshaller);
    client.setUnmarshaller(marshaller);
    // if there is a configuration with security credentials, add interceptor
    if (!clientToken.isEmpty()) {
        ClientInterceptor[] interceptors = new ClientInterceptor[] { securityInterceptor() };
        client.setInterceptors(interceptors);
    }
    return client;
}
Also used : ClientInterceptor(org.springframework.ws.client.support.interceptor.ClientInterceptor) PowerAuthServiceClient(io.getlime.security.powerauth.soap.spring.client.PowerAuthServiceClient) Bean(org.springframework.context.annotation.Bean)

Example 2 with ClientInterceptor

use of org.springframework.ws.client.support.interceptor.ClientInterceptor in project spring-integration by spring-projects.

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithCustomInterceptor.

@Test
public void simpleGatewayWithCustomInterceptor() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithCustomInterceptor", AbstractEndpoint.class);
    assertEquals(EventDrivenConsumer.class, endpoint.getClass());
    Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
    assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
    DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
    accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
    ClientInterceptor interceptor = context.getBean("interceptor", ClientInterceptor.class);
    assertEquals(interceptor, ((ClientInterceptor[]) accessor.getPropertyValue("interceptors"))[0]);
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) ClientInterceptor(org.springframework.ws.client.support.interceptor.ClientInterceptor) Test(org.junit.Test)

Example 3 with ClientInterceptor

use of org.springframework.ws.client.support.interceptor.ClientInterceptor in project camel by apache.

the class ProducerWss4JSecurityHeaderTest method setRemoveHeaders.

private void setRemoveHeaders(boolean isRemoved) {
    ClientInterceptor[] clientInterceptors = webServiceTemplate.getInterceptors();
    for (int i = 0; i < clientInterceptors.length; i++) {
        if (clientInterceptors[i] instanceof Wss4jSecurityInterceptor) {
            Wss4jSecurityInterceptor wss4jSampleInterceptor = (Wss4jSecurityInterceptor) clientInterceptors[i];
            wss4jSampleInterceptor.setRemoveSecurityHeader(isRemoved);
        }
    }
}
Also used : Wss4jSecurityInterceptor(org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor) ClientInterceptor(org.springframework.ws.client.support.interceptor.ClientInterceptor)

Example 4 with ClientInterceptor

use of org.springframework.ws.client.support.interceptor.ClientInterceptor in project spring-integration by spring-projects.

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithCustomInterceptorList.

@Test
public void simpleGatewayWithCustomInterceptorList() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithCustomInterceptorList", AbstractEndpoint.class);
    assertEquals(EventDrivenConsumer.class, endpoint.getClass());
    Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
    assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
    DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
    accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
    ClientInterceptor interceptor = context.getBean("interceptor", ClientInterceptor.class);
    assertEquals(interceptor, ((ClientInterceptor[]) accessor.getPropertyValue("interceptors"))[0]);
    assertEquals("Wrong number of interceptors ", 2, ((ClientInterceptor[]) accessor.getPropertyValue("interceptors")).length);
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) ClientInterceptor(org.springframework.ws.client.support.interceptor.ClientInterceptor) Test(org.junit.Test)

Aggregations

ClientInterceptor (org.springframework.ws.client.support.interceptor.ClientInterceptor)4 Test (org.junit.Test)2 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)2 AbstractEndpoint (org.springframework.integration.endpoint.AbstractEndpoint)2 PowerAuthServiceClient (io.getlime.security.powerauth.soap.spring.client.PowerAuthServiceClient)1 Bean (org.springframework.context.annotation.Bean)1 Wss4jSecurityInterceptor (org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor)1