org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor Java Examples

The following examples show how to use org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor. 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: CryptoCoverageCheckerTest.java    From steady with Apache License 2.0 6 votes vote down vote up
@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 #2
Source File: CryptoCoverageCheckerTest.java    From steady with Apache License 2.0 6 votes vote down vote up
@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 #3
Source File: CryptoCoverageCheckerTest.java    From steady with Apache License 2.0 6 votes vote down vote up
@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 vote down vote up
@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 cxf with Apache License 2.0 6 votes vote down vote up
@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 #6
Source File: MustUnderstandInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testHandleMessageFail() throws Exception {
    prepareSoapMessage("test-soap-header.xml");

    dsi.getUnderstoodHeaders().add(RESERVATION);

    soapMessage.getInterceptorChain().doIntercept(soapMessage);

    assertTrue("DummaySoapInterceptor getRoles has been called!", dsi.isCalledGetRoles());
    assertTrue("DummaySoapInterceptor getUnderstood has been called!", dsi.isCalledGetUnderstood());

    Set<QName> ie = CastUtils.cast((Set<?>)soapMessage.get(MustUnderstandInterceptor.UNKNOWNS));
    if (ie == null) {
        fail("InBound unknowns missing! Exception should be Can't understands QNames: " + PASSENGER);
    } else {
        assertTrue(ie.contains(PASSENGER));
    }
}
 
Example #7
Source File: WSS4JInOutTest.java    From steady with Apache License 2.0 5 votes vote down vote up
@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 #8
Source File: WSS4JInOutTest.java    From steady with Apache License 2.0 5 votes vote down vote up
@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 #9
Source File: WSS4JInOutTest.java    From steady with Apache License 2.0 5 votes vote down vote up
@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 #10
Source File: WSS4JInOutTest.java    From steady with Apache License 2.0 5 votes vote down vote up
@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 #11
Source File: WSS4JInOutTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@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 #12
Source File: EjbEndpoint.java    From tomee with Apache License 2.0 5 votes vote down vote up
private static void removeHandlerInterceptors(List<? extends Interceptor> interceptors) {
    for (Interceptor interceptor : interceptors) {
        if (interceptor instanceof MustUnderstandInterceptor || interceptor instanceof LogicalHandlerInInterceptor || interceptor instanceof SOAPHandlerInterceptor) {
            interceptors.remove(interceptor);
        }
    }
}
 
Example #13
Source File: MustUnderstandInterceptorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {

    super.setUp();

    Bus bus = BusFactory.getDefaultBus();

    rhi = new ReadHeadersInterceptor(bus, "phase1");
    chain.add(rhi);

    sbi = new StartBodyInterceptor("phase1.5");
    chain.add(sbi);

    mui = new MustUnderstandInterceptor("phase2");
    chain.add(mui);

    dsi = new DummySoapInterceptor("phase3");
    chain.add(dsi);
}
 
Example #14
Source File: EjbInterceptor.java    From tomee with Apache License 2.0 4 votes vote down vote up
@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
    Endpoint endpoint = this.exchange.get(Endpoint.class);
    Service service = endpoint.getService();
    Binding binding = ((JaxWsEndpointImpl) endpoint).getJaxwsBinding();

    this.exchange.put(InvocationContext.class, context);

    if (binding.getHandlerChain() == null || binding.getHandlerChain().isEmpty()) {
        // no handlers so let's just directly invoke the bean
        log.debug("No handlers found.");

        EjbMethodInvoker invoker = (EjbMethodInvoker) service.getInvoker();
        return invoker.directEjbInvoke(this.exchange, this.method, this.params);

    } else {
        // have handlers so have to run handlers now and redo data binding
        // as handlers can change the soap message
        log.debug("Handlers found.");

        Message inMessage = exchange.getInMessage();
        PhaseInterceptorChain chain = new PhaseInterceptorChain(bus.getExtension(PhaseManager.class).getInPhases());

        chain.setFaultObserver(endpoint.getOutFaultObserver());

        /*
         * Since we have to re-do data binding and the XMLStreamReader
         * contents are already consumed by prior data binding step
         * we have to reinitialize the XMLStreamReader from the SOAPMessage
         * created by SAAJInInterceptor.
         */
        if (inMessage instanceof SoapMessage) {
            try {
                reserialize((SoapMessage) inMessage);
            } catch (Exception e) {
                throw new ServerRuntimeException("Failed to reserialize soap message", e);
            }
        } else {
            // TODO: how to handle XML/HTTP binding?
        }

        this.exchange.setOutMessage(null);

        // install default interceptors
        chain.add(new ServiceInvokerInterceptor());
        //chain.add(new OutgoingChainInterceptor()); // it is already in the enclosing chain, if we add it there we are in the tx so we write the message in the tx!

        // See http://cwiki.apache.org/CXF20DOC/interceptors.html
        // install Holder and Wrapper interceptors
        chain.add(new WrapperClassInInterceptor());
        chain.add(new HolderInInterceptor());

        // install interceptors for handler processing
        chain.add(new MustUnderstandInterceptor());
        chain.add(new LogicalHandlerInInterceptor(binding));
        chain.add(new SOAPHandlerInterceptor(binding));

        // install data binding interceptors - todo: check we need it
        copyDataBindingInterceptors(chain, inMessage.getInterceptorChain());

        InterceptorChain oldChain = inMessage.getInterceptorChain();
        inMessage.setInterceptorChain(chain);
        try {
            chain.doIntercept(inMessage);
        } finally {
            inMessage.setInterceptorChain(oldChain);
        }

        // TODO: the result should be deserialized from SOAPMessage
        Object result = getResult();

        return result;
    }
}