Search in sources :

Example 21 with LoggingOutInterceptor

use of org.apache.cxf.ext.logging.LoggingOutInterceptor in project cxf by apache.

the class SpringBeansTest method testClients.

@Test
public void testClients() throws Exception {
    AbstractFactoryBeanDefinitionParser.setFactoriesAreAbstract(false);
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { "/org/apache/cxf/jaxws/spring/clients.xml" });
    ClientHolderBean greeters = (ClientHolderBean) ctx.getBean("greeters");
    assertEquals(4, greeters.greeterCount());
    Object bean = ctx.getBean("client1.proxyFactory");
    assertNotNull(bean);
    Greeter greeter = (Greeter) ctx.getBean("client1");
    Greeter greeter2 = (Greeter) ctx.getBean("client1");
    assertNotNull(greeter);
    assertNotNull(greeter2);
    assertSame(greeter, greeter2);
    Client client = ClientProxy.getClient(greeter);
    assertNotNull("expected ConduitSelector", client.getConduitSelector());
    assertTrue("unexpected ConduitSelector", client.getConduitSelector() instanceof NullConduitSelector);
    List<Interceptor<? extends Message>> inInterceptors = client.getInInterceptors();
    boolean saaj = false;
    boolean logging = false;
    for (Interceptor<? extends Message> i : inInterceptors) {
        if (i instanceof SAAJInInterceptor) {
            saaj = true;
        } else if (i instanceof LoggingInInterceptor) {
            logging = true;
        }
    }
    assertTrue(saaj);
    assertTrue(logging);
    saaj = false;
    logging = false;
    for (Interceptor<?> i : client.getOutInterceptors()) {
        if (i instanceof SAAJOutInterceptor) {
            saaj = true;
        } else if (i instanceof LoggingOutInterceptor) {
            logging = true;
        }
    }
    assertTrue(saaj);
    assertTrue(logging);
    assertTrue(client.getEndpoint().getService().getDataBinding() instanceof SourceDataBinding);
    JaxWsProxyFactoryBean factory = (JaxWsProxyFactoryBean) ctx.getBean("wsdlLocation.proxyFactory");
    assertNotNull(factory);
    String wsdlLocation = factory.getWsdlLocation();
    assertEquals("We should get the right wsdl location", wsdlLocation, "wsdl/hello_world.wsdl");
    factory = (JaxWsProxyFactoryBean) ctx.getBean("inlineSoapBinding.proxyFactory");
    assertNotNull(factory);
    BindingConfiguration bc = factory.getBindingConfig();
    assertTrue(bc instanceof SoapBindingConfiguration);
    SoapBindingConfiguration sbc = (SoapBindingConfiguration) bc;
    assertTrue(sbc.getVersion() instanceof Soap12);
    assertTrue("the soap configure should set isMtomEnabled to be true", sbc.isMtomEnabled());
    Greeter g1 = greeters.getGreet1();
    Greeter g2 = greeters.getGreet2();
    assertNotSame(g1, g2);
    ctx.close();
}
Also used : SAAJOutInterceptor(org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor) Soap12(org.apache.cxf.binding.soap.Soap12) Message(org.apache.cxf.message.Message) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) SourceDataBinding(org.apache.cxf.databinding.source.SourceDataBinding) NullConduitSelector(org.apache.cxf.endpoint.NullConduitSelector) SAAJInInterceptor(org.apache.cxf.binding.soap.saaj.SAAJInInterceptor) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) Greeter(org.apache.hello_world_soap_http.Greeter) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) Client(org.apache.cxf.endpoint.Client) SAAJOutInterceptor(org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor) SAAJInInterceptor(org.apache.cxf.binding.soap.saaj.SAAJInInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) BindingConfiguration(org.apache.cxf.binding.BindingConfiguration) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) Test(org.junit.Test)

Example 22 with LoggingOutInterceptor

use of org.apache.cxf.ext.logging.LoggingOutInterceptor in project cxf by apache.

the class StaxToDOMRoundTripTest method createService.

private Service createService() {
    // Create the Service
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceBean(new EchoImpl());
    factory.setAddress("local://Echo");
    factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    Server server = factory.create();
    Service service = server.getEndpoint().getService();
    service.getInInterceptors().add(new LoggingInInterceptor());
    service.getOutInterceptors().add(new LoggingOutInterceptor());
    return service;
}
Also used : Server(org.apache.cxf.endpoint.Server) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) Service(org.apache.cxf.service.Service) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 23 with LoggingOutInterceptor

use of org.apache.cxf.ext.logging.LoggingOutInterceptor in project cxf by apache.

the class StaxToDOMSignatureIdentifierTest method testSignatureIssuerSerial.

@Test
public void testSignatureIssuerSerial() throws Exception {
    // Create + configure service
    Service service = createService();
    Map<String, Object> inProperties = new HashMap<>();
    inProperties.put(ConfigurationConstants.ACTION, ConfigurationConstants.SIGNATURE);
    inProperties.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
    inProperties.put(ConfigurationConstants.SIG_VER_PROP_FILE, "insecurity.properties");
    WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
    service.getInInterceptors().add(inInterceptor);
    // Create + configure client
    Echo echo = createClientProxy();
    Client client = ClientProxy.getClient(echo);
    client.getInInterceptors().add(new LoggingInInterceptor());
    client.getOutInterceptors().add(new LoggingOutInterceptor());
    WSSSecurityProperties properties = new WSSSecurityProperties();
    List<WSSConstants.Action> actions = new ArrayList<WSSConstants.Action>();
    actions.add(XMLSecurityConstants.SIGNATURE);
    properties.setActions(actions);
    properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KeyIdentifier_IssuerSerial);
    properties.setSignatureUser("myalias");
    Properties cryptoProperties = CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader());
    properties.setSignatureCryptoProperties(cryptoProperties);
    properties.setCallbackHandler(new TestPwdCallback());
    WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties);
    client.getOutInterceptors().add(ohandler);
    assertEquals("test", echo.echo("test"));
}
Also used : WSSSecurityProperties(org.apache.wss4j.stax.ext.WSSSecurityProperties) WSSConstants(org.apache.wss4j.stax.ext.WSSConstants) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Service(org.apache.cxf.service.Service) Properties(java.util.Properties) WSSSecurityProperties(org.apache.wss4j.stax.ext.WSSSecurityProperties) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Example 24 with LoggingOutInterceptor

