org.apache.cxf.interceptor.Interceptor Java Examples

The following examples show how to use org.apache.cxf.interceptor.Interceptor. 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: JAXRSLocalTransportTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setResourceClasses(BookStore.class, BookStoreSpring.class);
    sf.setResourceProvider(BookStore.class,
                           new SingletonResourceProvider(new BookStore(), true));
    sf.setResourceProvider(BookStoreSpring.class,
                           new SingletonResourceProvider(new BookStoreSpring(), true));
    sf.setProvider(new JacksonJsonProvider());
    List<Interceptor<? extends Message>> outInts = new ArrayList<>();
    outInts.add(new CustomOutInterceptor());
    sf.setOutInterceptors(outInts);

    List<Interceptor<? extends Message>> inInts = new ArrayList<>();
    inInts.add(new CustomInFaultyInterceptor());
    sf.setInInterceptors(inInts);

    sf.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    sf.setAddress("local://books");
    localServer = sf.create();
}
 
Example #2
Source File: AnnotationInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimpleFrontend() throws Exception {
    fb.setServiceClass(HelloService.class);
    HelloService hello = new HelloServiceImpl();
    fb.setServiceBean(hello);
    server = fb.create();

    List<Interceptor<? extends Message>> interceptors
        = server.getEndpoint().getInInterceptors();
    assertTrue(hasTestInterceptor(interceptors));
    assertFalse(hasTest2Interceptor(interceptors));

    List<Interceptor<? extends Message>> outFaultInterceptors
        = server.getEndpoint().getOutFaultInterceptors();
    assertTrue(hasTestInterceptor(outFaultInterceptors));
    assertTrue(hasTest2Interceptor(outFaultInterceptors));
}
 
Example #3
Source File: ControlImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void setFaultLocation(FaultLocation fl) {
    List<Interceptor<? extends Message>> interceptors = greeterBus.getInInterceptors();
    FaultThrowingInterceptor fi = null;
    for (Interceptor<? extends Message> i : interceptors) {
        if (i instanceof FaultThrowingInterceptor) {
            interceptors.remove(i);
            LOG.fine("Removed existing FaultThrowingInterceptor");
            break;
        }
    }
    if (null == fl.getPhase() || "".equals(fl.getPhase())) {
        LOG.fine("Removed FaultThrowingInterceptor");
        return;
    }

    fi = new FaultThrowingInterceptor(fl.getPhase());
    if (null != fl.getBefore() && !"".equals(fl.getBefore())) {
        fi.addBefore(fl.getBefore());
    }
    if (null != fl.getAfter() && !"".equals(fl.getAfter())) {
        fi.addAfter(fl.getAfter());
    }

    interceptors.add(fi);
    LOG.fine("Added FaultThrowingInterceptor to phase " + fl.getPhase());
}
 
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: EffectivePolicyImplTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void setupRegistryInterceptors(boolean useIn, boolean fault,
                                       PolicyInterceptorProviderRegistry reg, QName qn,
                                       List<Interceptor<? extends Message>> m) {
    if (useIn && !fault) {
        EasyMock.expect(reg.getInInterceptorsForAssertion(qn))
            .andReturn(m);
    } else if (!useIn && !fault) {
        EasyMock.expect(reg.getOutInterceptorsForAssertion(qn))
            .andReturn(m);
    } else if (useIn && fault) {
        EasyMock.expect(reg.getInFaultInterceptorsForAssertion(qn))
            .andReturn(m);
    } else if (!useIn && fault) {
        EasyMock.expect(reg.getOutFaultInterceptorsForAssertion(qn))
            .andReturn(m);
    }
}
 
Example #6
Source File: PolicyInterceptorsTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void doTestBasics(Interceptor<Message> interceptor, boolean isClient, boolean usesOperationInfo) {
    setupMessage(!isClient, isClient, usesOperationInfo, !usesOperationInfo, false, false);
    control.replay();
    interceptor.handleMessage(message);
    control.verify();

    control.reset();
    setupMessage(isClient, isClient, usesOperationInfo, !usesOperationInfo, false, false);
    control.replay();
    interceptor.handleMessage(message);
    control.verify();

    control.reset();
    setupMessage(isClient, isClient, usesOperationInfo, usesOperationInfo, false, false);
    control.replay();
    interceptor.handleMessage(message);
    control.verify();

    control.reset();
    setupMessage(isClient, isClient, usesOperationInfo, usesOperationInfo, true, false);
    control.replay();
    interceptor.handleMessage(message);
    control.verify();
}
 
