Example #1
0
 public void clientCreated(final Client client) {
   if (null == store || null == retransmissionQueue) {
     return;
   }
   String id = RMUtils.getEndpointIdentifier(client.getEndpoint(), getBus());
   Collection<SourceSequence> sss = store.getSourceSequences(id /*, protocol*/);
   if (null == sss || 0 == sss.size()) {
     return;
   }
   LOG.log(Level.FINE, "Number of source sequences: {0}", sss.size());
   recoverReliableEndpoint(client.getEndpoint(), client.getConduit() /*, protocol*/);
 }
  public void init() {
    Bus oldbus = BusFactory.getThreadDefaultBus();
    BusFactory.setThreadDefaultBus(bus);
    try {
      GreeterService service =
          new GreeterService(GreeterTargetBean.class.getResource("/wsdl/hello_world.wsdl"));
      greeter = service.getGreeterPort();
      if (address != null) {
        ((BindingProvider) greeter)
            .getRequestContext()
            .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
      }
      client = ClientProxy.getClient(greeter);
      System.out.println("Greeter endpoint: " + client.getEndpoint().getEndpointInfo());

    } catch (RuntimeException e) {
      e.printStackTrace();
      throw e;
    } catch (Error e) {
      e.printStackTrace();
      throw e;
    } finally {
      BusFactory.setThreadDefaultBus(oldbus);
    }
  }
Example #3
0
  public static Webservices getProxy() {

    final JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
    proxyFactory.setServiceClass(Webservices.class);
    SettingsDataProvider settings = BeanProvider.getContextualReference(SettingsDataProvider.class);
    proxyFactory.setAddress(settings.getSetting("cmdbuild_url"));
    Object proxy = proxyFactory.create();

    final Map<String, Object> outProps = new HashMap<String, Object>();
    outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
    outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
    outProps.put(WSHandlerConstants.USER, settings.getSetting("cmdbuild_login"));
    outProps.put(
        WSHandlerConstants.PW_CALLBACK_REF,
        new ClientPasswordCallback(settings.getSetting("cmdbuild_pwd")));

    final Client client = ClientProxy.getClient(proxy);
    final Endpoint cxfEndpoint = client.getEndpoint();
    long timeout = 9000000000L;
    if (client != null) {
      HTTPConduit conduit = (HTTPConduit) client.getConduit();
      HTTPClientPolicy policy = new HTTPClientPolicy();
      policy.setConnectionTimeout(timeout);
      policy.setReceiveTimeout(timeout);
      conduit.setClient(policy);
    }
    cxfEndpoint.getOutInterceptors().add(new WSS4JOutInterceptorWOExpire(outProps));

    return (Webservices) proxy;
  }
Example #4
0
 @Override
 protected void configureInterceptors(Client client) {
   super.configureInterceptors(client);
   client.getInInterceptors().add(new InPayloadExtractorInterceptor());
   client.getInInterceptors().add(new InNamespaceMergeInterceptor());
   client.getInInterceptors().add(new InPayloadInjectorInterceptor(0));
   client.getEndpoint().getService().setDataBinding(new PlainXmlDataBinding());
 }
  private void setWSS4JOutInterceptor(Object service) {
    Client client = ClientProxy.getClient(service);
    Endpoint cxfEP = client.getEndpoint();

    WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);

    cxfEP.getOutInterceptors().add(wssOut);
  }
  @Override
  public void initialize(Client client, Bus bus) {
    // check if there is logging interceptor
    removeInterceptorWhichIsOutThePhases(
        client.getInInterceptors(), REMAINING_IN_PHASES, getInInterceptorNames());
    removeInterceptorWhichIsOutThePhases(
        client.getEndpoint().getInInterceptors(), REMAINING_IN_PHASES, getInInterceptorNames());
    client.getEndpoint().getBinding().getInInterceptors().clear();

    // we need to keep the LoggingOutputInterceptor
    getOutInterceptorNames().add(LoggingOutInterceptor.class.getName());
    removeInterceptorWhichIsOutThePhases(
        client.getOutInterceptors(), REMAINING_OUT_PHASES, getOutInterceptorNames());
    removeInterceptorWhichIsOutThePhases(
        client.getEndpoint().getOutInterceptors(), REMAINING_OUT_PHASES, getOutInterceptorNames());
    client.getEndpoint().getBinding().getOutInterceptors().clear();
    client.getEndpoint().getOutInterceptors().add(new RawMessageContentRedirectInterceptor());
  }
 public void clientDestroyed(Client client) {
   Destination dest =
       client
           .getEndpoint()
           .getEndpointInfo()
           .getProperty(DECOUPLED_DESTINATION, Destination.class);
   if (dest != null) {
     dest.setMessageObserver(null);
     dest.shutdown();
   }
 }
  private Client createClient() throws BusException, EndpointException {
    Client client = clientFactory.create();

    final Service service = client.getEndpoint().getService();
    service.setDataBinding(new SourceDataBinding());

    final ServiceInfo si = service.getServiceInfos().get(0);
    ServiceHelper.addOperation(si, operationName, isRequestResponse);

    return client;
  }
