org.apache.cxf.service.model.EndpointInfo Java Examples

The following examples show how to use org.apache.cxf.service.model.EndpointInfo. 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: 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 #2
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 #3
Source File: WSDLGetUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
public Map<String, String> getSchemaLocations(Message message,
                                              String base,
                                              String ctxUri,
                                              EndpointInfo endpointInfo) {
    Map<String, String> params = new HashMap<>();
    params.put("wsdl", "");
    getDocument(message, base,
                params, ctxUri,
                endpointInfo);

    Map<String, SchemaReference> mp = CastUtils.cast((Map<?, ?>)endpointInfo.getService()
                                                     .getProperty(SCHEMAS_KEY));

    Map<String, String> schemas = new HashMap<>();
    for (Map.Entry<String, SchemaReference> ent : mp.entrySet()) {
        params.clear();
        params.put("xsd", ent.getKey());
        Document doc = getDocument(message, base, params, ctxUri, endpointInfo);
        schemas.put(doc.getDocumentElement().getAttribute("targetNamespace"),
                    buildUrl(base, ctxUri, "xsd=" + ent.getKey()));
    }
    return schemas;
}
 
Example #4
Source File: PolicyAttachmentTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testAppliesToEndpoint() {
    EndpointInfo ei1 = control.createMock(EndpointInfo.class);
    EndpointInfo ei2 = control.createMock(EndpointInfo.class);
    DomainExpression de = control.createMock(DomainExpression.class);
    Collection<DomainExpression> des = Collections.singletonList(de);
    PolicyAttachment pa = new PolicyAttachment();
    pa.setDomainExpressions(des);

    EasyMock.expect(de.appliesTo(ei1)).andReturn(false);
    EasyMock.expect(de.appliesTo(ei2)).andReturn(true);
    control.replay();
    assertFalse(pa.appliesTo(ei1));
    assertTrue(pa.appliesTo(ei2));
    control.verify();
}
 
Example #5
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 #6
Source File: PolicyEngineTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetEffectiveServerRequestPolicyInfo() throws Exception {
    Method m = PolicyEngineImpl.class.getDeclaredMethod("createOutPolicyInfo", new Class[] {});
    engine = EasyMock.createMockBuilder(PolicyEngineImpl.class)
        .addMockedMethod(m).createMock(control);
    engine.init();
    EndpointInfo ei = createMockEndpointInfo();
    BindingOperationInfo boi = createMockBindingOperationInfo();
    EffectivePolicyImpl epi = control.createMock(EffectivePolicyImpl.class);
    EasyMock.expect(engine.createOutPolicyInfo()).andReturn(epi);
    epi.initialise(ei, boi, engine, false, true, msg);
    EasyMock.expectLastCall();
    control.replay();
    assertSame(epi, engine.getEffectiveServerRequestPolicy(ei, boi, msg));
    assertSame(epi, engine.getEffectiveServerRequestPolicy(ei, boi, msg));
    control.verify();
}
 
Example #7
Source File: AtmosphereWebSocketUndertowDestination.java    From cxf with Apache License 2.0 6 votes vote down vote up
public AtmosphereWebSocketUndertowDestination(Bus bus, DestinationRegistry registry, EndpointInfo ei,
                                              UndertowHTTPServerEngineFactory serverEngineFactory)
                                                  throws IOException {
    super(bus, registry, ei, serverEngineFactory);
    framework = new AtmosphereFramework(false, true);
    framework.setUseNativeImplementation(false);
    framework.addInitParameter(ApplicationConfig.PROPERTY_NATIVE_COMETSUPPORT, "true");
    framework.addInitParameter(ApplicationConfig.PROPERTY_SESSION_SUPPORT, "true");
    framework.addInitParameter(ApplicationConfig.WEBSOCKET_SUPPORT, "true");
    framework.addInitParameter(ApplicationConfig.WEBSOCKET_PROTOCOL_EXECUTION, "true");
    // workaround for atmosphere's jsr356 initialization requiring servletConfig
    framework.addInitParameter(ApplicationConfig.WEBSOCKET_SUPPRESS_JSR356, "true");
    AtmosphereUtils.addInterceptors(framework, bus);
    framework.addAtmosphereHandler("/", new DestinationHandler());
    framework.init();
    executor = bus.getExtension(WorkQueueManager.class).getAutomaticWorkQueue();
}
 