Example #7
Source File: PhaseInterceptorChainTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testThreeInterceptorSamePhaseWithOrder() throws Exception {
    AbstractPhaseInterceptor<? extends Message> p1 = setUpPhaseInterceptor("phase1", "p1");
    Set<String> before = new HashSet<>();
    before.add("p1");
    AbstractPhaseInterceptor<? extends Message> p2 = setUpPhaseInterceptor("phase1", "p2", before, null);
    Set<String> before1 = new HashSet<>();
    before1.add("p2");
    AbstractPhaseInterceptor<? extends Message> p3 = setUpPhaseInterceptor("phase1", "p3", before1, null);
    control.replay();
    chain.add(p3);
    chain.add(p1);
    chain.add(p2);

    Iterator<Interceptor<? extends Message>> it = chain.iterator();
    assertSame("Unexpected interceptor at this position.", p3, it.next());
    assertSame("Unexpected interceptor at this position.", p2, it.next());
    assertSame("Unexpected interceptor at this position.", p1, it.next());
    assertFalse(it.hasNext());
}
 
Example #8
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 #9
Source File: WSAFeatureXmlTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void checkAddressInterceptors(List<Interceptor<? extends Message>> interceptors) {
    boolean hasAg = false;
    boolean hasCodec = false;
    Object cache = null;

    for (Interceptor<? extends Message> i : interceptors) {
        if (i instanceof MAPAggregator) {
            hasAg = true;
            cache = ((MAPAggregator) i).getMessageIdCache();
        } else if (i instanceof MAPCodec) {
            hasCodec = true;
        }
    }

    assertTrue(cache instanceof TestCache);
    assertTrue(hasAg);
    assertTrue(hasCodec);
}
 
Example #10
Source File: ClientImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void modifyChain(InterceptorChain chain, Message ctx, boolean in) {
    if (ctx == null) {
        return;
    }
    Collection<InterceptorProvider> providers
        = CastUtils.cast((Collection<?>)ctx.get(Message.INTERCEPTOR_PROVIDERS));
    if (providers != null) {
        for (InterceptorProvider p : providers) {
            if (in) {
                chain.add(p.getInInterceptors());
            } else {
                chain.add(p.getOutInterceptors());
            }
        }
    }
    String key = in ? Message.IN_INTERCEPTORS : Message.OUT_INTERCEPTORS;
    Collection<Interceptor<? extends Message>> is
        = CastUtils.cast((Collection<?>)ctx.get(key));
    if (is != null) {
        chain.add(is);
    }
}
 
Example #11
Source File: EndpointPolicyImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
void initializeInterceptors(PolicyInterceptorProviderRegistry reg,
                            Set<Interceptor<? extends Message>> out, Assertion a,
                            boolean fault, Message msg) {
    QName qn = a.getName();
    List<Interceptor<? extends org.apache.cxf.message.Message>> i
        = fault ? reg.getInFaultInterceptorsForAssertion(qn)
        : reg.getInInterceptorsForAssertion(qn);
    out.addAll(i);
    if (a instanceof PolicyContainingAssertion) {
        Policy p = ((PolicyContainingAssertion)a).getPolicy();
        if (p != null) {
            for (Assertion a2 : getSupportedAlternatives(p, msg)) {
                initializeInterceptors(reg, out, a2, fault, msg);
            }
        }
    }
}
 
Example #12
Source File: MustUnderstandInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void initServiceSideInfo(Set<QName> mustUnderstandQNames, SoapMessage soapMessage,
                Set<URI> serviceRoles, Set<QName> paramHeaders) {

    if (paramHeaders != null) {
        mustUnderstandQNames.addAll(paramHeaders);
    }
    for (Interceptor<? extends org.apache.cxf.message.Message> interceptorInstance
        : soapMessage.getInterceptorChain()) {
        if (interceptorInstance instanceof SoapInterceptor) {
            SoapInterceptor si = (SoapInterceptor) interceptorInstance;
            Set<URI> roles = si.getRoles();
            if (roles != null) {
                serviceRoles.addAll(roles);
            }
            Set<QName> understoodHeaders = si.getUnderstoodHeaders();
            if (understoodHeaders != null) {
                mustUnderstandQNames.addAll(understoodHeaders);
            }
        }
    }
}
 
