org.apache.cxf.endpoint.Endpoint Java Examples

The following examples show how to use org.apache.cxf.endpoint.Endpoint. 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: KerberosTokenInterceptorProvider.java    From steady with Apache License 2.0 6 votes vote down vote up
static final TokenStore getTokenStore(Message message) {
    EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
    synchronized (info) {
        TokenStore tokenStore = 
            (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        if (tokenStore == null) {
            tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        }
        if (tokenStore == null) {
            TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance();
            String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE;
            if (info.getName() != null) {
                cacheKey += "-" + info.getName().toString().hashCode();
            }
            tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message);
            info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore);
        }
        return tokenStore;
    }
}
 
Example #2
Source File: EjbMessageContext.java    From tomee with Apache License 2.0 6 votes vote down vote up
public EndpointReference getEndpointReference(Element... referenceParameters) {
    org.apache.cxf.message.Message msg = getWrappedMessage();
    Endpoint ep = msg.getExchange().get(Endpoint.class);

    W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
    builder.address(ep.getEndpointInfo().getAddress());
    builder.serviceName(ep.getService().getName());
    builder.endpointName(ep.getEndpointInfo().getName());

    if (referenceParameters != null) {
        for (Element referenceParameter : referenceParameters) {
            builder.referenceParameter(referenceParameter);
        }
    }

    return builder.build();
}
 
Example #3
Source File: MessageContextImplTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private Message createMessage() {
    ProviderFactory factory = ServerProviderFactory.getInstance();
    Message m = new MessageImpl();
    m.put("org.apache.cxf.http.case_insensitive_queries", false);
    Exchange e = new ExchangeImpl();
    m.setExchange(e);
    e.setInMessage(m);
    Endpoint endpoint = EasyMock.mock(Endpoint.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andReturn(null).anyTimes();
    EasyMock.expect(endpoint.get(Application.class.getName())).andReturn(null);
    EasyMock.expect(endpoint.size()).andReturn(0).anyTimes();
    EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes();
    EasyMock.expect(endpoint.get(ServerProviderFactory.class.getName())).andReturn(factory).anyTimes();
    EasyMock.replay(endpoint);
    e.put(Endpoint.class, endpoint);
    return m;
}
 
Example #4
Source File: RMManager.java    From cxf with Apache License 2.0 6 votes vote down vote up
void shutdownReliableEndpoint(Endpoint e) {
    RMEndpoint rme = reliableEndpoints.get(e);
    if (rme == null) {
        // not found
        return;
    }
    rme.shutdown();

    // remove references to timer tasks cancelled above to make them
    // eligible for garbage collection
    Timer t = getTimer(false);
    if (t != null) {
        t.purge();
    }

    reliableEndpoints.remove(e);
}
 
Example #5
Source File: XSLTJaxbProviderTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private Message createMessage() {
    ProviderFactory factory = ServerProviderFactory.getInstance();
    Message m = new MessageImpl();
    m.put(Message.ENDPOINT_ADDRESS, "http://localhost:8080/bar");
    m.put("org.apache.cxf.http.case_insensitive_queries", false);
    Exchange e = new ExchangeImpl();
    m.setExchange(e);
    e.setInMessage(m);
    Endpoint endpoint = EasyMock.mock(Endpoint.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andReturn(null).anyTimes();
    EasyMock.expect(endpoint.get(Application.class.getName())).andReturn(null);
    EasyMock.expect(endpoint.size()).andReturn(0).anyTimes();
    EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes();
    EasyMock.expect(endpoint.get(ServerProviderFactory.class.getName())).andReturn(factory).anyTimes();
    EasyMock.replay(endpoint);
    e.put(Endpoint.class, endpoint);
    return m;
}
 
Example #6
Source File: LoadDistributorTargetSelector.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Called when a Conduit is actually required.
 *
 * @param message
 * @return the Conduit to use for mediation of the message
 */
public synchronized Conduit selectConduit(Message message) {
    Conduit c = message.get(Conduit.class);
    if (c != null) {
        return c;
    }
    Exchange exchange = message.getExchange();
    String key = String.valueOf(System.identityHashCode(exchange));
    InvocationContext invocation = getInvocationContext(key);
    if ((invocation != null) && !invocation.getContext().containsKey(IS_DISTRIBUTED)) {
        Endpoint target = getDistributionTarget(exchange, invocation);
        if (target != null) {
            setEndpoint(target);
            message.put(Message.ENDPOINT_ADDRESS, target.getEndpointInfo().getAddress());
            message.put(CONDUIT_COMPARE_FULL_URL, Boolean.TRUE);
            overrideAddressProperty(invocation.getContext());
            invocation.getContext().put(IS_DISTRIBUTED, null);
        }
    }
    return getSelectedConduit(message);
}
 
Example #7
Source File: ColocOutInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void verifyIsColocatedWithDifferentService() {
    //Funtion Param
    Server s1 = control.createMock(Server.class);
    List<Server> list = new ArrayList<>();
    list.add(s1);
    Endpoint sep = control.createMock(Endpoint.class);
    //Local var
    Service ses = control.createMock(Service.class);

    Endpoint rep = control.createMock(Endpoint.class);
    Service res = control.createMock(Service.class);

    EasyMock.expect(sep.getService()).andReturn(ses);
    EasyMock.expect(s1.getEndpoint()).andReturn(rep);
    EasyMock.expect(rep.getService()).andReturn(res);
    EasyMock.expect(ses.getName()).andReturn(new QName("A", "C"));
    EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));

    control.replay();
    Server val = colocOut.isColocated(list, sep, null);
    assertEquals("Is not a colocated call",
                 null,
                 val);
    control.reset();
}
 