Example #8
Source File: RMEndpointTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetUsingAddressing() {
    EndpointInfo ei = null;
    control.replay();
    assertNull(rme.getUsingAddressing(ei));
    control.verify();

    control.reset();
    ExtensibilityElement ua = control.createMock(ExtensibilityElement.class);
    ei = control.createMock(EndpointInfo.class);
    List<ExtensibilityElement> noExts = new ArrayList<>();
    List<ExtensibilityElement> exts = new ArrayList<>();
    exts.add(ua);
    EasyMock.expect(ei.getExtensors(ExtensibilityElement.class)).andReturn(noExts);
    BindingInfo bi = control.createMock(BindingInfo.class);
    EasyMock.expect(ei.getBinding()).andReturn(bi).times(2);
    EasyMock.expect(bi.getExtensors(ExtensibilityElement.class)).andReturn(noExts);
    ServiceInfo si = control.createMock(ServiceInfo.class);
    EasyMock.expect(ei.getService()).andReturn(si).times(2);
    EasyMock.expect(si.getExtensors(ExtensibilityElement.class)).andReturn(exts);
    EasyMock.expect(ua.getElementType()).andReturn(Names.WSAW_USING_ADDRESSING_QNAME);
    control.replay();
    assertSame(ua, rme.getUsingAddressing(ei));
}
 
Example #9
Source File: JavaToWSDLProcessor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void customize(ServiceInfo service) {
    if (context.containsKey(ToolConstants.CFG_TNS)) {
        String ns = (String)context.get(ToolConstants.CFG_TNS);
        service.setTargetNamespace(ns);
    }

    if (context.containsKey(ToolConstants.CFG_PORT)) {
        String portName = (String)context.get(ToolConstants.CFG_PORT);
        EndpointInfo einfo = service.getEndpoints().iterator().next();
        QName qn = new QName(einfo.getName().getNamespaceURI(), portName);
        einfo.setName(qn);
    }

    if (context.containsKey(ToolConstants.CFG_SERVICENAME)) {
        String svName = getServiceName();
        service.setName(new QName(service.getName().getNamespaceURI(), svName));
    }
    EndpointInfo endpointInfo = service.getEndpoints().iterator().next();
    String address = ToolConstants.DEFAULT_ADDRESS + "/" + endpointInfo.getName().getLocalPart();
    if (context.get(ToolConstants.CFG_ADDRESS) != null) {
        address = (String)context.get(ToolConstants.CFG_ADDRESS);
    }
    endpointInfo.setAddress(address);
    context.put(ToolConstants.CFG_ADDRESS, address);

}
 
Example #10
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 #11
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 #12
Source File: ColocOutInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected Server isColocated(List<Server> servers, Endpoint endpoint, BindingOperationInfo boi) {
    if (servers != null) {
        Service senderService = endpoint.getService();
        EndpointInfo senderEI = endpoint.getEndpointInfo();
        for (Server s : servers) {
            Endpoint receiverEndpoint = s.getEndpoint();
            Service receiverService = receiverEndpoint.getService();
            EndpointInfo receiverEI = receiverEndpoint.getEndpointInfo();
            if (receiverService.getName().equals(senderService.getName())
                && receiverEI.getName().equals(senderEI.getName())) {
                //Check For Operation Match.
                BindingOperationInfo receiverOI = receiverEI.getBinding().getOperation(boi.getName());
                if (receiverOI != null
                    && isCompatibleOperationInfo(boi, receiverOI)) {
                    return s;
                }
            }
        }
    }

    return null;
}
 
Example #13
Source File: ClientImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Create a Client that uses a specific EndpointImpl.
 * @param bus
 * @param svc
 * @param port
 * @param endpointImplFactory
 */
public ClientImpl(Bus bus, Service svc, QName port,
                  EndpointImplFactory endpointImplFactory) {
    this.bus = bus;
    outFaultObserver = new ClientOutFaultObserver(bus);
    EndpointInfo epfo = findEndpoint(svc, port);

    try {
        if (endpointImplFactory != null) {
            getConduitSelector().setEndpoint(endpointImplFactory.newEndpointImpl(bus, svc, epfo));
        } else {
            getConduitSelector().setEndpoint(new EndpointImpl(bus, svc, epfo));
        }
    } catch (EndpointException epex) {
        throw new IllegalStateException("Unable to create endpoint: " + epex.getMessage(), epex);
    }
    notifyLifecycleManager();
}
 
