Search in sources :

Example 1 with EventFeature

use of org.talend.esb.sam.agent.feature.EventFeature in project tesb-rt-se by Talend.

the class RuntimeESBConsumerTest method noPropertiesSetProvidesEmptyArgumentList.

@Test
public void noPropertiesSetProvidesEmptyArgumentList() throws Exception {
    QName serviceName = new QName("http://services.talend.org/test/Library/1.0", "LibraryProvider");
    QName portName = new QName("http://services.talend.org/test/Library/1.0", "LibraryHttpPort");
    QName operationName = new QName("http://services.talend.org/test/Library/1.0", "seekBook");
    String publishedEndpointUrl = "local://LibraryHttpPort";
    String wsdlURL = "classpath:/conf/libraryService/Library.wsdl";
    boolean useServiceLocator = false;
    LocatorFeature locatorFeature = null;
    Map<String, String> locatorProps = new HashMap<String, String>();
    EventFeature samFeature = null;
    Map<String, String> samProps = new HashMap<String, String>();
    boolean useServiceRegistry = false;
    EsbSecurity esbSecurity = null;
    Policy policy = null;
    String username = "";
    String password = "";
    String alias = "";
    Map<String, String> clientProperties = new HashMap<String, String>();
    String roleName = "";
    Object securityToken = null;
    Crypto cryptoProvider = null;
    SecurityArguments securityArguments = new SecurityArguments(esbSecurity, policy, username, password, alias, clientProperties, roleName, securityToken, cryptoProvider);
    Bus bus = null;
    boolean logging = false;
    List<Header> soapHeaders = new ArrayList<Header>();
    Feature httpHeadersFeature = null;
    boolean enhancedResponse = false;
    Object correlationIDCallbackHandler = null;
    final boolean useGZipCompression = false;
    RuntimeESBConsumer consumer = new RuntimeESBConsumer(serviceName, portName, operationName, publishedEndpointUrl, wsdlURL, useServiceLocator, locatorFeature, locatorProps, samFeature, samProps, useServiceRegistry, securityArguments, bus, logging, soapHeaders, httpHeadersFeature, enhancedResponse, correlationIDCallbackHandler, useGZipCompression);
    String requestString = "<ns2:SearchFor xmlns:ns2=\"http://types.talend.org/test/Library/Common/1.0\" " + "xmlns:ns3=\"http://types.talend.org/test/GeneralObjects/ErrorHandling/1.0\">" + "<AuthorLastName>Icebear</AuthorLastName><ISBNNumber>123</ISBNNumber></ns2:SearchFor>";
    consumer.invoke(getDocumentFromString(requestString));
}
Also used : Policy(org.apache.neethi.Policy) Bus(org.apache.cxf.Bus) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) EventFeature(org.talend.esb.sam.agent.feature.EventFeature) EventFeature(org.talend.esb.sam.agent.feature.EventFeature) LocatorFeature(org.talend.esb.servicelocator.cxf.LocatorFeature) Feature(org.apache.cxf.feature.Feature) Crypto(org.apache.wss4j.common.crypto.Crypto) Header(org.apache.cxf.headers.Header) EsbSecurity(org.talend.esb.job.controller.ESBEndpointConstants.EsbSecurity) LocatorFeature(org.talend.esb.servicelocator.cxf.LocatorFeature) Test(org.junit.Test)

Example 2 with EventFeature

use of org.talend.esb.sam.agent.feature.EventFeature in project tesb-rt-se by Talend.

the class SamEnablingInterceptorProvider method process.