Example #8
Source File: JAXBElementProviderTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private Message createMessage() {
    ServerProviderFactory factory = ServerProviderFactory.getInstance();
    Message m = new MessageImpl();
    m.put(Message.ENDPOINT_ADDRESS, "http://localhost:8080/bar");
    m.put("org.apache.cxf.http.case_insensitive_queries", false);
    Exchange e = new ExchangeImpl();
    m.setExchange(e);
    e.setInMessage(m);
    Endpoint endpoint = EasyMock.mock(Endpoint.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andReturn(null).anyTimes();
    EasyMock.expect(endpoint.get(Application.class.getName())).andReturn(null);
    EasyMock.expect(endpoint.size()).andReturn(0).anyTimes();
    EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes();
    EasyMock.expect(endpoint.get(ServerProviderFactory.class.getName())).andReturn(factory).anyTimes();
    EasyMock.replay(endpoint);
    e.put(Endpoint.class, endpoint);
    return m;
}
 
Example #9
Source File: MAPAggregatorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void setUpRebase(Message message, Exchange exchange, Endpoint endpoint)
    throws Exception {
    setUpMessageProperty(message,
                         "org.apache.cxf.ws.addressing.partial.response.sent",
                         Boolean.FALSE);
    Binding binding = control.createMock(Binding.class);
    endpoint.getBinding();
    EasyMock.expectLastCall().andReturn(binding).anyTimes();
    Message partialResponse = getMessage();
    binding.createMessage(EasyMock.isA(Message.class));
    EasyMock.expectLastCall().andReturn(partialResponse);

    Destination target = control.createMock(Destination.class);
    setUpMessageDestination(message, target);
    Conduit backChannel = control.createMock(Conduit.class);
    target.getBackChannel(EasyMock.eq(message));
    EasyMock.expectLastCall().andReturn(backChannel);
    // REVISIT test interceptor chain setup & send
}
 
Example #10
Source File: PolicyBasedWSS4JInInterceptor.java    From steady with Apache License 2.0 6 votes vote down vote up
private Crypto getSignatureCrypto(Object s, SoapMessage message) throws WSSecurityException {
    Crypto signCrypto = null;
    if (s instanceof Crypto) {
        signCrypto = (Crypto)s;
    } else if (s != null) {
        URL propsURL = getPropertiesFileURL(s, message);
        String propsKey = s.toString();
        if (propsURL != null) {
            propsKey = propsURL.getPath();
        }
        Properties props = getProps(s, propsKey, propsURL, message);
        signCrypto = CryptoFactory.getInstance(props);
        
        EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
        synchronized (info) {
            info.setProperty(SecurityConstants.SIGNATURE_CRYPTO, signCrypto);
        }
    }
    return signCrypto;
}
 
Example #11
Source File: ExchangeImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
public <T> T get(Class<T> key) {
    T t = key.cast(get(key.getName()));

    if (t == null) {
        if (key == Bus.class) {
            t = key.cast(bus);
        } else if (key == OperationInfo.class && bindingOp != null) {
            t = key.cast(bindingOp.getOperationInfo());
        } else if (key == BindingOperationInfo.class) {
            t = key.cast(bindingOp);
        } else if (key == Endpoint.class) {
            t = key.cast(endpoint);
        } else if (key == Service.class) {
            t = key.cast(service);
        } else if (key == Binding.class) {
            t = key.cast(binding);
        } else if (key == BindingInfo.class && binding != null) {
            t = key.cast(binding.getBindingInfo());
        } else if (key == InterfaceInfo.class && endpoint != null) {
            t = key.cast(endpoint.getEndpointInfo().getService().getInterface());
        } else if (key == ServiceInfo.class && endpoint != null) {
            t = key.cast(endpoint.getEndpointInfo().getService());
        }
    }
    return t;
}
 
Example #12
Source File: PolicyBasedWSS4JInInterceptor.java    From steady with Apache License 2.0 6 votes vote down vote up
private Crypto getEncryptionCrypto(Object e, SoapMessage message) throws WSSecurityException {
    Crypto encrCrypto = null;
    if (e instanceof Crypto) {
        encrCrypto = (Crypto)e;
    } else if (e != null) {
        URL propsURL = getPropertiesFileURL(e, message);
        String propsKey = e.toString();
        if (propsURL != null) {
            propsKey = propsURL.getPath();
        }
        Properties props = getProps(e, propsKey, propsURL, message);
        encrCrypto = CryptoFactory.getInstance(props);
        
        EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
        synchronized (info) {
            info.setProperty(SecurityConstants.ENCRYPT_CRYPTO, encrCrypto);
        }
    }
    return encrCrypto;
}
 
Example #13
Source File: KerberosTokenInterceptorProvider.java    From steady with Apache License 2.0 6 votes vote down vote up
static final TokenStore getTokenStore(Message message) {
    EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
    synchronized (info) {
        TokenStore tokenStore = 
            (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        if (tokenStore == null) {
            tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        }
        if (tokenStore == null) {
            TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance();
            String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE;
            if (info.getName() != null) {
                cacheKey += "-" + info.getName().toString().hashCode();
            }
            tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message);
            info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore);
        }
        return tokenStore;
    }
}
 