use of org.apache.cxf.ext.logging.LoggingOutInterceptor in project cxf by apache.

the class StaxToDOMSignatureIdentifierTest method testSignatureThumbprint.

@Test
public void testSignatureThumbprint() throws Exception {
    // Create + configure service
    Service service = createService();
    Map<String, Object> inProperties = new HashMap<>();
    inProperties.put(ConfigurationConstants.ACTION, ConfigurationConstants.SIGNATURE);
    inProperties.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
    inProperties.put(ConfigurationConstants.SIG_VER_PROP_FILE, "insecurity.properties");
    WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
    service.getInInterceptors().add(inInterceptor);
    // Create + configure client
    Echo echo = createClientProxy();
    Client client = ClientProxy.getClient(echo);
    client.getInInterceptors().add(new LoggingInInterceptor());
    client.getOutInterceptors().add(new LoggingOutInterceptor());
    WSSSecurityProperties properties = new WSSSecurityProperties();
    List<WSSConstants.Action> actions = new ArrayList<WSSConstants.Action>();
    actions.add(XMLSecurityConstants.SIGNATURE);
    properties.setActions(actions);
    properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KEYIDENTIFIER_THUMBPRINT_IDENTIFIER);
    properties.setSignatureUser("myalias");
    Properties cryptoProperties = CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader());
    properties.setSignatureCryptoProperties(cryptoProperties);
    properties.setCallbackHandler(new TestPwdCallback());
    WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties);
    client.getOutInterceptors().add(ohandler);
    assertEquals("test", echo.echo("test"));
}
Also used : WSSSecurityProperties(org.apache.wss4j.stax.ext.WSSSecurityProperties) WSSConstants(org.apache.wss4j.stax.ext.WSSConstants) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Service(org.apache.cxf.service.Service) Properties(java.util.Properties) WSSSecurityProperties(org.apache.wss4j.stax.ext.WSSSecurityProperties) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Example 25 with LoggingOutInterceptor

use of org.apache.cxf.ext.logging.LoggingOutInterceptor in project cxf by apache.

the class StaxToDOMSignatureIdentifierTest method testSignatureKeyValue.

@Test
public void testSignatureKeyValue() throws Exception {
    // Create + configure service
    Service service = createService();
    Map<String, Object> inProperties = new HashMap<>();
    inProperties.put(ConfigurationConstants.ACTION, ConfigurationConstants.SIGNATURE);
    inProperties.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
    inProperties.put(ConfigurationConstants.SIG_VER_PROP_FILE, "insecurity.properties");
    inProperties.put(ConfigurationConstants.IS_BSP_COMPLIANT, "false");
    WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
    service.getInInterceptors().add(inInterceptor);
    // Create + configure client
    Echo echo = createClientProxy();
    Client client = ClientProxy.getClient(echo);
    client.getInInterceptors().add(new LoggingInInterceptor());
    client.getOutInterceptors().add(new LoggingOutInterceptor());
    WSSSecurityProperties properties = new WSSSecurityProperties();
    List<WSSConstants.Action> actions = new ArrayList<WSSConstants.Action>();
    actions.add(XMLSecurityConstants.SIGNATURE);
    properties.setActions(actions);
    properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KeyIdentifier_KeyValue);
    properties.setSignatureUser("myalias");
    Properties cryptoProperties = CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader());
    properties.setSignatureCryptoProperties(cryptoProperties);
    properties.setCallbackHandler(new TestPwdCallback());
    WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties);
    client.getOutInterceptors().add(ohandler);
    assertEquals("test", echo.echo("test"));
}
Also used : WSSSecurityProperties(org.apache.wss4j.stax.ext.WSSSecurityProperties) WSSConstants(org.apache.wss4j.stax.ext.WSSConstants) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Service(org.apache.cxf.service.Service) Properties(java.util.Properties) WSSSecurityProperties(org.apache.wss4j.stax.ext.WSSSecurityProperties) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Aggregations

LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)224 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)207 Test (org.junit.Test)175 Service (org.apache.cxf.service.Service)138 Client (org.apache.cxf.endpoint.Client)135 HashMap (java.util.HashMap)101 WSSSecurityProperties (org.apache.wss4j.stax.ext.WSSSecurityProperties)89 ArrayList (java.util.ArrayList)68 Properties (java.util.Properties)65 WSSConstants (org.apache.wss4j.stax.ext.WSSConstants)61 QName (javax.xml.namespace.QName)35 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)22 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)21 AbstractSecurityTest (org.apache.cxf.ws.security.wss4j.AbstractSecurityTest)18 Echo (org.apache.cxf.ws.security.wss4j.Echo)18 Bus (org.apache.cxf.Bus)16 URL (java.net.URL)15 Server (org.apache.cxf.endpoint.Server)14 Greeter (org.apache.cxf.greeter_control.Greeter)14 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)13