Example #14
Source File: PolicyEngineTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetEffectiveServerResponsePolicy() throws Exception {
    Method m = PolicyEngineImpl.class.getDeclaredMethod("createOutPolicyInfo", new Class[] {});
    engine = EasyMock.createMockBuilder(PolicyEngineImpl.class)
        .addMockedMethod(m).createMock(control);
    engine.init();
    EndpointInfo ei = createMockEndpointInfo();
    BindingOperationInfo boi = createMockBindingOperationInfo();
    AssertingDestination destination = control.createMock(AssertingDestination.class);
    EffectivePolicyImpl epi = control.createMock(EffectivePolicyImpl.class);
    EasyMock.expect(engine.createOutPolicyInfo()).andReturn(epi);
    epi.initialise(ei, boi, engine, destination, false, false, null);
    EasyMock.expectLastCall();
    control.replay();
    assertSame(epi, engine.getEffectiveServerResponsePolicy(ei, boi, destination, null, msg));
    assertSame(epi, engine.getEffectiveServerResponsePolicy(ei, boi, destination, null, msg));
    control.verify();
}
 
Example #15
Source File: NettyHttpTransportFactory.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
public Conduit getConduit(EndpointInfo endpointInfo, EndpointReferenceType target, Bus bus)
    throws IOException {

    HTTPConduit conduit = null;
    // need to updated the endpointInfo
    endpointInfo.setAddress(getAddress(endpointInfo));

    conduit = factory.createConduit(bus, endpointInfo, target);

    // Spring configure the conduit.
    String address = conduit.getAddress();
    if (address != null && address.indexOf('?') != -1) {
        address = address.substring(0, address.indexOf('?'));
    }
    HTTPConduitConfigurer c1 = bus.getExtension(HTTPConduitConfigurer.class);
    if (c1 != null) {
        c1.configure(conduit.getBeanName(), address, conduit);
    }
    configure(bus, conduit, conduit.getBeanName(), address);
    conduit.finalizeConfig();
    return conduit;
}
 
Example #16
Source File: WebSocketTransportFactory.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Destination getDestination(EndpointInfo endpointInfo, Bus bus) throws IOException {
    if (endpointInfo == null) {
        throw new IllegalArgumentException("EndpointInfo cannot be null");
    }
    synchronized (registry) {
        AbstractHTTPDestination d = registry.getDestinationForPath(endpointInfo.getAddress());
        if (d == null) {
            d = factory.createDestination(endpointInfo, bus, registry);
            if (d == null) {
                String error = "No destination available. The CXF websocket transport needs either the "
                    + "Jetty WebSocket or Atmosphere dependencies to be available";
                throw new IOException(error);
            }
            registry.addDestination(d);
            configure(bus, d);
            d.finalizeConfig();
        }
        return d;
    }
}
 
Example #17
Source File: HolderTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testClient() throws Exception {
    EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
    ei.setAddress(ADDRESS);

    Destination d = localTransport.getDestination(ei, bus);
    d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/holder/echoResponse.xml"));

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.getClientFactoryBean().setServiceClass(HolderService.class);
    factory.getClientFactoryBean().setBus(getBus());
    factory.getClientFactoryBean().setAddress(ADDRESS);

    HolderService h = (HolderService)factory.create();
    Holder<String> holder = new Holder<>();
    assertEquals("one", h.echo("one", "two", holder));
    assertEquals("two", holder.value);
}
 
Example #18
Source File: MEXUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static List<Element> getWSDLs(Server server) {
    Message message = PhaseInterceptorChain.getCurrentMessage();
    message.put(WSDLGetUtils.AUTO_REWRITE_ADDRESS_ALL, true);
    String base = (String)message.get(Message.REQUEST_URL);
    String ctxUri = (String)message.get(Message.PATH_INFO);

    WSDLGetUtils utils = new WSDLGetUtils();
    EndpointInfo info = server.getEndpoint().getEndpointInfo();
    List<Element> ret = new LinkedList<>();
    for (String id : utils.getWSDLIds(message, base, ctxUri, info)) {
        Map<String, String> params = new HashMap<>();
        params.put("wsdl", id);
        ret.add(utils.getDocument(message, base,
                                  params, ctxUri,
                                  info).getDocumentElement());

    }
    return ret;
}
 