Example #14
Source File: NegotiationUtils.java    From steady with Apache License 2.0 6 votes vote down vote up
static TokenStore getTokenStore(Message message) {
    EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
    synchronized (info) {
        TokenStore tokenStore = 
            (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        if (tokenStore == null) {
            tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        }
        if (tokenStore == null) {
            TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance();
            String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE;
            if (info.getName() != null) {
                cacheKey += "-" + info.getName().toString().hashCode();
            }
            tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message);
            info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore);
        }
        return tokenStore;
    }
}
 
Example #15
Source File: IssuedTokenInterceptorProvider.java    From steady with Apache License 2.0 6 votes vote down vote up
static final TokenStore createTokenStore(Message message) {
    EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
    synchronized (info) {
        TokenStore tokenStore = 
            (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        if (tokenStore == null) {
            tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        }
        if (tokenStore == null) {
            TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance();
            String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE;
            if (info.getName() != null) {
                cacheKey += "-" + info.getName().toString().hashCode();
            }
            tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message);
            info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore);
        }
        return tokenStore;
    }
}
 
Example #16
Source File: FailoverTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void enableWSAForCurrentEndpoint() {
    Endpoint provider = ClientProxy.getClient(greeter).getEndpoint();
    mapAggregator = new MAPAggregator();
    mapCodec = MAPCodec.getInstance(ClientProxy.getClient(greeter).getBus());
    provider.getInInterceptors().add(mapAggregator);
    provider.getInInterceptors().add(mapCodec);

    provider.getOutInterceptors().add(mapAggregator);
    provider.getOutInterceptors().add(mapCodec);

    provider.getInFaultInterceptors().add(mapAggregator);
    provider.getInFaultInterceptors().add(mapCodec);

    provider.getOutFaultInterceptors().add(mapAggregator);
    provider.getOutFaultInterceptors().add(mapCodec);
}
 
Example #17
Source File: NegotiationUtils.java    From steady with Apache License 2.0 6 votes vote down vote up
static TokenStore getTokenStore(Message message) {
    EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
    synchronized (info) {
        TokenStore tokenStore = 
            (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        if (tokenStore == null) {
            tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        }
        if (tokenStore == null) {
            TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance();
            String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE;
            if (info.getName() != null) {
                cacheKey += "-" + info.getName().toString().hashCode();
            }
            tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message);
            info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore);
        }
        return tokenStore;
    }
}
 