Example #13
Source File: PhaseChainCache.java    From cxf with Apache License 2.0 6 votes vote down vote up
@SafeVarargs
static PhaseInterceptorChain getChain(AtomicReference<ChainHolder> lastData,
                                      SortedSet<Phase> phaseList,
                                     List<Interceptor<? extends Message>> ... providers) {
    ChainHolder last = lastData.get();

    if (last == null
        || !last.matches(providers)) {

        PhaseInterceptorChain chain = new PhaseInterceptorChain(phaseList);
        List<ModCountCopyOnWriteArrayList<Interceptor<? extends Message>>> copy
            = new ArrayList<ModCountCopyOnWriteArrayList<
                Interceptor<? extends Message>>>(providers.length);
        for (List<Interceptor<? extends Message>> p : providers) {
            copy.add(new ModCountCopyOnWriteArrayList<Interceptor<? extends Message>>(p));
            chain.add(p);
        }
        last = new ChainHolder(chain, copy);
        lastData.set(last);
    }


    return last.chain.cloneChain();
}
 
Example #14
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 #15
Source File: XMLBindingFactoryTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testContainsInAttachmentInterceptor() {
    XMLBindingFactory xbf = new XMLBindingFactory();
    Binding b = xbf.createBinding(new BindingInfo(null, null));

    boolean found = false;
    for (Interceptor<? extends Message> interseptor : b.getInInterceptors()) {
        if (interseptor instanceof AttachmentInInterceptor) {
            found = true;
        }
    }

    assertTrue("No in attachment interceptor found", found);
}
 
Example #16
Source File: AbstractClient.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected static PhaseInterceptorChain setupOutInterceptorChain(ClientConfiguration cfg) {
    PhaseManager pm = cfg.getBus().getExtension(PhaseManager.class);
    List<Interceptor<? extends Message>> i1 = cfg.getBus().getOutInterceptors();
    List<Interceptor<? extends Message>> i2 = cfg.getOutInterceptors();
    List<Interceptor<? extends Message>> i3 = cfg.getConduitSelector().getEndpoint().getOutInterceptors();
    PhaseInterceptorChain chain = new PhaseChainCache().get(pm.getOutPhases(), i1, i2, i3);
    chain.add(new ClientRequestFilterInterceptor());
    return chain;
}
 
Example #17
Source File: BusDefinitionParser.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void setInFaultInterceptors(List<Interceptor<? extends Message>> interceptors) {
    if (bus != null) {
        bus.getInFaultInterceptors().addAll(interceptors);
    } else {
        super.setInFaultInterceptors(interceptors);
    }
}
 
Example #18
Source File: EffectivePolicyImplTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private List<Interceptor<? extends Message>> createMockInterceptorList() {
    Interceptor<? extends Message> i = control.createMock(Interceptor.class);
    Interceptor<? extends Message> m = i;
    List<Interceptor<? extends Message>> a = new ArrayList<>();
    a.add(m);
    return a;
}
 
Example #19
Source File: PhaseChainCache.java    From cxf with Apache License 2.0 5 votes vote down vote up
public PhaseInterceptorChain get(SortedSet<Phase> phaseList,
                                 List<Interceptor<? extends Message>> p1,
                                 List<Interceptor<? extends Message>> p2,
                                 List<Interceptor<? extends Message>> p3,
                                 List<Interceptor<? extends Message>> p4) {
    return getChain(lastData, phaseList, p1, p2, p3, p4);
}
 
Example #20
Source File: PhaseChainCache.java    From cxf with Apache License 2.0 5 votes vote down vote up
public PhaseInterceptorChain get(SortedSet<Phase> phaseList,
                                 List<Interceptor<? extends Message>> p1,
                                 List<Interceptor<? extends Message>> p2,
                                 List<Interceptor<? extends Message>> p3,
                                 List<Interceptor<? extends Message>> p4,
                                 List<Interceptor<? extends Message>> p5) {
    return getChain(lastData, phaseList, p1, p2, p3, p4, p5);
}
 
