org.apache.cxf.ext.logging.LoggingOutInterceptor Java Examples
The following examples show how to use
org.apache.cxf.ext.logging.LoggingOutInterceptor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CXF6655Test.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testConnectionWithProxy() throws Exception { QName serviceName = new QName("http://cxf.apache.org/systest/jaxws/", "HelloService"); HelloService service = new HelloService(null, serviceName); assertNotNull(service); Hello hello = service.getHelloPort(); Client client = ClientProxy.getClient(hello); client.getInInterceptors().add(new LoggingInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); HTTPConduit http = (HTTPConduit)client.getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setAllowChunking(false); httpClientPolicy.setReceiveTimeout(0); httpClientPolicy.setProxyServerType(ProxyServerType.HTTP); httpClientPolicy.setProxyServer("localhost"); httpClientPolicy.setProxyServerPort(PROXY_PORT); http.setClient(httpClientPolicy); ((BindingProvider)hello).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/hello"); assertEquals("getSayHi", hello.sayHi("SayHi")); }
Example #2
Source File: RetransmissionGZIPTest.java From cxf with Apache License 2.0 | 6 votes |
protected void run() { SpringBusFactory bf = new SpringBusFactory(); Bus bus = bf.createBus("/org/apache/cxf/systest/ws/rm/gzip-enabled.xml"); BusFactory.setDefaultBus(bus); LoggingInInterceptor in = new LoggingInInterceptor(); bus.getInInterceptors().add(in); bus.getInFaultInterceptors().add(in); LoggingOutInterceptor out = new LoggingOutInterceptor(); bus.getOutInterceptors().add(out); bus.getOutFaultInterceptors().add(out); GreeterImpl implementor = new GreeterImpl(); String address = "http://localhost:" + PORT + "/SoapContext/GreeterPort"; Endpoint ep = Endpoint.create(implementor); ep.publish(address); LOG.info("Published greeter endpoint."); }
Example #3
Source File: CachedOutMessageTest.java From cxf with Apache License 2.0 | 6 votes |
protected void run() { SpringBusFactory bf = new SpringBusFactory(); Bus bus = bf.createBus("/org/apache/cxf/systest/ws/rm/message-loss.xml"); BusFactory.setDefaultBus(bus); setBus(bus); LoggingInInterceptor in = new LoggingInInterceptor(); bus.getInInterceptors().add(in); bus.getInFaultInterceptors().add(in); LoggingOutInterceptor out = new LoggingOutInterceptor(); bus.getOutInterceptors().add(out); bus.getOutFaultInterceptors().add(out); GreeterImpl implementor = new GreeterImpl(); String address = "http://localhost:" + PORT + "/SoapContext/GreeterPort"; ep = Endpoint.create(implementor); ep.publish(address); LOG.info("Published greeter endpoint."); }
Example #4
Source File: JMSSoapActionTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testSayHi() throws Exception { QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldServiceSoapAction"); QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort"); URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl"); HelloWorldService service = new HelloWorldService(wsdl, serviceName); String response = new String("Bonjour"); HelloWorldPortType greeter = service.getPort(portName, HelloWorldPortType.class); ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingOutInterceptor()); ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingInInterceptor()); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true"); ((BindingProvider)greeter).getRequestContext().put( BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_1" ); String reply = greeter.sayHi(); assertNotNull("no response received from service", reply); assertEquals(response, reply); ((java.io.Closeable)greeter).close(); }
Example #5
Source File: AddressingPolicyExternalAttachmentWsdl11Test.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testUsingAddressing() throws Exception { SpringBusFactory bf = new SpringBusFactory(); bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-wsdl11.xml"); BusFactory.setDefaultBus(bus); LoggingInInterceptor in = new LoggingInInterceptor(); bus.getInInterceptors().add(in); bus.getInFaultInterceptors().add(in); LoggingOutInterceptor out = new LoggingOutInterceptor(); bus.getOutInterceptors().add(out); bus.getOutFaultInterceptors().add(out); BasicGreeterService gs = new BasicGreeterService(); final Greeter greeter = gs.getGreeterPort(); updateAddressPort(greeter, PORT); LOG.fine("Created greeter client."); ConnectionHelper.setKeepAliveConnection(greeter, true); assertEquals("CXF", greeter.greetMe("cxf")); ((Closeable)greeter).close(); }
Example #6
Source File: AddressingPolicy0705Test.java From cxf with Apache License 2.0 | 6 votes |
protected void run() { System.setProperty("temp.location", tmpDir); SpringBusFactory bf = new SpringBusFactory(); Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr0705.xml"); BusFactory.setDefaultBus(bus); setBus(bus); LoggingInInterceptor in = new LoggingInInterceptor(); bus.getInInterceptors().add(in); bus.getInFaultInterceptors().add(in); LoggingOutInterceptor out = new LoggingOutInterceptor(); bus.getOutInterceptors().add(out); bus.getOutFaultInterceptors().add(out); GreeterImpl implementor = new GreeterImpl(); String address = "http://localhost:" + PORT + "/SoapContext/GreeterPort"; ep = Endpoint.publish(address, implementor); LOG.info("Published greeter endpoint."); }
Example #7
Source File: AddressingOptionalPolicyTest.java From cxf with Apache License 2.0 | 6 votes |
protected void run() { System.setProperty("temp.location", tmpDir); SpringBusFactory bf = new SpringBusFactory(); Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-optional.xml"); BusFactory.setDefaultBus(bus); setBus(bus); LoggingInInterceptor in = new LoggingInInterceptor(); bus.getInInterceptors().add(in); bus.getInFaultInterceptors().add(in); LoggingOutInterceptor out = new LoggingOutInterceptor(); bus.getOutInterceptors().add(out); bus.getOutFaultInterceptors().add(out); GreeterImpl implementor = new GreeterImpl(); String address = "http://localhost:" + PORT + "/SoapContext/GreeterPort"; ep = Endpoint.publish(address, implementor); LOG.info("Published greeter endpoint."); }
Example #8
Source File: RetransmissionQueueTest.java From cxf with Apache License 2.0 | 6 votes |
protected void run() { SpringBusFactory bf = new SpringBusFactory(); Bus bus = bf.createBus("/org/apache/cxf/systest/ws/rm/message-loss.xml"); BusFactory.setDefaultBus(bus); LoggingInInterceptor in = new LoggingInInterceptor(); bus.getInInterceptors().add(in); bus.getInFaultInterceptors().add(in); LoggingOutInterceptor out = new LoggingOutInterceptor(); bus.getOutInterceptors().add(out); bus.getOutFaultInterceptors().add(out); GreeterImpl implementor = new GreeterImpl(); String address = "http://localhost:" + PORT + "/SoapContext/GreeterPort"; Endpoint ep = Endpoint.create(implementor); ep.publish(address); LOG.info("Published greeter endpoint."); }
Example #9
Source File: OpenTracingTracingTest.java From cxf with Apache License 2.0 | 6 votes |
private static BookStoreService createJaxWsService(final Map<String, List<String>> headers, final Feature feature) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.getOutInterceptors().add(new LoggingOutInterceptor()); factory.getInInterceptors().add(new LoggingInInterceptor()); factory.setServiceClass(BookStoreService.class); factory.setAddress("http://localhost:" + PORT + "/BookStore"); if (feature != null) { factory.getFeatures().add(feature); } final BookStoreService service = (BookStoreService) factory.create(); final Client proxy = ClientProxy.getClient(service); proxy.getRequestContext().put(Message.PROTOCOL_HEADERS, headers); return service; }
Example #10
Source File: MTOMBase64Test.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testMTOMInHashMapWithBase64() throws Exception { Service service = Service.create(new QName("http://foo", "bar")); service.addPort(new QName("http://foo", "bar"), SOAPBinding.SOAP11HTTP_BINDING, ADDRESS); MTOMService port = service.getPort(new QName("http://foo", "bar"), MTOMService.class); ClientProxy.getClient(port).getOutInterceptors().add(new LoggingOutInterceptor()); ClientProxy.getClient(port).getInInterceptors().add(new LoggingInInterceptor()); final int count = 99; ObjectWithHashMapData data = port.getHashMapData(count); for (int y = 1; y < count; y++) { byte[] bytes = data.getKeyData().get(Integer.toHexString(y)); assertEquals(y, bytes.length); } }
Example #11
Source File: BraveTracingTest.java From cxf with Apache License 2.0 | 6 votes |
private BookStoreService createJaxWsService(final Map<String, List<String>> headers, final Feature feature) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.getOutInterceptors().add(new LoggingOutInterceptor()); factory.getInInterceptors().add(new LoggingInInterceptor()); factory.setServiceClass(BookStoreService.class); factory.setAddress("http://localhost:" + PORT + "/BookStore"); if (feature != null) { factory.getFeatures().add(feature); } final BookStoreService service = (BookStoreService) factory.create(); final Client proxy = ClientProxy.getClient(service); proxy.getRequestContext().put(Message.PROTOCOL_HEADERS, headers); return service; }
Example #12
Source File: AddressingAnonymousPolicyTest.java From cxf with Apache License 2.0 | 6 votes |
protected void run() { System.setProperty("server.temp.location", tmpDir); SpringBusFactory bf = new SpringBusFactory(); Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-anon-server.xml"); setBus(bus); BusFactory.setDefaultBus(bus); LoggingInInterceptor in = new LoggingInInterceptor(); bus.getInInterceptors().add(in); bus.getInFaultInterceptors().add(in); LoggingOutInterceptor out = new LoggingOutInterceptor(); bus.getOutInterceptors().add(out); bus.getOutFaultInterceptors().add(out); GreeterImpl implementor = new GreeterImpl(); String address = "http://localhost:" + PORT + "/SoapContext/GreeterPort"; ep = Endpoint.publish(address, implementor); LOG.info("Published greeter endpoint."); }
Example #13
Source File: JettyDigestAuthTest.java From cxf with Apache License 2.0 | 6 votes |
private HTTPConduit setupClient(boolean async) throws Exception { URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl"); greeter = new SOAPService(wsdl, SERVICE_NAME).getPort(Greeter.class); BindingProvider bp = (BindingProvider)greeter; ClientProxy.getClient(greeter).getInInterceptors().add(new LoggingInInterceptor()); ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingOutInterceptor()); bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ADDRESS); HTTPConduit cond = (HTTPConduit)ClientProxy.getClient(greeter).getConduit(); HTTPClientPolicy client = new HTTPClientPolicy(); cond.setClient(client); if (async) { if (cond instanceof AsyncHTTPConduit) { UsernamePasswordCredentials creds = new UsernamePasswordCredentials("ffang", "pswd"); bp.getRequestContext().put(Credentials.class.getName(), creds); bp.getRequestContext().put(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE); client.setAutoRedirect(true); } else { fail("Not an async conduit"); } } else { bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "ffang"); bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd"); cond.setAuthSupplier(new DigestAuthSupplier()); } ClientProxy.getClient(greeter).getOutInterceptors() .add(new AbstractPhaseInterceptor<Message>(Phase.PRE_STREAM_ENDING) { public void handleMessage(Message message) throws Fault { Map<String, ?> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS)); if (headers.containsKey("Proxy-Authorization")) { throw new RuntimeException("Should not have Proxy-Authorization"); } } }); client.setAllowChunking(false); return cond; }
Example #14
Source File: NestedAddressingPolicyTest.java From cxf with Apache License 2.0 | 6 votes |
protected void run() { SpringBusFactory bf = new SpringBusFactory(); Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/http-addr-server.xml"); setBus(bus); GreeterImpl implementor = new GreeterImpl(); implementor.setThrowAlways(true); Endpoint.publish("http://localhost:" + PORT + "/SoapContext/GreeterPort", implementor); LOG.info("Published greeter endpoint."); LoggingInInterceptor in = new LoggingInInterceptor(); LoggingOutInterceptor out = new LoggingOutInterceptor(); bus.getInInterceptors().add(in); bus.getOutInterceptors().add(out); bus.getOutFaultInterceptors().add(out); }
Example #15
Source File: AegisClientServerTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testCollection() throws Exception { AegisDatabinding aegisBinding = new AegisDatabinding(); JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean(); proxyFactory.setDataBinding(aegisBinding); proxyFactory.setServiceClass(SportsService.class); proxyFactory.setWsdlLocation("http://localhost:" + PORT + "/jaxwsAndAegisSports?wsdl"); proxyFactory.getInInterceptors().add(new LoggingInInterceptor()); proxyFactory.getOutInterceptors().add(new LoggingOutInterceptor()); SportsService service = (SportsService) proxyFactory.create(); Collection<Team> teams = service.getTeams(); assertEquals(1, teams.size()); assertEquals("Patriots", teams.iterator().next().getName()); //CXF-1251 String s = service.testForMinOccurs0("A", null, "b"); assertEquals("Anullb", s); }
Example #16
Source File: NonSpringJaxrsServletBookServer.java From cxf with Apache License 2.0 | 6 votes |
protected void run() { server = new org.eclipse.jetty.server.Server(Integer.parseInt(PORT)); final ServletHolder servletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet(new BookStoreOpenAPI())); final ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); context.addServlet(servletHolder, "/*"); //servletHolder.setInitParameter("jaxrs.serviceClasses", BookStore.class.getName()); servletHolder.setInitParameter("jaxrs.outInterceptors", LoggingOutInterceptor.class.getName()); servletHolder.setInitParameter("jaxrs.inInterceptors", LoggingInInterceptor.class.getName()); server.setHandler(context); try { server.start(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Example #17
Source File: EventSinkInterfaceNotificationTask.java From cxf with Apache License 2.0 | 6 votes |
protected Object getProxy(Class<?> sinkInterface, Class<?>... extraClasses) { //needed SOAP handlers ReferenceParametersAddingHandler handler = new ReferenceParametersAddingHandler( target.getNotificationReferenceParams()); JaxWsProxyFactoryBean service = new JaxWsProxyFactoryBean(); service.getOutInterceptors().add(new LoggingOutInterceptor()); service.setServiceClass(sinkInterface); service.setAddress(target.getTargetURL()); service.getHandlers().add(handler); // do we need to apply a filter? if (target.getFilter() != null && target.getFilter().getContent().size() > 0) { service.getOutInterceptors().add(new FilteringInterceptor(target.getFilter())); } if (extraClasses != null && extraClasses.length > 0) { Map<String, Object> props = new HashMap<>(); props.put("jaxb.additionalContextClasses", extraClasses); service.getClientFactoryBean().getServiceFactory().setProperties(props); } return service.create(); }
Example #18
Source File: JMSSoapActionTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testSayHi2() throws Exception { QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldServiceSoapAction"); QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort"); URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl"); HelloWorldService service = new HelloWorldService(wsdl, serviceName); HelloWorldPortType greeter = service.getPort(portName, HelloWorldPortType.class); ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingOutInterceptor()); ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingInInterceptor()); ((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true"); ((BindingProvider)greeter).getRequestContext().put( BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_2" ); try { greeter.sayHi(); fail("Failure expected on spoofing attack"); } catch (Exception ex) { // expected } ((java.io.Closeable)greeter).close(); }
Example #19
Source File: ProviderClientServerTest.java From cxf with Apache License 2.0 | 5 votes |
protected void run() { Object implementor = new HWSoapMessageDocProvider(); Endpoint ep = Endpoint.create(implementor); Map<String, Object> map = new HashMap<>(); map.put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE); ep.setProperties(map); ((EndpointImpl)ep).getInInterceptors().add(new LoggingInInterceptor()); ((EndpointImpl)ep).getOutInterceptors().add(new LoggingOutInterceptor()); ep.publish(ADDRESS); }
Example #20
Source File: StaxToDOMSignatureIdentifierTest.java From cxf with Apache License 2.0 | 5 votes |
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; }
Example #21
Source File: StaxToDOMSamlTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testSaml1() throws Exception { // Create + configure service Service service = createService(); Map<String, Object> inProperties = new HashMap<>(); inProperties.put(ConfigurationConstants.ACTION, ConfigurationConstants.SAML_TOKEN_UNSIGNED); final Map<QName, Object> customMap = new HashMap<>(); CustomSamlValidator validator = new CustomSamlValidator(); customMap.put(WSConstants.SAML_TOKEN, validator); customMap.put(WSConstants.SAML2_TOKEN, validator); inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP, customMap); inProperties.put(SecurityConstants.VALIDATE_SAML_SUBJECT_CONFIRMATION, "false"); WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties); service.getInInterceptors().add(inInterceptor); service.put(SecurityConstants.VALIDATE_SAML_SUBJECT_CONFIRMATION, "false"); // 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<>(); actions.add(WSSConstants.SAML_TOKEN_UNSIGNED); properties.setActions(actions); properties.setSamlCallbackHandler(new SAML1CallbackHandler()); WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test", echo.echo("test")); }
Example #22
Source File: RxJava2ObservableServer.java From cxf with Apache License 2.0 | 5 votes |
protected void run() { Bus bus = BusFactory.getDefaultBus(); // Make sure default JSONProvider is not loaded bus.setProperty("skip.default.json.provider.registration", true); JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setInvoker(new ReactiveIOInvoker()); sf.setProvider(new JacksonJsonProvider()); sf.getOutInterceptors().add(new LoggingOutInterceptor()); sf.setResourceClasses(RxJava2ObservableService.class); sf.setResourceProvider(RxJava2ObservableService.class, new SingletonResourceProvider(new RxJava2ObservableService(), true)); sf.setAddress("http://localhost:" + PORT + "/"); server = sf.create(); }
Example #23
Source File: StaxRoundTripTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testUsernameTokenTextUnknownPassword() throws Exception { // Create + configure service Service service = createService(); WSSSecurityProperties inProperties = new WSSSecurityProperties(); inProperties.setCallbackHandler(new TestPwdCallback()); inProperties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_TEXT); WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties); service.getInInterceptors().add(inhandler); // 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<>(); actions.add(WSSConstants.USERNAMETOKEN); properties.setActions(actions); properties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_TEXT); properties.setTokenUser("username"); properties.setCallbackHandler(new UnknownUserPasswordCallbackHandler()); WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); service.put(SecurityConstants.RETURN_SECURITY_ERROR, true); try { echo.echo("test"); fail("Failure expected on an unknown password"); } catch (javax.xml.ws.soap.SOAPFaultException ex) { // expected String error = "The security token could not be authenticated or authorized"; assertTrue(ex.getMessage().contains(error)); } }
Example #24
Source File: AbstractWSATestBase.java From cxf with Apache License 2.0 | 5 votes |
protected ByteArrayOutputStream setupOutLogging() { PayloadLogEventSender sender = new PayloadLogEventSender(); LoggingOutInterceptor out = new LoggingOutInterceptor(sender); this.bus.getOutInterceptors().add(out); this.bus.getOutFaultInterceptors().add(out); return sender.bos; }
Example #25
Source File: StaxToDOMEncryptionIdentifierTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testEncryptDirectReference() throws Exception { // Create + configure service Service service = createService(); Map<String, Object> inProperties = new HashMap<>(); inProperties.put(ConfigurationConstants.ACTION, ConfigurationConstants.ENCRYPTION); inProperties.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback()); inProperties.put(ConfigurationConstants.DEC_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<>(); actions.add(XMLSecurityConstants.ENCRYPTION); properties.setActions(actions); properties.setEncryptionUser("myalias"); properties.setEncryptionKeyIdentifier( WSSecurityTokenConstants.KEYIDENTIFIER_SECURITY_TOKEN_DIRECT_REFERENCE ); properties.setEncryptionSymAlgorithm(XMLSecurityConstants.NS_XENC_AES128); Properties cryptoProperties = CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader()); properties.setEncryptionCryptoProperties(cryptoProperties); properties.setCallbackHandler(new TestPwdCallback()); WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties); client.getOutInterceptors().add(ohandler); assertEquals("test", echo.echo("test")); }
Example #26
Source File: StaxToDOMSamlTest.java From cxf with Apache License 2.0 | 5 votes |
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; }
Example #27
Source File: DispatchClientServerWithMalformedResponseTest.java From cxf with Apache License 2.0 | 5 votes |
@org.junit.Before public void setUp() { BusFactory.setThreadDefaultBus(getStaticBus()); BusFactory.getThreadDefaultBus().getOutInterceptors().add(new LoggingOutInterceptor()); BusFactory.getThreadDefaultBus().getInInterceptors().add(new LoggingInInterceptor()); BusFactory.getThreadDefaultBus().getInInterceptors().add(new MalformedResponseInterceptor()); }
Example #28
Source File: JAXRSKerberosBookTest.java From cxf with Apache License 2.0 | 5 votes |
@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("[email protected]"); kbInterceptor.setServiceNameType(GSSName.NT_HOSTBASED_SERVICE); Book b = wc.get(Book.class); Assert.assertEquals(b.getId(), 123); }
Example #29
Source File: SubscriptionEndNotificationTask.java From cxf with Apache License 2.0 | 5 votes |
@Override public void run() { try { // needed SOAP handlers ReferenceParametersAddingHandler handler = new ReferenceParametersAddingHandler( target.getNotificationReferenceParams()); JaxWsProxyFactoryBean service = new JaxWsProxyFactoryBean(); service.getOutInterceptors().add(new LoggingOutInterceptor()); service.setServiceClass(EndToEndpoint.class); service.setAddress(target.getEndToURL()); service.getHandlers().add(handler); EndToEndpoint endpoint = (EndToEndpoint)service.create(); SubscriptionEnd message = new SubscriptionEnd(); message.setStatus(status.toString()); if (reason != null) { LanguageSpecificStringType reasonElement = new LanguageSpecificStringType(); reasonElement.setLang("en-US"); reasonElement.setValue(reason); message.getReason().add(reasonElement); } endpoint.subscriptionEnd(message); } catch (Exception e) { e.printStackTrace(); } }
Example #30
Source File: NestedAddressingPolicyTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void greetMeWSA() throws Exception { // use a wsa-enabled client SpringBusFactory bf = new SpringBusFactory(); bus = bf.createBus(); BusFactory.setDefaultBus(bus); BasicGreeterService gs = new BasicGreeterService(); final Greeter greeter = gs.getGreeterPort(); updateAddressPort(greeter, PORT); LoggingInInterceptor in = new LoggingInInterceptor(); LoggingOutInterceptor out = new LoggingOutInterceptor(); MAPCodec mapCodec = MAPCodec.getInstance(bus); MAPAggregatorImpl mapAggregator = new MAPAggregatorImpl(); bus.getInInterceptors().add(in); bus.getInInterceptors().add(mapCodec); bus.getInInterceptors().add(mapAggregator); bus.getOutInterceptors().add(out); bus.getOutInterceptors().add(mapCodec); bus.getOutInterceptors().add(mapAggregator); String s = greeter.greetMe("mytest"); assertEquals("MYTEST", s); ((Closeable)greeter).close(); }