Example #18
Source File: STSInvoker.java    From steady with Apache License 2.0 6 votes vote down vote up
private void doCancel(
    Exchange exchange, 
    SecurityToken cancelToken, 
    W3CDOMStreamWriter writer,
    String prefix, 
    String namespace
) throws Exception {
    if (STSUtils.WST_NS_05_12.equals(namespace)) {
        writer.writeStartElement(prefix, "RequestSecurityTokenResponseCollection", namespace);
    }
    writer.writeStartElement(prefix, "RequestSecurityTokenResponse", namespace);
    
    TokenStore store = (TokenStore)exchange.get(Endpoint.class).getEndpointInfo()
            .getProperty(TokenStore.class.getName());
    store.remove(cancelToken.getId());
    writer.writeEmptyElement(prefix, "RequestedTokenCancelled", namespace);
    
    writer.writeEndElement();
    if (STSUtils.WST_NS_05_12.equals(namespace)) {
        writer.writeEndElement();
    }
}
 
Example #19
Source File: AbstractBindingBuilder.java    From steady with Apache License 2.0 6 votes vote down vote up
protected final TokenStore getTokenStore() {
    EndpointInfo info = message.getExchange().get(Endpoint.class).getEndpointInfo();
    synchronized (info) {
        TokenStore tokenStore = 
            (TokenStore)message.getContextualProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        if (tokenStore == null) {
            tokenStore = (TokenStore)info.getProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE);
        }
        if (tokenStore == null) {
            TokenStoreFactory tokenStoreFactory = TokenStoreFactory.newInstance();
            String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE;
            if (info.getName() != null) {
                cacheKey += "-" + info.getName().toString().hashCode();
            }
            tokenStore = tokenStoreFactory.newTokenStore(cacheKey, message);
            info.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore);
        }
        return tokenStore;
    }
}
 
Example #20
Source File: ProtobufMessageInInterceptor.java    From fuchsia with Apache License 2.0 6 votes vote down vote up
/**
 */
public void handleMessage(Message message) throws Fault {
    Endpoint endpoint = message.getExchange().get(Endpoint.class);
    @SuppressWarnings(value = "unchecked")
    Class<? extends com.google.protobuf.Message> messageClass = (Class) message.getExchange().get(IN_MESSAGE_CLASS);

    if (messageClass == null) {
        messageClass = (Class) endpoint
                .get(IN_MESSAGE_CLASS);
    }

    InputStream in = message.getContent(InputStream.class);

    try {
        com.google.protobuf.Message m = (com.google.protobuf.Message) messageClass.getMethod("parseFrom",
                InputStream.class).invoke(null, in);
        message.setContent(com.google.protobuf.Message.class, m);
    } catch (Exception e) {
        log.error("Failed to invoke message method from protobuffer.",e);
        throw new RuntimeException(e);
    }
}
 
Example #21
Source File: StaxDataBindingInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void handleMessage(Message message) {
    if (isGET(message) && message.getContent(List.class) != null) {
        LOG.fine("StaxDataBindingInterceptor skipped in HTTP GET method");
        return;
    }

    DepthXMLStreamReader xmlReader = getXMLStreamReader(message);
    DataReader<XMLStreamReader> dr = getDataReader(message);
    MessageContentsList parameters = new MessageContentsList();

    Exchange exchange = message.getExchange();
    BindingOperationInfo bop = exchange.getBindingOperationInfo();

    //if body is empty and we have BindingOperationInfo, we do not need to match
    //operation anymore, just return
    if (!StaxUtils.toNextElement(xmlReader) && bop != null) {
        // body may be empty for partial response to decoupled request
        return;
    }

    if (bop == null) {
        Endpoint ep = exchange.getEndpoint();
        bop = ep.getBinding().getBindingInfo().getOperations().iterator().next();
    }

    message.getExchange().put(BindingOperationInfo.class, bop);

    if (isRequestor(message)) {
        parameters.put(bop.getOutput().getMessageParts().get(0), dr.read(xmlReader));
    } else {
        parameters.put(bop.getInput().getMessageParts().get(0), dr.read(xmlReader));
    }


    if (!parameters.isEmpty()) {
        message.setContent(List.class, parameters);
    }
}
 
