org.apache.cxf.binding.soap.saaj.SAAJInInterceptor Java Examples
The following examples show how to use
org.apache.cxf.binding.soap.saaj.SAAJInInterceptor.
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: ConfigureCxfSecurity.java From tomee with Apache License 2.0 | 6 votes |
public static final void setupWSS4JChain(InterceptorProvider endpoint, Map<String, Object> inProps, Map<String, Object> outProps) { if (null != inProps && !inProps.isEmpty()) { endpoint.getInInterceptors().add(new SAAJInInterceptor()); endpoint.getInInterceptors().add(new WSS4JInInterceptor(inProps)); // if WS Security is used with a JAX-WS handler (See EjbInterceptor), we have to deal with mustUnderstand flag // in WS Security headers. So, let's add an interceptor endpoint.getInInterceptors().add(new WSSPassThroughInterceptor()); } if (null != outProps && !outProps.isEmpty()) { endpoint.getOutInterceptors().add(new SAAJOutInterceptor()); endpoint.getOutInterceptors().add(new WSS4JOutInterceptor(outProps)); } }
Example #2
Source File: CryptoCoverageCheckerTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testOrder() throws Exception { //make sure the interceptors get ordered correctly SortedSet<Phase> phases = new TreeSet<>(); phases.add(new Phase(Phase.PRE_PROTOCOL, 1)); List<Interceptor<? extends Message>> lst = new ArrayList<>(); lst.add(new MustUnderstandInterceptor()); lst.add(new WSS4JInInterceptor()); lst.add(new SAAJInInterceptor()); lst.add(new CryptoCoverageChecker()); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); chain.add(lst); String output = chain.toString(); assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, " + "WSS4JInInterceptor, CryptoCoverageChecker")); }
Example #3
Source File: CryptoCoverageCheckerTest.java From steady with Apache License 2.0 | 6 votes |
@Test public void testOrder() throws Exception { //make sure the interceptors get ordered correctly SortedSet<Phase> phases = new TreeSet<Phase>(); phases.add(new Phase(Phase.PRE_PROTOCOL, 1)); List<Interceptor<? extends Message>> lst = new ArrayList<Interceptor<? extends Message>>(); lst.add(new MustUnderstandInterceptor()); lst.add(new WSS4JInInterceptor()); lst.add(new SAAJInInterceptor()); lst.add(new CryptoCoverageChecker()); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); chain.add(lst); String output = chain.toString(); assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, " + "WSS4JInInterceptor, CryptoCoverageChecker")); }
Example #4
Source File: CryptoCoverageCheckerTest.java From steady with Apache License 2.0 | 6 votes |
@Test public void testOrder() throws Exception { //make sure the interceptors get ordered correctly SortedSet<Phase> phases = new TreeSet<Phase>(); phases.add(new Phase(Phase.PRE_PROTOCOL, 1)); List<Interceptor<? extends Message>> lst = new ArrayList<Interceptor<? extends Message>>(); lst.add(new MustUnderstandInterceptor()); lst.add(new WSS4JInInterceptor()); lst.add(new SAAJInInterceptor()); lst.add(new CryptoCoverageChecker()); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); chain.add(lst); String output = chain.toString(); assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, " + "WSS4JInInterceptor, CryptoCoverageChecker")); }
Example #5
Source File: CryptoCoverageCheckerTest.java From steady with Apache License 2.0 | 6 votes |
@Test public void testOrder() throws Exception { //make sure the interceptors get ordered correctly SortedSet<Phase> phases = new TreeSet<Phase>(); phases.add(new Phase(Phase.PRE_PROTOCOL, 1)); List<Interceptor<? extends Message>> lst = new ArrayList<Interceptor<? extends Message>>(); lst.add(new MustUnderstandInterceptor()); lst.add(new WSS4JInInterceptor()); lst.add(new SAAJInInterceptor()); lst.add(new CryptoCoverageChecker()); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); chain.add(lst); String output = chain.toString(); assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, " + "WSS4JInInterceptor, CryptoCoverageChecker")); }
Example #6
Source File: CryptoCoverageCheckerTest.java From steady with Apache License 2.0 | 6 votes |
@Test public void testOrder() throws Exception { //make sure the interceptors get ordered correctly SortedSet<Phase> phases = new TreeSet<Phase>(); phases.add(new Phase(Phase.PRE_PROTOCOL, 1)); List<Interceptor<? extends Message>> lst = new ArrayList<Interceptor<? extends Message>>(); lst.add(new MustUnderstandInterceptor()); lst.add(new WSS4JInInterceptor()); lst.add(new SAAJInInterceptor()); lst.add(new CryptoCoverageChecker()); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); chain.add(lst); String output = chain.toString(); assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, " + "WSS4JInInterceptor, CryptoCoverageChecker")); }
Example #7
Source File: WSS4JInInterceptor.java From steady with Apache License 2.0 | 5 votes |
@Override public Collection<PhaseInterceptor<? extends org.apache.cxf.message.Message>> getAdditionalInterceptors() { List<PhaseInterceptor<? extends org.apache.cxf.message.Message>> extras = new ArrayList<PhaseInterceptor<? extends org.apache.cxf.message.Message>>(1); extras.add(SAAJInInterceptor.SAAJPreInInterceptor.INSTANCE); return extras; }
Example #8
Source File: EjbEndpoint.java From tomee with Apache License 2.0 | 5 votes |
protected void init() { // configure handlers try { initHandlers(); } catch (Exception e) { throw new WebServiceException("Error configuring handlers", e); } // Set service to invoke the target ejb service.setInvoker(new EjbMethodInvoker(this.bus, beanContext)); // Remove interceptors that perform handler processing since // handler processing must happen within the EJB container. Endpoint endpoint = getEndpoint(); removeHandlerInterceptors(bus.getInInterceptors()); removeHandlerInterceptors(endpoint.getInInterceptors()); removeHandlerInterceptors(endpoint.getBinding().getInInterceptors()); removeHandlerInterceptors(endpoint.getService().getInInterceptors()); // Install SAAJ interceptor if (endpoint.getBinding() instanceof SoapBinding && !this.implInfo.isWebServiceProvider()) { endpoint.getService().getInInterceptors().add(new SAAJInInterceptor()); } // Install WSS4J interceptor ConfigureCxfSecurity.configure(endpoint, port); }
Example #9
Source File: CalculatorTest.java From tomee with Apache License 2.0 | 5 votes |
public void testCalculatorViaWsInterfaceWithTimestamp2ways() throws Exception { final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplTimestamp2ways?wsdl"), new QName("http://superbiz.org/wsdl", "CalculatorWsService")); assertNotNull(calcService); // for debugging (ie. TCPMon) calcService.addPort(new QName("http://superbiz.org/wsdl", "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING, "http://127.0.0.1:8204/CalculatorImplTimestamp2ways"); // CalculatorWs calc = calcService.getPort( // new QName("http://superbiz.org/wsdl", "CalculatorWsService2"), // CalculatorWs.class); final CalculatorWs calc = calcService.getPort(CalculatorWs.class); final Client client = ClientProxy.getClient(calc); final Endpoint endpoint = client.getEndpoint(); endpoint.getOutInterceptors().add(new SAAJOutInterceptor()); endpoint.getInInterceptors().add(new SAAJInInterceptor()); final Map<String, Object> outProps = new HashMap<String, Object>(); outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP); final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps); endpoint.getOutInterceptors().add(wssOut); final Map<String, Object> inProps = new HashMap<String, Object>(); inProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP); final WSS4JInInterceptor wssIn = new WSS4JInInterceptor(inProps); endpoint.getInInterceptors().add(wssIn); assertEquals(12, calc.multiply(3, 4)); }
Example #10
Source File: WSS4JInOutTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testOrder() throws Exception { //make sure the interceptors get ordered correctly SortedSet<Phase> phases = new TreeSet<>(); phases.add(new Phase(Phase.PRE_PROTOCOL, 1)); List<Interceptor<? extends Message>> lst = new ArrayList<>(); lst.add(new MustUnderstandInterceptor()); lst.add(new WSS4JInInterceptor()); lst.add(new SAAJInInterceptor()); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); chain.add(lst); String output = chain.toString(); assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, WSS4JInInterceptor")); }
Example #11
Source File: WSS4JInInterceptor.java From cxf with Apache License 2.0 | 5 votes |
public WSS4JInInterceptor() { super(); setPhase(Phase.PRE_PROTOCOL); getAfter().add(SAAJInInterceptor.class.getName()); getAfter().add("org.apache.cxf.ws.addressing.soap.MAPCodec"); }
Example #12
Source File: DispatchImpl.java From cxf with Apache License 2.0 | 5 votes |
DispatchImpl(Client client, Service.Mode m, JAXBContext ctx, Class<T> clazz) { this.binding = ((JaxWsEndpointImpl)client.getEndpoint()).getJaxwsBinding(); this.builder = new EndpointReferenceBuilder((JaxWsEndpointImpl)client.getEndpoint()); this.client = client; this.mode = m; context = ctx; cl = clazz; setupEndpointAddressContext(client.getEndpoint()); addInvokeOperation(false); addInvokeOperation(true); if (m == Service.Mode.MESSAGE && binding instanceof SOAPBinding) { if (DataSource.class.isAssignableFrom(clazz)) { error = new Message("DISPATCH_OBJECT_NOT_SUPPORTED", LOG, "DataSource", m, "SOAP/HTTP"); } else if (m == Service.Mode.MESSAGE) { SAAJOutInterceptor saajOut = new SAAJOutInterceptor(); client.getOutInterceptors().add(saajOut); client.getOutInterceptors(). add(new MessageModeOutInterceptor(saajOut, client.getEndpoint() .getBinding().getBindingInfo().getName())); client.getInInterceptors().add(new SAAJInInterceptor()); client.getInInterceptors() .add(new MessageModeInInterceptor(clazz, client.getEndpoint() .getBinding().getBindingInfo().getName())); } } else if (m == Service.Mode.PAYLOAD && binding instanceof SOAPBinding && SOAPMessage.class.isAssignableFrom(clazz)) { error = new Message("DISPATCH_OBJECT_NOT_SUPPORTED", LOG, "SOAPMessage", m, "SOAP/HTTP"); } }
Example #13
Source File: SOAPHandlerInterceptor.java From cxf with Apache License 2.0 | 5 votes |
public void handleMessage(SoapMessage message) { if (binding.getHandlerChain().isEmpty()) { return; } if (getInvoker(message).getProtocolHandlers().isEmpty()) { return; } checkUnderstoodHeaders(message); if (getInvoker(message).isOutbound()) { if (!chainAlreadyContainsSAAJ(message)) { SAAJ_OUT.handleMessage(message); } message.getInterceptorChain().add(ending); } else { boolean isFault = handleMessageInternal(message); SOAPMessage msg = message.getContent(SOAPMessage.class); if (msg != null) { XMLStreamReader xmlReader = createXMLStreamReaderFromSOAPMessage(msg); message.setContent(XMLStreamReader.class, xmlReader); // replace headers try { SAAJInInterceptor.replaceHeaders(msg, message); } catch (SOAPException e) { e.printStackTrace(); } } if (isFault) { Endpoint ep = message.getExchange().getEndpoint(); message.getInterceptorChain().abort(); if (ep.getInFaultObserver() != null) { ep.getInFaultObserver().onMessage(message); } } } }
Example #14
Source File: WSS4JInOutTest.java From steady with Apache License 2.0 | 5 votes |
@Test public void testOrder() throws Exception { //make sure the interceptors get ordered correctly SortedSet<Phase> phases = new TreeSet<Phase>(); phases.add(new Phase(Phase.PRE_PROTOCOL, 1)); List<Interceptor<? extends Message>> lst = new ArrayList<Interceptor<? extends Message>>(); lst.add(new MustUnderstandInterceptor()); lst.add(new WSS4JInInterceptor()); lst.add(new SAAJInInterceptor()); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); chain.add(lst); String output = chain.toString(); assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, WSS4JInInterceptor")); }
Example #15
Source File: WSS4JInInterceptor.java From steady with Apache License 2.0 | 5 votes |
@Override public Collection<PhaseInterceptor<? extends org.apache.cxf.message.Message>> getAdditionalInterceptors() { List<PhaseInterceptor<? extends org.apache.cxf.message.Message>> extras = new ArrayList<PhaseInterceptor<? extends org.apache.cxf.message.Message>>(1); extras.add(SAAJInInterceptor.SAAJPreInInterceptor.INSTANCE); return extras; }
Example #16
Source File: WSS4JInOutTest.java From steady with Apache License 2.0 | 5 votes |
@Test public void testOrder() throws Exception { //make sure the interceptors get ordered correctly SortedSet<Phase> phases = new TreeSet<Phase>(); phases.add(new Phase(Phase.PRE_PROTOCOL, 1)); List<Interceptor<? extends Message>> lst = new ArrayList<Interceptor<? extends Message>>(); lst.add(new MustUnderstandInterceptor()); lst.add(new WSS4JInInterceptor()); lst.add(new SAAJInInterceptor()); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); chain.add(lst); String output = chain.toString(); assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, WSS4JInInterceptor")); }
Example #17
Source File: WSS4JInInterceptor.java From steady with Apache License 2.0 | 5 votes |
@Override public Collection<PhaseInterceptor<? extends org.apache.cxf.message.Message>> getAdditionalInterceptors() { List<PhaseInterceptor<? extends org.apache.cxf.message.Message>> extras = new ArrayList<PhaseInterceptor<? extends org.apache.cxf.message.Message>>(1); extras.add(SAAJInInterceptor.SAAJPreInInterceptor.INSTANCE); return extras; }
Example #18
Source File: WSS4JInOutTest.java From steady with Apache License 2.0 | 5 votes |
@Test public void testOrder() throws Exception { //make sure the interceptors get ordered correctly SortedSet<Phase> phases = new TreeSet<Phase>(); phases.add(new Phase(Phase.PRE_PROTOCOL, 1)); List<Interceptor<? extends Message>> lst = new ArrayList<Interceptor<? extends Message>>(); lst.add(new MustUnderstandInterceptor()); lst.add(new WSS4JInInterceptor()); lst.add(new SAAJInInterceptor()); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); chain.add(lst); String output = chain.toString(); assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, WSS4JInInterceptor")); }
Example #19
Source File: WSS4JInOutTest.java From steady with Apache License 2.0 | 5 votes |
@Test public void testOrder() throws Exception { //make sure the interceptors get ordered correctly SortedSet<Phase> phases = new TreeSet<Phase>(); phases.add(new Phase(Phase.PRE_PROTOCOL, 1)); List<Interceptor<? extends Message>> lst = new ArrayList<Interceptor<? extends Message>>(); lst.add(new MustUnderstandInterceptor()); lst.add(new WSS4JInInterceptor()); lst.add(new SAAJInInterceptor()); PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); chain.add(lst); String output = chain.toString(); assertTrue(output.contains("MustUnderstandInterceptor, SAAJInInterceptor, WSS4JInInterceptor")); }
Example #20
Source File: WSS4JInInterceptor.java From steady with Apache License 2.0 | 5 votes |
@Override public Collection<PhaseInterceptor<? extends org.apache.cxf.message.Message>> getAdditionalInterceptors() { List<PhaseInterceptor<? extends org.apache.cxf.message.Message>> extras = new ArrayList<PhaseInterceptor<? extends org.apache.cxf.message.Message>>(1); extras.add(SAAJInInterceptor.SAAJPreInInterceptor.INSTANCE); return extras; }
Example #21
Source File: WSS4JInInterceptor.java From steady with Apache License 2.0 | 4 votes |
private SOAPMessage getSOAPMessage(SoapMessage msg) { SAAJInInterceptor.INSTANCE.handleMessage(msg); return msg.getContent(SOAPMessage.class); }
Example #22
Source File: WSS4JInInterceptor.java From steady with Apache License 2.0 | 4 votes |
public WSS4JInInterceptor() { super(); setPhase(Phase.PRE_PROTOCOL); getAfter().add(SAAJInInterceptor.class.getName()); }
Example #23
Source File: WSS4JInInterceptor.java From steady with Apache License 2.0 | 4 votes |
private SOAPMessage getSOAPMessage(SoapMessage msg) { SAAJInInterceptor.INSTANCE.handleMessage(msg); return msg.getContent(SOAPMessage.class); }
Example #24
Source File: RoundTripTest.java From steady with Apache License 2.0 | 4 votes |
@Before public void setUpService() throws Exception { 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 SAAJInInterceptor()); service.getInInterceptors().add(new LoggingInInterceptor()); service.getOutInterceptors().add(new SAAJOutInterceptor()); service.getOutInterceptors().add(new LoggingOutInterceptor()); wsIn = new WSS4JInInterceptor(); wsIn.setProperty(WSHandlerConstants.SIG_PROP_FILE, "insecurity.properties"); wsIn.setProperty(WSHandlerConstants.DEC_PROP_FILE, "insecurity.properties"); wsIn.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName()); service.getInInterceptors().add(wsIn); wsOut = new WSS4JOutInterceptor(); wsOut.setProperty(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties"); wsOut.setProperty(WSHandlerConstants.ENC_PROP_FILE, "outsecurity.properties"); wsOut.setProperty(WSHandlerConstants.USER, "myalias"); wsOut.setProperty("password", "myAliasPassword"); wsOut.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName()); service.getOutInterceptors().add(wsOut); // Create the client JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean(); proxyFac.setServiceClass(Echo.class); proxyFac.setAddress("local://Echo"); proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID); echo = (Echo)proxyFac.create(); client = ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getInInterceptors().add(wsIn); client.getInInterceptors().add(new SAAJInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); client.getOutInterceptors().add(wsOut); client.getOutInterceptors().add(new SAAJOutInterceptor()); }
Example #25
Source File: CustomUTValidator.java From cxf-fediz with Apache License 2.0 | 4 votes |
private SOAPMessage getSOAPMessage(SoapMessage msg) { SAAJInInterceptor.INSTANCE.handleMessage(msg); return msg.getContent(SOAPMessage.class); }
Example #26
Source File: UserNameTokenAuthorizationTest.java From steady with Apache License 2.0 | 4 votes |
public void setUpService(String expectedRoles, boolean digest, boolean encryptUsernameTokenOnly) throws Exception { 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 SAAJInInterceptor()); service.getInInterceptors().add(new LoggingInInterceptor()); service.getOutInterceptors().add(new SAAJOutInterceptor()); service.getOutInterceptors().add(new LoggingOutInterceptor()); wsIn = new SimpleSubjectCreatingInterceptor(); wsIn.setSupportDigestPasswords(digest); wsIn.setProperty(WSHandlerConstants.SIG_PROP_FILE, "insecurity.properties"); wsIn.setProperty(WSHandlerConstants.DEC_PROP_FILE, "insecurity.properties"); wsIn.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName()); service.getInInterceptors().add(wsIn); SimpleAuthorizingInterceptor sai = new SimpleAuthorizingInterceptor(); sai.setMethodRolesMap(Collections.singletonMap("echo", expectedRoles)); service.getInInterceptors().add(sai); wsOut = new WSS4JOutInterceptor(); wsOut.setProperty(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties"); wsOut.setProperty(WSHandlerConstants.ENC_PROP_FILE, "outsecurity.properties"); wsOut.setProperty(WSHandlerConstants.USER, "myalias"); if (digest) { wsOut.setProperty("password", "myAliasPassword"); } else { wsOut.setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT); } if (encryptUsernameTokenOnly) { wsOut.setProperty(WSHandlerConstants.ENCRYPTION_USER, "myalias"); wsOut.setProperty( WSHandlerConstants.ENCRYPTION_PARTS, "{Content}{" + WSConstants.WSSE_NS + "}UsernameToken" ); } wsOut.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName()); service.getOutInterceptors().add(wsOut); // Create the client JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean(); proxyFac.setServiceClass(Echo.class); proxyFac.setAddress("local://Echo"); proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID); echo = (Echo)proxyFac.create(); ((BindingProvider)echo).getRequestContext().put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE); client = ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getInInterceptors().add(wsIn); client.getInInterceptors().add(new SAAJInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); client.getOutInterceptors().add(wsOut); client.getOutInterceptors().add(new SAAJOutInterceptor()); }
Example #27
Source File: UserNameTokenAuthorizationTest.java From cxf with Apache License 2.0 | 4 votes |
public void setUpService(String expectedRoles, boolean digest, boolean encryptUsernameTokenOnly) throws Exception { 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 SAAJInInterceptor()); service.getInInterceptors().add(new LoggingInInterceptor()); service.getOutInterceptors().add(new SAAJOutInterceptor()); service.getOutInterceptors().add(new LoggingOutInterceptor()); wsIn = new SimpleSubjectCreatingInterceptor(); wsIn.setSupportDigestPasswords(digest); wsIn.setProperty(ConfigurationConstants.SIG_PROP_FILE, "insecurity.properties"); wsIn.setProperty(ConfigurationConstants.DEC_PROP_FILE, "insecurity.properties"); wsIn.setProperty(ConfigurationConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName()); service.getInInterceptors().add(wsIn); SimpleAuthorizingInterceptor sai = new SimpleAuthorizingInterceptor(); sai.setMethodRolesMap(Collections.singletonMap("echo", expectedRoles)); service.getInInterceptors().add(sai); wsOut = new WSS4JOutInterceptor(); wsOut.setProperty(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties"); wsOut.setProperty(ConfigurationConstants.ENC_PROP_FILE, "outsecurity.properties"); wsOut.setProperty(ConfigurationConstants.USER, "myalias"); if (digest) { wsOut.setProperty("password", "myAliasPassword"); } else { wsOut.setProperty(ConfigurationConstants.PASSWORD_TYPE, WSS4JConstants.PW_TEXT); } if (encryptUsernameTokenOnly) { wsOut.setProperty(ConfigurationConstants.ENCRYPTION_USER, "myalias"); wsOut.setProperty( ConfigurationConstants.ENCRYPTION_PARTS, "{Content}{" + WSS4JConstants.WSSE_NS + "}UsernameToken" ); } wsOut.setProperty(ConfigurationConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName()); service.getOutInterceptors().add(wsOut); // Create the client JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean(); proxyFac.setServiceClass(Echo.class); proxyFac.setAddress("local://Echo"); proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID); echo = (Echo)proxyFac.create(); ((BindingProvider)echo).getRequestContext().put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE); client = ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getInInterceptors().add(wsIn); client.getInInterceptors().add(new SAAJInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); client.getOutInterceptors().add(wsOut); client.getOutInterceptors().add(new SAAJOutInterceptor()); }
Example #28
Source File: RoundTripTest.java From cxf with Apache License 2.0 | 4 votes |
@Before public void setUpService() throws Exception { 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 SAAJInInterceptor()); service.getInInterceptors().add(new LoggingInInterceptor()); service.getOutInterceptors().add(new SAAJOutInterceptor()); service.getOutInterceptors().add(new LoggingOutInterceptor()); wsIn = new WSS4JInInterceptor(); wsIn.setProperty(ConfigurationConstants.SIG_VER_PROP_FILE, "insecurity.properties"); wsIn.setProperty(ConfigurationConstants.DEC_PROP_FILE, "insecurity.properties"); wsIn.setProperty(ConfigurationConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName()); service.getInInterceptors().add(wsIn); wsOut = new WSS4JOutInterceptor(); wsOut.setProperty(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties"); wsOut.setProperty(ConfigurationConstants.ENC_PROP_FILE, "outsecurity.properties"); wsOut.setProperty(ConfigurationConstants.USER, "myalias"); wsOut.setProperty("password", "myAliasPassword"); wsOut.setProperty(ConfigurationConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName()); service.getOutInterceptors().add(wsOut); // Create the client JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean(); proxyFac.setServiceClass(Echo.class); proxyFac.setAddress("local://Echo"); proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID); echo = (Echo)proxyFac.create(); client = ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getInInterceptors().add(wsIn); client.getInInterceptors().add(new SAAJInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); client.getOutInterceptors().add(wsOut); client.getOutInterceptors().add(new SAAJOutInterceptor()); }
Example #29
Source File: WSS4JInInterceptor.java From cxf with Apache License 2.0 | 4 votes |
private SOAPMessage getSOAPMessage(SoapMessage msg) { SAAJInInterceptor.INSTANCE.handleMessage(msg); return msg.getContent(SOAPMessage.class); }
Example #30
Source File: WSS4JInInterceptor.java From steady with Apache License 2.0 | 4 votes |
public WSS4JInInterceptor() { super(); setPhase(Phase.PRE_PROTOCOL); getAfter().add(SAAJInInterceptor.class.getName()); }