Example #19
Source File: PolicyEngineTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testEndpointPolicyWithEqualPolicies() throws Exception {
    engine = new PolicyEngineImpl();
    EndpointInfo ei = createMockEndpointInfo();
    ServiceInfo si = control.createMock(ServiceInfo.class);
    ei.setService(si);
    si.getExtensor(Policy.class);
    EasyMock.expectLastCall().andReturn(null).times(2);
    EndpointPolicyImpl epi = control.createMock(EndpointPolicyImpl.class);
    control.replay();
    engine.setServerEndpointPolicy(ei, epi);
    engine.setClientEndpointPolicy(ei, epi);

    assertSame(epi, engine.getClientEndpointPolicy(ei, (Conduit)null, msg));
    assertSame(epi, engine.getServerEndpointPolicy(ei, (Destination)null, msg));

    control.reset();
    ei.setService(si);
    Policy p = new Policy();
    si.getExtensor(Policy.class);
    EasyMock.expectLastCall().andReturn(p).times(2);
    epi.getPolicy();
    EasyMock.expectLastCall().andReturn(p).times(2);
    control.replay();
    assertSame(epi, engine.getServerEndpointPolicy(ei, (Destination)null, msg));
}
 
Example #20
Source File: ProtobufQueryHandler.java    From fuchsia with Apache License 2.0 6 votes vote down vote up
/**
 * @see org.apache.cxf.transports.http.QueryHandler#writeResponse(String,.
 * String, org.apache.cxf.service.model.EndpointInfo,
 * java.io.OutputStream)
 */
@SuppressWarnings("unchecked")
public void writeResponse(String fullQueryString, String ctx,
                          EndpointInfo endpoint, OutputStream os) {
    try {
        Class<? extends Message> messageClass = endpoint.getProperty(
                ProtobufServerFactoryBean.PROTOBUF_MESSAGE_CLASS,
                Class.class);
        PrintStream out = new PrintStream(os);
        Descriptor wrapperMessage = ((Descriptor) messageClass.getMethod(
                "getDescriptor").invoke(null));
        new ProtoGenerator().generateProtoFromDescriptor(wrapperMessage
                .getFile(), out, wrapperMessage);
        out.flush();
    } catch (Exception x) {
        throw new RuntimeException(x);
    }
}
 
Example #21
Source File: EndpointPolicyImplTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testInitializePolicy() {
    EndpointInfo ei = control.createMock(EndpointInfo.class);
    PolicyEngineImpl engine = control.createMock(PolicyEngineImpl.class);
    ServiceInfo si = control.createMock(ServiceInfo.class);
    EasyMock.expect(ei.getService()).andReturn(si);
    Policy sp = control.createMock(Policy.class);
    EasyMock.expect(engine.getAggregatedServicePolicy(si, null)).andReturn(sp);
    Policy ep = control.createMock(Policy.class);
    EasyMock.expect(engine.getAggregatedEndpointPolicy(ei, null)).andReturn(ep);
    Policy merged = control.createMock(Policy.class);
    EasyMock.expect(sp.merge(ep)).andReturn(merged);
    EasyMock.expect(merged.normalize(null, true)).andReturn(merged);

    control.replay();
    EndpointPolicyImpl epi = new EndpointPolicyImpl(ei, engine, true, null);
    epi.initializePolicy(null);
    assertSame(merged, epi.getPolicy());
    control.verify();
}
 
Example #22
Source File: PolicyEngineImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
public EffectivePolicy getEffectiveServerRequestPolicy(EndpointInfo ei,
                                                       BindingOperationInfo boi,
                                                       Message m) {
    EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_REQUEST_SERVER);
    if (effectivePolicy == null) {
        synchronized (ei) {
            effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_REQUEST_SERVER);
            if (null == effectivePolicy) {
                EffectivePolicyImpl epi = createOutPolicyInfo();
                epi.initialise(ei, boi, this, false, true, m);
                if (m != null) {
                    boi.setProperty(POLICY_INFO_REQUEST_SERVER, epi);
                }
                effectivePolicy = epi;
            }
        }
    }
    return effectivePolicy;
}
 
Example #23
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 #24
Source File: RMEndpoint.java    From cxf with Apache License 2.0 6 votes vote down vote up
Object getUsingAddressing(EndpointInfo endpointInfo) {
    if (null == endpointInfo) {
        return null;
    }
    Object ua = null;
    List<ExtensibilityElement> exts = endpointInfo.getExtensors(ExtensibilityElement.class);
    ua = getUsingAddressing(exts);
    if (null != ua) {
        return ua;
    }
    exts = endpointInfo.getBinding() != null ? endpointInfo.getBinding()
        .getExtensors(ExtensibilityElement.class) : null;
    ua = getUsingAddressing(exts);
    if (null != ua) {
        return ua;
    }
    exts = endpointInfo.getService() != null ? endpointInfo.getService()
        .getExtensors(ExtensibilityElement.class) : null;
    ua = getUsingAddressing(exts);
    if (null != ua) {
        return ua;
    }
    return ua;
}
 