Example #22
Source File: WadlGeneratorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Message mockMessage(String baseAddress, String pathInfo, String query,
                            List<ClassResourceInfo> cris) throws Exception {
    Message m = new MessageImpl();
    Exchange e = new ExchangeImpl();
    e.put(Service.class, new JAXRSServiceImpl(cris));
    m.setExchange(e);
    control.reset();
    ServletDestination d = control.createMock(ServletDestination.class);
    EndpointInfo epr = new EndpointInfo();
    epr.setAddress(baseAddress);
    d.getEndpointInfo();
    EasyMock.expectLastCall().andReturn(epr).anyTimes();

    Endpoint endpoint = new EndpointImpl(null, null, epr);
    e.put(Endpoint.class, endpoint);
    endpoint.put(ServerProviderFactory.class.getName(), ServerProviderFactory.getInstance());
    e.setDestination(d);
    BindingInfo bi = control.createMock(BindingInfo.class);
    epr.setBinding(bi);
    bi.getProperties();
    EasyMock.expectLastCall().andReturn(Collections.emptyMap()).anyTimes();
    m.put(Message.REQUEST_URI, pathInfo);
    m.put(Message.QUERY_STRING, query);
    m.put(Message.HTTP_REQUEST_METHOD, "GET");
    control.replay();
    return m;
}
 
Example #23
Source File: AbstractJAXRSFactoryBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Endpoint createEndpoint() throws BusException, EndpointException {
    Service service = serviceFactory.getService();

    if (service == null) {
        service = serviceFactory.create();
    }

    EndpointInfo ei = createEndpointInfo(service);
    Endpoint ep = new EndpointImpl(getBus(), service, ei);

    if (properties != null) {
        ep.putAll(properties);
    }

    if (getInInterceptors() != null) {
        ep.getInInterceptors().addAll(getInInterceptors());
    }
    if (getOutInterceptors() != null) {
        ep.getOutInterceptors().addAll(getOutInterceptors());
    }
    if (getInFaultInterceptors() != null) {
        ep.getInFaultInterceptors().addAll(getInFaultInterceptors());
    }
    if (getOutFaultInterceptors() != null) {
        ep.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
    }

    List<ClassResourceInfo> list = serviceFactory.getRealClassResourceInfo();
    for (ClassResourceInfo cri : list) {
        initializeAnnotationInterceptors(ep, cri.getServiceClass());
        serviceFactory.sendEvent(FactoryBeanListener.Event.ENDPOINT_SELECTED, ei, ep,
                                 cri.getServiceClass(), null);
    }
    ep.put(JAXRSServiceFactoryBean.class.getName(), serviceFactory);
    return ep;
}
 
Example #24
Source File: WSS4JUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
/**
 * Get a ReplayCache instance. It first checks to see whether caching has been explicitly 
 * enabled or disabled via the booleanKey argument. If it has been set to false then no
 * replay caching is done (for this booleanKey). If it has not been specified, then caching
 * is enabled only if we are not the initiator of the exchange. If it has been specified, then
 * caching is enabled.
 * 
 * It tries to get an instance of ReplayCache via the instanceKey argument from a 
 * contextual property, and failing that the message exchange. If it can't find any, then it
 * defaults to using an EH-Cache instance and stores that on the message exchange.
 */
public static ReplayCache getReplayCache(
    SoapMessage message, String booleanKey, String instanceKey
) {
    boolean specified = false;
    Object o = message.getContextualProperty(booleanKey);
    if (o != null) {
        if (!MessageUtils.isTrue(o)) {
            return null;
        }
        specified = true;
    }

    if (!specified && MessageUtils.isRequestor(message)) {
        return null;
    }
    Endpoint ep = message.getExchange().get(Endpoint.class);
    if (ep != null && ep.getEndpointInfo() != null) {
        EndpointInfo info = ep.getEndpointInfo();
        synchronized (info) {
            ReplayCache replayCache = 
                    (ReplayCache)message.getContextualProperty(instanceKey);
            if (replayCache == null) {
                replayCache = (ReplayCache)info.getProperty(instanceKey);
            }
            if (replayCache == null) {
                ReplayCacheFactory replayCacheFactory = ReplayCacheFactory.newInstance();
                String cacheKey = instanceKey;
                if (info.getName() != null) {
                    cacheKey += "-" + info.getName().toString().hashCode();
                }
                replayCache = replayCacheFactory.newReplayCache(cacheKey, message);
                info.setProperty(instanceKey, replayCache);
            }
            return replayCache;
        }
    }
    return null;
}
 