Example #21
Source File: ConfiguredEndpointTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private TestInterceptor findTestInterceptor(List<Interceptor<? extends Message>> interceptors) {
    for (Interceptor<? extends Message> i : interceptors) {
        if (i instanceof TestInterceptor) {
            return (TestInterceptor)i;
        }
    }
    return null;
}
 
Example #22
Source File: AnnotationInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean hasAnnotationFeatureInterceptor(List<Interceptor<? extends Message>> interceptors) {
    boolean flag = false;
    for (Interceptor<? extends Message> it : interceptors) {
        if (it instanceof AnnotationFeatureInterceptor) {
            flag = true;
        }
    }
    return flag;
}
 
Example #23
Source File: PolicyEngineTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Set<String> getInterceptorIds(List<Interceptor<? extends Message>> interceptors) {
    Set<String> ids = new HashSet<>();
    for (Interceptor<? extends Message> i : interceptors) {
        ids.add(((PhaseInterceptor<? extends Message>)i).getId());
    }
    return ids;
}
 
Example #24
Source File: ClientBuilderTest.java    From dropwizard-jaxws with Apache License 2.0 5 votes vote down vote up
@Test
public void buildClient() {

    Handler<?> handler = mock(Handler.class);

    Interceptor<?> inInterceptor = mock(Interceptor.class);
    Interceptor<?> inFaultInterceptor = mock(Interceptor.class);
    Interceptor<?> outInterceptor = mock(Interceptor.class);
    Interceptor<?> outFaultInterceptor = mock(Interceptor.class);

    ClientBuilder<Object> builder = new ClientBuilder<>(Object.class, "address")
            .connectTimeout(1234)
            .receiveTimeout(5678)
            .handlers(handler, handler)
            .bindingId("binding id")
            .cxfInInterceptors(inInterceptor, inInterceptor)
            .cxfInFaultInterceptors(inFaultInterceptor, inFaultInterceptor)
            .cxfOutInterceptors(outInterceptor, outInterceptor)
            .cxfOutFaultInterceptors(outFaultInterceptor, outFaultInterceptor);

    assertThat(builder.getAddress(), equalTo("address"));
    assertThat(builder.getServiceClass(), equalTo(Object.class));
    assertThat(builder.getConnectTimeout(), equalTo(1234));
    assertThat(builder.getReceiveTimeout(), equalTo(5678));
    assertThat(builder.getBindingId(), equalTo("binding id"));
    assertThat(builder.getCxfInInterceptors(), contains(new Interceptor<?>[]{ inInterceptor, inInterceptor }));
    assertThat(builder.getCxfInFaultInterceptors(), contains(new Interceptor<?>[]{ inFaultInterceptor, inFaultInterceptor }));
    assertThat(builder.getCxfOutInterceptors(), contains(new Interceptor<?>[]{ outInterceptor, outInterceptor }));
    assertThat(builder.getCxfOutFaultInterceptors(), contains(new Interceptor<?>[]{ outFaultInterceptor, outFaultInterceptor }));
}
 
Example #25
Source File: CorbaBindingTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testCorbaBinding() {
    CorbaBinding binding = new CorbaBinding();
    List<Interceptor<? extends Message>> in = binding.getInInterceptors();
    assertNotNull(in);
    List<Interceptor<? extends Message>> out = binding.getOutInterceptors();
    assertNotNull(out);
    List<Interceptor<? extends Message>> infault = binding.getInFaultInterceptors();
    assertNotNull(infault);
    List<Interceptor<? extends Message>> outfault = binding.getFaultOutInterceptors();
    assertNotNull(outfault);
    Message message = binding.createMessage();
    message.put(ORB.class, orb);
    assertNotNull(message);
    ORB corbaORB = message.get(ORB.class);
    assertNotNull(corbaORB);
    MessageImpl mesage = new MessageImpl();
    mesage.put(ORB.class, orb);
    Message msg = binding.createMessage(mesage);
    assertNotNull(msg);
    ORB corbaOrb = msg.get(ORB.class);
    assertNotNull(corbaOrb);
    /*List<Interceptor> infault = binding.getInFaultInterceptors();
    assertEquals(1, infault.size());
    List<Interceptor> outfault = binding.getOutFaultInterceptors();
    assertEquals(1, fault.size());*/
}
 