Example #25
Source File: WSPolicyFeature.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(Server server, Bus bus) {
    Endpoint endpoint = server.getEndpoint();
    Policy p = initializeEndpointPolicy(endpoint, bus);
    PolicyEngine pe = bus.getExtension(PolicyEngine.class);
    EndpointInfo ei = endpoint.getEndpointInfo();
    EndpointPolicy ep = pe.getServerEndpointPolicy(ei, null, null);
    pe.setServerEndpointPolicy(ei, ep.updatePolicy(p, createMessage(endpoint, bus)));

    // Add policy to the service model (and consequently to the WSDL)
    // FIXME - ideally this should probably be moved up to where the policies are applied to the
    // endpoint, rather than this late.  As a consequence of its location, you have to declare a
    // ws policy feature on every endpoint in order to get any policy attachments into the
    // wsdl.  Alternatively add to the WSDLServiceBuilder somehow.
    ServiceModelPolicyUpdater pu = new ServiceModelPolicyUpdater(ei);
    for (PolicyProvider pp : ((PolicyEngineImpl) pe).getPolicyProviders()) {
        if (pp instanceof ExternalAttachmentProvider) {
            pu.addPolicyAttachments(((ExternalAttachmentProvider) pp).getAttachments());
        }
    }
}
 
Example #26
Source File: UniqueBodyValidator.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean checkUniqueBody() {
    Collection<EndpointInfo> endpoints = service.getEndpoints();
    if (endpoints != null) {
        for (EndpointInfo endpoint : endpoints) {
            if (!isValidEndpoint(endpoint)) {
                return false;
            }
        }
    }
    return true;
}
 
Example #27
Source File: UndertowHTTPDestinationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
EasyMockUndertowHTTPDestination(Bus bus,
                                    DestinationRegistry registry,
                                    EndpointInfo endpointInfo,
                                    UndertowHTTPServerEngineFactory serverEngineFactory,
                                    UndertowHTTPServerEngine easyMockEngine) throws IOException {
    super(bus, registry, endpointInfo, serverEngineFactory);
    engine = easyMockEngine;
}
 
Example #28
Source File: AbstractWSDLBasedEndpointFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void modifyTransportIdPerAddress(EndpointInfo ei) {
    //get chance to set transportId according to the the publish address prefix
    //this is useful for local & camel transport
    if (transportId == null && getAddress() != null) {
        DestinationFactory df = getDestinationFactory();
        if (df == null) {
            DestinationFactoryManager dfm = getBus().getExtension(
                    DestinationFactoryManager.class);
            df = dfm.getDestinationFactoryForUri(getAddress());
        }

        if (df != null) {
            transportId = df.getTransportIds().get(0);
        } else {
            // check conduits (the address could be supported on
            // client only)
            ConduitInitiatorManager cim = getBus().getExtension(
                    ConduitInitiatorManager.class);
            ConduitInitiator ci = cim
                    .getConduitInitiatorForUri(getAddress());
            if (ci != null) {
                transportId = ci.getTransportIds().get(0);
            }
        }
    }
    if (transportId != null) {
        ei.setTransportId(transportId);
    }
}
 
Example #29
Source File: RequestResponseTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testRequestTopicResponseStaticQueue() throws Exception {
    EndpointInfo ei = setupServiceInfo("http://cxf.apache.org/jms_simple", "/wsdl/jms_spec_testsuite.wsdl",
                     "JMSSimpleService002X", "SimplePortTopicRequestQueueResponse");
    sendAndReceiveMessages(ei, true);
    sendAndReceiveMessages(ei, false);
}
 
Example #30
Source File: ApplicationContextTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private EndpointInfo getEndpointInfo(String serviceNS,
                                     String endpointLocal,
                                     String address) {
    ServiceInfo serviceInfo2 = new ServiceInfo();
    serviceInfo2.setName(new QName(serviceNS, "Service"));
    EndpointInfo info2 = new EndpointInfo(serviceInfo2, "");
    info2.setName(new QName("urn:test:ns", endpointLocal));
    info2.setAddress(address);
    return info2;
}