Example #25
Source File: RMEndpoint.java    From cxf with Apache License 2.0 5 votes vote down vote up
void createEndpoint(org.apache.cxf.transport.Destination d, ProtocolVariation protocol) {
    final QName bindingQName = new QName(protocol.getWSRMNamespace(), BINDING_NAME);
    WrappedService service = services.get(protocol);
    ServiceInfo si = service.getServiceInfo();
    buildBindingInfo(si, protocol);
    EndpointInfo aei = applicationEndpoint.getEndpointInfo();
    String transportId = aei.getTransportId();
    EndpointInfo ei = new EndpointInfo(si, transportId);
    if (d != null) {
        ei.setProperty(MAPAggregator.DECOUPLED_DESTINATION, d);
    }

    ei.setAddress(aei.getAddress());

    ei.setName(RMUtils.getConstants(protocol.getWSRMNamespace()).getPortName());
    ei.setBinding(si.getBinding(bindingQName));

    // if addressing was enabled on the application endpoint by means
    // of the UsingAddressing element extensor, use this for the
    // RM endpoint also

    Object ua = getUsingAddressing(aei);
    if (null != ua) {
        ei.addExtensor(ua);
    }
    si.addEndpoint(ei);
    ei.setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore);

    Endpoint endpoint = new WrappedEndpoint(applicationEndpoint, ei, service);
    if (applicationEndpoint.getEndpointInfo() != null
        && applicationEndpoint.getEndpointInfo().getProperties() != null) {
        for (String key : applicationEndpoint.getEndpointInfo().getProperties().keySet()) {
            endpoint.getEndpointInfo()
                .setProperty(key, applicationEndpoint.getEndpointInfo().getProperty(key));
        }
    }
    service.setEndpoint(endpoint);
    endpoints.put(protocol, endpoint);
}
 
Example #26
Source File: RMUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static ObjectName getManagedObjectName(RMEndpoint endpoint) throws JMException {
    StringBuilder buffer = new StringBuilder();
    writeTypeProperty(buffer, endpoint.getManager().getBus(), "WSRM.Endpoint");
    Endpoint ep = endpoint.getApplicationEndpoint();
    writeEndpointProperty(buffer, ep);
    return new ObjectName(buffer.toString());
}
 
Example #27
Source File: STSInvoker.java    From steady with Apache License 2.0 5 votes vote down vote up
private SecurityToken findCancelToken(Exchange exchange, Element el) throws WSSecurityException {
    SecurityTokenReference ref = new SecurityTokenReference(DOMUtils.getFirstElement(el));
    String uri = ref.getReference().getURI();
    TokenStore store = (TokenStore)exchange.get(Endpoint.class).getEndpointInfo()
            .getProperty(TokenStore.class.getName());
    return store.getToken(uri);
}
 
Example #28
Source File: JAXRSInInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Message createOutMessage(Message inMessage, Response r) {
    Endpoint e = inMessage.getExchange().getEndpoint();
    Message mout = e.getBinding().createMessage();
    mout.setContent(List.class, new MessageContentsList(r));
    mout.setExchange(inMessage.getExchange());
    mout.setInterceptorChain(
         OutgoingChainInterceptor.getOutInterceptorChain(inMessage.getExchange()));
    inMessage.getExchange().setOutMessage(mout);
    if (r.getStatus() >= Response.Status.BAD_REQUEST.getStatusCode()) {
        inMessage.getExchange().put("cxf.io.cacheinput", Boolean.FALSE);
    }
    return mout;
}
 
Example #29
Source File: WoodstoxValidationImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void setupValidation(XMLStreamReader reader,
                            Endpoint endpoint,
                            ServiceInfo serviceInfo) throws XMLStreamException {
    if (utils != null && reader != null && !utils.setupValidation(reader, endpoint, serviceInfo)) {
        utils = null;
    }
}
 
Example #30
Source File: STSUtils.java    From steady with Apache License 2.0 5 votes vote down vote up
public static Endpoint createSTSEndpoint(Bus bus, 
                                         String namespace,
                                         String transportId,
                                         String location,
                                         String soapVersion,
                                         Policy policy,
                                         QName epName) throws BusException, EndpointException {
    return createSTSEndpoint(bus, namespace, transportId, location, soapVersion, policy, epName, false);
}