Example #9
0
  private <T> void configureWSSecurity(Dispatch<T> dispatch) {
    if (this.mcf.getAsSecurityType() == WSManagedConnectionFactory.SecurityType.WSSecurity) {
      Bus bus = BusFactory.getThreadDefaultBus();
      BusFactory.setThreadDefaultBus(this.mcf.getBus());
      try {
        Client client = ((DispatchImpl) dispatch).getClient();
        Endpoint ep = client.getEndpoint();

        // spring configuration file
        if (this.mcf.getOutInterceptors() != null) {
          for (Interceptor i : this.mcf.getOutInterceptors()) {
            ep.getOutInterceptors().add(i);
          }
        }

        // ws-security pass-thru from custom jaas domain
        Subject subject = ConnectionContext.getSubject();
        if (subject != null) {
          WSSecurityCredential credential =
              ConnectionContext.getSecurityCredential(subject, WSSecurityCredential.class);
          if (credential != null) {
            if (credential.useSts()) {
              dispatch
                  .getRequestContext()
                  .put(SecurityConstants.STS_CLIENT, credential.buildStsClient(bus));
            }
            if (credential.getSecurityHandler() == WSSecurityCredential.SecurityHandler.WSS4J) {
              ep.getOutInterceptors()
                  .add(new WSS4JOutInterceptor(credential.getRequestPropterties()));
              ep.getInInterceptors()
                  .add(new WSS4JInInterceptor(credential.getResponsePropterties()));
            } else if (credential.getSecurityHandler()
                == WSSecurityCredential.SecurityHandler.WSPOLICY) {
              dispatch.getRequestContext().putAll(credential.getRequestPropterties());
              dispatch.getResponseContext().putAll(credential.getResponsePropterties());
            }
          }

          // When properties are set on subject treat them as they can configure WS-Security
          HashMap<String, String> properties =
              ConnectionContext.getSecurityCredential(subject, HashMap.class);
          for (String key : properties.keySet()) {
            if (key.startsWith("ws-security.")) { // $NON-NLS-1$
              ep.put(key, properties.get(key));
            }
          }
        }
      } finally {
        BusFactory.setThreadDefaultBus(bus);
      }
    }
  }
 @Override
 public void initialize(Client client, Bus bus) {
   checkZmqConfig();
   Conduit conduit = client.getConduit();
   if (!(conduit instanceof ZMQConduit)) {
     throw new ConfigurationException(new Message("ZMQCONFIGFEATURE_ONLY_ZMQ", LOG));
   }
   Endpoint ep = client.getEndpoint();
   changeTransportUriToZmq(ep);
   ZMQConduit zmqConduit = (ZMQConduit) conduit;
   zmqConduit.setZmqConfig(zmqConfig);
   super.initialize(client, bus);
 }
Example #11
0
  @Override
  protected void configureInterceptors(Client client) {
    super.configureInterceptors(client);
    client.getInInterceptors().add(new InPayloadExtractorInterceptor(SOAP_BODY));
    client.getInInterceptors().add(new InNamespaceMergeInterceptor());
    client.getInInterceptors().add(new InPayloadInjectorInterceptor(0));
    client.getEndpoint().getService().setDataBinding(new PlainXmlDataBinding());

    // install auditing-related interceptors if the user has not switched auditing off
    if (auditStrategy != null) {
      client
          .getOutInterceptors()
          .add(
              new AuditOutRequestInterceptor<>(
                  auditStrategy, correlator, getWsTransactionConfiguration()));

      AuditResponseInterceptor<Hl7v3AuditDataset> auditInterceptor =
          new AuditResponseInterceptor<>(auditStrategy, false, correlator, false);
      client.getInInterceptors().add(auditInterceptor);
      client.getInFaultInterceptors().add(auditInterceptor);
    }
  }
 /** Construction of ConferenceServiceHandler class */
 public ConferenceServiceHandler(final String webServiceUrl) {
   if (webServiceUrl.contains("rest")) {
     final JsonInvocationHandler jsonInvocationHandler =
         JsonInvocationHandler.getInstance(webServiceUrl);
     port = (JConferenceService) jsonInvocationHandler.getProxy(JConferenceService.class);
   } else {
     final URL wsdlURL =
         ConferenceServiceHandler.class
             .getClassLoader()
             .getResource("wsdl/current/JConferenceService.wsdl");
     final JConferenceService_Service ss = new JConferenceService_Service(wsdlURL, SERVICE_NAME);
     port = ss.getJConferenceServicePort();
     final BindingProvider provider = (BindingProvider) port;
     provider
         .getRequestContext()
         .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, webServiceUrl + "/JConferenceService");
     // https support
     CommonUtils.httpsConnectionSupport(port);
     // Add custom SOAPAction header interceptor here
     final Client client = ClientProxy.getClient(port);
     final Endpoint cxfEndpoint = client.getEndpoint();
     cxfEndpoint.getOutInterceptors().add(new SoapHeaderOutInterceptor());
   }
 }
 @Override
 public void initialize(Client client, Bus bus) {
   setupEndpoint(client.getEndpoint());
 }