Example #26
Source File: WssAuthTest.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
protected static OrderEndpoint createCXFClient(String url, String user, String passwordCallbackClass) {
    List<Interceptor<? extends Message>> outInterceptors = new ArrayList();

    // Define WSS4j properties for flow outgoing
    Map<String, Object> outProps = new HashMap<String, Object>();
    outProps.put("action", "UsernameToken Timestamp");
    outProps.put("user", user);
    outProps.put("passwordCallbackClass", passwordCallbackClass);

    WSS4JOutInterceptor wss4j = new WSS4JOutInterceptor(outProps);
    // Add LoggingOutInterceptor
    LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();

    outInterceptors.add(wss4j);
    outInterceptors.add(loggingOutInterceptor);

    // we use CXF to create a client for us as its easier than JAXWS and works
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setOutInterceptors(outInterceptors);
    factory.setServiceClass(OrderEndpoint.class);
    factory.setAddress(url);
    return (OrderEndpoint) factory.create();
}
 
Example #27
Source File: MicroProfileClientProxyImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void init(ExecutorService executorService, Configuration configuration) {
    cfg.getRequestContext().put(EXECUTOR_SERVICE_PROPERTY, executorService);
    cfg.getRequestContext().putAll(configuration.getProperties());

    List<Interceptor<? extends Message>>inboundChain = cfg.getInInterceptors();
    inboundChain.add(new MPAsyncInvocationInterceptorPostAsyncImpl());
    inboundChain.add(new MPAsyncInvocationInterceptorRemoveContextImpl());
}
 
Example #28
Source File: MAPCodec.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Invoked when unwinding normal interceptor chain when a fault occurred.
 *
 * @param message the messsage message
 */
public void handleFault(SoapMessage message) {
    if (!message.getExchange().isOneWay()) {
        AddressingProperties maps = ContextUtils.retrieveMAPs(message, false, true, false);
        if (ContextUtils.isRequestor(message)
            && maps != null) {
            //fault occurred trying to send the message, remove it
            uncorrelatedExchanges.remove(maps.getMessageID().getValue());
        } else if (!ContextUtils.isRequestor(message)
            && maps == null
            && !message.containsKey(MAPAggregator.class.getName())) {
            //fault occurred while processing the incoming message, but possibly
            //before the MAPAggregator was called.   We need to see if we can
            //try and map this if at all possible so a FaultTo/ReplyTo can
            //be properly determined to get the fault back to the rightful
            //place.
            for (Interceptor<? extends Message> i : message.getInterceptorChain()) {
                if (i instanceof MAPAggregator) {
                    try {
                        MAPAggregator agg = (MAPAggregator)i;
                        agg.handleMessage(message);
                    } catch (Throwable t) {
                        //ignore
                    }
                    return;
                }
            }
        }
    }
    if (MessageUtils.getContextualBoolean(message, DECOUPLED_FAULT_SUPPORT, false)) {
        new DecoupledFaultHandler().handleFault(message);
    }
}
 
Example #29
Source File: RedeliveryQueueImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static void addInterceptors(PhaseInterceptorChain chain,
                                    List<Interceptor<? extends Message>> il) {
    for (Interceptor<? extends Message> i : il) {
        final String iname = i.getClass().getSimpleName();
        if ("OneWayProcessorInterceptor".equals(iname)
            || "MAPAggregatorImpl".equals(iname)
            || "RMInInterceptor".equals(iname)) {
            continue;
        }
        chain.add(i);
    }
}
 
Example #30
Source File: CustomerSecurityInterceptor.java    From servicemix with Apache License 2.0 5 votes vote down vote up
public void handleMessage(Message message) throws Fault {
    Map<String, Object> outProps = new HashMap<String, Object>();
    outProps.put("action", "UsernameToken");

    outProps.put("passwordType", "PasswordText");
    outProps.put("user", "smx");
    outProps.put("passwordCallbackClass", "org.apache.servicemix.examples.cxf.ClientPasswordCallback");
    for (Interceptor inteceptor : message.getInterceptorChain()) {
        //set properties for WSS4JOutInterceptor
        if (inteceptor.getClass().getName().equals("org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor")) {
            ((WSS4JOutInterceptor)inteceptor).setProperties(outProps);
        }
    }
}