static void process(Message message) {
    AssertionInfoMap aim = message.get(AssertionInfoMap.class);
    if (aim != null) {
        Collection<AssertionInfo> ais = aim.get(SamEnablingPolicyBuilder.SAM_ENABLE);
        if (ais != null) {
            for (AssertionInfo ai : ais) {
                if (ai.getAssertion() instanceof SamEnablingPolicy) {
                    SamEnablingPolicy vPolicy = (SamEnablingPolicy) ai.getAssertion();
                    AppliesToType appliesToType = vPolicy.getAppliesToType();
                    // Service service = ServiceModelUtil.getService(message
                    // .getExchange());
                    Exchange ex = message.getExchange();
                    Bus b = ex.getBus();
                    if (b.getFeatures().contains(EventFeature.class)) {
                        ai.setAsserted(true);
                        return;
                    }
                    Endpoint ep = ex.getEndpoint();
                    Bundle bundle = FrameworkUtil.getBundle(SamEnablingInterceptorProvider.class);
                    EventFeature eventFeature = null;
                    if (bundle != null) {
                        // OSGi
                        BundleContext context = FrameworkUtil.getBundle(SamEnablingInterceptorProvider.class).getBundleContext();
                        ServiceReference sref = context.getServiceReference(EventFeature.class.getName());
                        eventFeature = (EventFeature) context.getService(sref);
                    } else {
                        // non-OSGi
                        if (springContext == null) {
                            throw springContextException;
                        }
                        eventFeature = (EventFeature) springContext.getBean("eventFeature");
                    }
                    if (MessageUtils.isRequestor(message)) {
                        if (MessageUtils.isOutbound(message)) {
                            // REQ_OUT
                            if ((appliesToType == AppliesToType.consumer || appliesToType == AppliesToType.always)) {
                                Client cli = ex.get(Client.class);
                                if (!cli.getOutInterceptors().contains(WireTapOut.class)) {
                                    eventFeature.initialize(cli, b);
                                    List<Interceptor<? extends Message>> outInterceptors = cli.getOutInterceptors();
                                    message.getInterceptorChain().add(outInterceptors);
                                    outInterceptors.getClass();
                                }
                            }
                        } else {
                            // RESP_IN
                            if ((appliesToType == AppliesToType.consumer || appliesToType == AppliesToType.always)) {
                                Client cli = ex.get(Client.class);
                                eventFeature.initialize(cli, b);
                            }
                        }
                    } else {
                        ServerRegistry registry = b.getExtension(ServerRegistry.class);
                        List<Server> servers = registry.getServers();
                        if (MessageUtils.isOutbound(message)) {
                            // RESP_OUT
                            if ((appliesToType == AppliesToType.provider || appliesToType == AppliesToType.always)) {
                                for (Server sr : servers) {
                                    EndpointInfo ei = sr.getEndpoint().getEndpointInfo();
                                    if (null != ei && ei.getAddress().equals(ep.getEndpointInfo().getAddress())) {
                                        eventFeature.initialize(sr, b);
                                    }
                                }
                            }
                        } else {
                            // REQ_IN
                            if ((appliesToType == AppliesToType.provider || appliesToType == AppliesToType.always)) {
                                for (Server sr : servers) {
                                    EndpointInfo ei = sr.getEndpoint().getEndpointInfo();
                                    if (null != ei && ei.getAddress().equals(ep.getEndpointInfo().getAddress()) && (!sr.getEndpoint().getInInterceptors().contains(WireTapIn.class))) {
                                        eventFeature.initialize(sr, b);
                                        List<Interceptor<? extends Message>> inInterceptors = sr.getEndpoint().getInInterceptors();
                                        message.getInterceptorChain().add(inInterceptors);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        for (AssertionInfo ai : ais) {
            ai.setAsserted(true);
        }
    }
}
Also used : Bus(org.apache.cxf.Bus) AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) Message(org.apache.cxf.message.Message) Server(org.apache.cxf.endpoint.Server) Bundle(org.osgi.framework.Bundle) ServerRegistry(org.apache.cxf.endpoint.ServerRegistry) WireTapIn(org.talend.esb.sam.agent.wiretap.WireTapIn) EventFeature(org.talend.esb.sam.agent.feature.EventFeature) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap) ServiceReference(org.osgi.framework.ServiceReference) Exchange(org.apache.cxf.message.Exchange) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) WireTapOut(org.talend.esb.sam.agent.wiretap.WireTapOut) AppliesToType(org.talend.esb.policy.samenabling.SamEnablingPolicy.AppliesToType) Client(org.apache.cxf.endpoint.Client) AbstractPhaseInterceptor(org.apache.cxf.phase.AbstractPhaseInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor) BundleContext(org.osgi.framework.BundleContext)

Aggregations

Bus (org.apache.cxf.Bus)2 EventFeature (org.talend.esb.sam.agent.feature.EventFeature)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 QName (javax.xml.namespace.QName)1 Client (org.apache.cxf.endpoint.Client)1 Endpoint (org.apache.cxf.endpoint.Endpoint)1 Server (org.apache.cxf.endpoint.Server)1 ServerRegistry (org.apache.cxf.endpoint.ServerRegistry)1 Feature (org.apache.cxf.feature.Feature)1 Header (org.apache.cxf.headers.Header)1 Interceptor (org.apache.cxf.interceptor.Interceptor)1 Exchange (org.apache.cxf.message.Exchange)1 Message (org.apache.cxf.message.Message)1 AbstractPhaseInterceptor (org.apache.cxf.phase.AbstractPhaseInterceptor)1 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)1 AssertionInfo (org.apache.cxf.ws.policy.AssertionInfo)1 AssertionInfoMap (org.apache.cxf.ws.policy.AssertionInfoMap)1 Policy (org.apache.neethi.Policy)1 Crypto (org.apache.wss4j.common.crypto.Crypto)1