org.apache.http.auth.InvalidCredentialsException#com.sun.jersey.api.client.config.ClientConfig源码实例Demo

下面列出了org.apache.http.auth.InvalidCredentialsException#com.sun.jersey.api.client.config.ClientConfig 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hop   文件: HopServerTest.java
@Test
public void callStopHopServerRestService() throws Exception {
  WebResource status = mock( WebResource.class );
  doReturn( "<serverstatus>" ).when( status ).get( String.class );

  WebResource stop = mock( WebResource.class );
  doReturn( "Shutting Down" ).when( stop ).get( String.class );

  Client client = mock( Client.class );
  doCallRealMethod().when( client ).addFilter( any( HTTPBasicAuthFilter.class ) );
  doCallRealMethod().when( client ).getHeadHandler();
  doReturn( status ).when( client ).resource( "http://localhost:8080/hop/status/?xml=Y" );
  doReturn( stop ).when( client ).resource( "http://localhost:8080/hop/stopHopServer" );

  mockStatic( Client.class );
  when( Client.create( any( ClientConfig.class ) ) ).thenReturn( client );

  HopServer.callStopHopServerRestService( "localhost", "8080", "admin", "Encrypted 2be98afc86aa7f2e4bb18bd63c99dbdde" );

  // the expected value is: "Basic <base64 encoded username:password>"
  assertEquals( "Basic " + new String( Base64.getEncoder().encode( "admin:password".getBytes( "utf-8" ) ) ),
    getInternalState( client.getHeadHandler(), "authentication" ) );
}
 
源代码2 项目: Eagle   文件: EagleServiceBaseClient.java
public EagleServiceBaseClient(String host, int port, String basePath, String username, String password) {
    this.host = host;
    this.port = port;
    this.basePath = basePath;
    this.baseEndpoint = buildBathPath().toString();
    this.username = username;
    this.password = password;

    ClientConfig cc = new DefaultClientConfig();
    cc.getProperties().put(DefaultClientConfig.PROPERTY_CONNECT_TIMEOUT, 60 * 1000);
    cc.getProperties().put(DefaultClientConfig.PROPERTY_READ_TIMEOUT, 60 * 1000);
    cc.getClasses().add(JacksonJsonProvider.class);
    cc.getProperties().put(URLConnectionClientHandler.PROPERTY_HTTP_URL_CONNECTION_SET_METHOD_WORKAROUND, true);
    this.client = Client.create(cc);
    client.addFilter(new com.sun.jersey.api.client.filter.GZIPContentEncodingFilter());
    //        Runtime.getRuntime().addShutdownHook(new EagleServiceClientShutdownHook(this));
}
 
源代码3 项目: occurrence   文件: ApiClientConfiguration.java
/**
 * @return a new jersey client using a multithreaded http client
 */
public WebResource newApiClient() {
  ClientConfig cc = new DefaultClientConfig();
  cc.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true);
  cc.getProperties().put(ClientConfig.PROPERTY_READ_TIMEOUT, timeout);
  cc.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, timeout);
  cc.getClasses().add(JacksonJsonProvider.class);
  // use custom configured object mapper ignoring unknown properties
  cc.getClasses().add(ObjectMapperContextResolver.class);

  HttpClient http = HttpUtil.newMultithreadedClient(timeout, maxConnections, maxConnections);
  ApacheHttpClient4Handler hch = new ApacheHttpClient4Handler(http, null, false);
  Client client = new ApacheHttpClient4(hch, cc);

  LOG.info("Connecting to GBIF API: {}", url);
  return client.resource(url);
}
 
源代码4 项目: eagle   文件: EagleServiceBaseClient.java
public EagleServiceBaseClient(String host, int port, String basePath, String username, String password) {
    this.host = host;
    this.port = port;
    this.basePath = basePath;
    this.baseEndpoint = buildBathPath().toString();
    this.username = username;
    this.password = password;

    ClientConfig cc = new DefaultClientConfig();
    cc.getProperties().put(DefaultClientConfig.PROPERTY_CONNECT_TIMEOUT, 60 * 1000);
    cc.getProperties().put(DefaultClientConfig.PROPERTY_READ_TIMEOUT, 60 * 1000);
    cc.getClasses().add(JacksonJsonProvider.class);
    cc.getProperties().put(URLConnectionClientHandler.PROPERTY_HTTP_URL_CONNECTION_SET_METHOD_WORKAROUND, true);
    this.client = Client.create(cc);
    client.addFilter(new com.sun.jersey.api.client.filter.GZIPContentEncodingFilter());
}
 
源代码5 项目: osiris   文件: RestRequestSender.java
public void uploadVoid(String url, File f, String formName, Headers... headers) {

		FormDataMultiPart form = new FormDataMultiPart().field(formName, f, MediaType.MULTIPART_FORM_DATA_TYPE);
		String urlCreated = createURI(url);
		ClientConfig cc = new DefaultClientConfig();
		cc.getClasses().add(MultiPartWriter.class);
		WebResource webResource = Client.create(cc).resource(urlCreated);

		Builder builder = webResource.type(MULTIPART_MEDIA).accept(MEDIA);

		for (Headers h : headers) {
			builder.header(h.getKey(), h.getValue());
		}

		builder.post(form);
	}
 
源代码6 项目: osiris   文件: RestRequestSender.java
public <T> ClientResponse<T> upload(String url, File f, Class<T> expectedResponse, Headers... headers) {
	
	@SuppressWarnings("resource")
	FormDataMultiPart form = new FormDataMultiPart();
	form.bodyPart(new FileDataBodyPart("file", f, MediaType.APPLICATION_OCTET_STREAM_TYPE));

	String urlCreated = createURI(url);
	ClientConfig cc = new DefaultClientConfig();
	cc.getClasses().add(MultiPartWriter.class);
	WebResource webResource = Client.create(cc).resource(urlCreated);
	Builder builder = webResource.type(MULTIPART_MEDIA).accept(MEDIA).accept("text/plain");
	for (Headers h : headers) {
		builder.header(h.getKey(), h.getValue());
	}

	com.sun.jersey.api.client.ClientResponse clienteResponse = null;

	clienteResponse = builder.post(com.sun.jersey.api.client.ClientResponse.class, form);

	return new ClientResponse<T>(clienteResponse, expectedResponse);
}
 
源代码7 项目: osiris   文件: RestRequestSender.java
public ClientResponse<File> uploadNoMultipart(String url, File f, Headers... headers) throws FileNotFoundException {

		InputStream is = new FileInputStream(f);

		String urlCreated = createURI(url);
		ClientConfig cc = new DefaultClientConfig();
		cc.getClasses().add(MultiPartWriter.class);
		WebResource webResource = Client.create(cc).resource(urlCreated);
		Builder builder = webResource.type(MediaType.APPLICATION_OCTET_STREAM).accept(MEDIA).accept("text/plain");

		String sContentDisposition = "attachment; filename=\"" + f.getName() + "\"";
		builder.header("Content-Disposition", sContentDisposition);

		for (Headers h : headers) {
			builder.header(h.getKey(), h.getValue());
		}

		com.sun.jersey.api.client.ClientResponse clienteResponse = null;

		clienteResponse = builder.post(com.sun.jersey.api.client.ClientResponse.class, is);

		return new ClientResponse<File>(clienteResponse, File.class);
	}
 
源代码8 项目: pentaho-kettle   文件: RepositoryCleanupUtil.java
/**
 * Use REST API to authenticate provided credentials
 * 
 * @throws Exception
 */
@VisibleForTesting
void authenticateLoginCredentials() throws Exception {
  KettleClientEnvironment.init();

  if ( client == null ) {
    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getFeatures().put( JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE );
    client = Client.create( clientConfig );
    client.addFilter( new HTTPBasicAuthFilter( username, Encr.decryptPasswordOptionallyEncrypted( password ) ) );
  }

  WebResource resource = client.resource( url + AUTHENTICATION + AdministerSecurityAction.NAME );
  String response = resource.get( String.class );

  if ( !response.equals( "true" ) ) {
    throw new Exception( Messages.getInstance().getString( "REPOSITORY_CLEANUP_UTIL.ERROR_0012.ACCESS_DENIED" ) );
  }
}
 
源代码9 项目: curator   文件: TestStringsWithJersey.java
@Test
public void     testEmptyServiceNames()
{
    ClientConfig    config = new DefaultClientConfig()
    {
        @Override
        public Set<Object> getSingletons()
        {
            Set<Object>     singletons = Sets.newHashSet();
            singletons.add(context);
            singletons.add(serviceNamesMarshaller);
            singletons.add(serviceInstanceMarshaller);
            singletons.add(serviceInstancesMarshaller);
            return singletons;
        }
    };
    Client          client = Client.create(config);
    WebResource     resource = client.resource("http://localhost:" + port);
    ServiceNames names = resource.path("/v1/service").get(ServiceNames.class);
    Assert.assertEquals(names.getNames(), Lists.<String>newArrayList());
}
 
源代码10 项目: roboconf-platform   文件: WsClient.java
/**
 * Constructor.
 * @param rootUrl the root URL (example: http://192.168.1.18:9007/dm/)
 */
public WsClient( String rootUrl ) {

	ClientConfig cc = new DefaultClientConfig();
	cc.getClasses().add( JacksonJsonProvider.class );
	cc.getClasses().add( ObjectMapperProvider.class );

	this.client = Client.create( cc );
	this.client.setFollowRedirects( true );

	WebResource resource = this.client.resource( rootUrl );
	this.applicationDelegate = new ApplicationWsDelegate( resource, this );
	this.managementDelegate = new ManagementWsDelegate( resource, this );
	this.debugDelegate = new DebugWsDelegate( resource, this );
	this.targetWsDelegate = new TargetWsDelegate( resource, this );
	this.schedulerDelegate = new SchedulerWsDelegate( resource, this );
	this.preferencesWsDelegate = new PreferencesWsDelegate( resource, this );
	this.authenticationWsDelegate = new AuthenticationWsDelegate( resource, this );
}
 
源代码11 项目: pentaho-kettle   文件: RepositoryCleanupUtilTest.java
@Test
public void authenticateLoginCredentials() throws Exception {
  RepositoryCleanupUtil util = mock( RepositoryCleanupUtil.class );
  doCallRealMethod().when( util ).authenticateLoginCredentials();

  setInternalState( util, "url", "http://localhost:8080/pentaho" );
  setInternalState( util, "username", "admin" );
  setInternalState( util, "password", "Encrypted 2be98afc86aa7f2e4bb18bd63c99dbdde" );

  WebResource resource = mock( WebResource.class );
  doReturn( "true" ).when( resource ).get( String.class );

  Client client = mock( Client.class );
  doCallRealMethod().when( client ).addFilter( any( HTTPBasicAuthFilter.class ) );
  doCallRealMethod().when( client ).getHeadHandler();
  doReturn( resource ).when( client ).resource( anyString() );

  mockStatic( Client.class );
  when( Client.create( any( ClientConfig.class ) ) ).thenReturn( client );
  util.authenticateLoginCredentials();

  // the expected value is: "Basic <base64 encoded username:password>"
  assertEquals( "Basic " + new String( Base64.getEncoder().encode( "admin:password".getBytes( "utf-8" ) ) ),
    getInternalState( client.getHeadHandler(), "authentication" ) );
}
 
源代码12 项目: maven-framework-project   文件: UserInfoClient.java
public static void main(String[] args) {

		String name = "Pavithra";
		int age = 25;

		ClientConfig config = new DefaultClientConfig();
		Client client = Client.create(config);
		WebResource resource = client.resource(BASE_URI);

		WebResource nameResource = resource.path("rest").path(PATH_NAME + name);
		System.out.println("Client Response \n"
				+ getClientResponse(nameResource));
		System.out.println("Response \n" + getResponse(nameResource) + "\n\n");

		WebResource ageResource = resource.path("rest").path(PATH_AGE + age);
		System.out.println("Client Response \n"
				+ getClientResponse(ageResource));
		System.out.println("Response \n" + getResponse(ageResource));
	}
 
源代码13 项目: nextreports-server   文件: WebServiceClient.java
private void initSSL(ClientConfig config) throws Exception {
	
	log("* Init SSL connection ...");		
	sslContext = SSLContext.getInstance("SSL");
	tm = createTrustManager();
	sslContext.init(null, new TrustManager[] {tm}, null);
	config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
			new HTTPSProperties(createHostnameVerifier(), sslContext));		
	
	SSLSocketFactory factory = sslContext.getSocketFactory();

	URL url = new URL(server);
	String host = url.getHost();
	int port = url.getPort();
	log("  -> Opening connection to " + host + ":" + port + "...");
	SSLSocket socket = (SSLSocket) factory.createSocket(host, port);
	socket.setSoTimeout(10000);

	log("  -> Starting SSL handshake...");
	socket.startHandshake();
	socket.close();		
	log("  -> No errors, certificate is already trusted");		
}
 
源代码14 项目: cloudbreak   文件: YarnHttpClient.java
@Override
public void validateApiEndpoint() throws CloudbreakOrchestratorFailedException, MalformedURLException {
    YarnEndpoint dashEndpoint = new YarnEndpoint(
            apiEndpoint,
            YarnResourceConstants.APPLICATIONS_PATH
            );

    ClientConfig clientConfig = new DefaultClientConfig();
    Client client = Client.create(clientConfig);

    WebResource webResource = client.resource(dashEndpoint.getFullEndpointUrl().toString());
    ClientResponse response = webResource.accept("application/json").type("application/json").get(ClientResponse.class);

    // Validate HTTP 200 status code
    if (response.getStatus() != YarnResourceConstants.HTTP_SUCCESS) {
        String msg = String.format("Received %d status code from url %s, reason: %s",
                response.getStatus(),
                dashEndpoint.getFullEndpointUrl().toString(),
                response.getEntity(String.class));
        LOGGER.debug(msg);
        throw new CloudbreakOrchestratorFailedException(msg);
    }
}
 
源代码15 项目: pentaho-reporting   文件: JCRSolutionFileModel.java
public JCRSolutionFileModel( final String url,
                             final String username,
                             final String password,
                             final int timeout ) {
  if ( url == null ) {
    throw new NullPointerException();
  }
  this.url = url;
  descriptionEntries = new HashMap<FileName, String>();

  final ClientConfig config = new DefaultClientConfig();
  config.getProperties().put( ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true );
  config.getProperties().put( ClientConfig.PROPERTY_READ_TIMEOUT, timeout );
  this.client = Client.create( config );
  this.client.addFilter( new CookiesHandlerFilter() ); // must be inserted before HTTPBasicAuthFilter
  this.client.addFilter( new HTTPBasicAuthFilter( username, password ) );
  this.majorVersion = "999";
  this.minorVersion = "999";
  this.releaseVersion = "999";
  this.buildVersion = "999";
  this.milestoneVersion = "999";
  this.loadTreePartially = Boolean.parseBoolean( PARTIAL_LOADING_ENABLED );
}
 
源代码16 项目: tr069-simulator   文件: CPEClientSession.java
public static void main(String[] args) {
	ClientConfig 	config 			= new DefaultClientConfig();
	Client 			client 			= Client.create(config);
	WebResource 	service 		= client.resource(getBaseURI());
	JSONObject 		data 			= new JSONObject();
	JSONObject 		status 			= new JSONObject();		
	String			filefolder  	= "//dump//microcell//";
	CpeDBReader 	confdb 			= new CpeDBReader().readFromGetMessages(filefolder);
	CpeActions 		cpeAction 		= new CpeActions(confdb);	
	
	ArrayList<EventStruct> eventKeyList = new ArrayList<EventStruct>();
	EventStruct eventStruct = new EventStruct();
	eventStruct.setEventCode("1 BOOT");
	eventKeyList.add(eventStruct);
	CpeActions cpeactions = new CpeActions(confdb);
	Envelope evn = cpeactions.doInform(eventKeyList);
	
}
 
源代码17 项目: pentaho-kettle   文件: CarteTest.java
@Test
public void callStopCarteRestService() throws Exception {
  WebResource status = mock( WebResource.class );
  doReturn( "<serverstatus>" ).when( status ).get( String.class );

  WebResource stop = mock( WebResource.class );
  doReturn( "Shutting Down" ).when( stop ).get( String.class );

  Client client = mock( Client.class );
  doCallRealMethod().when( client ).addFilter( any( HTTPBasicAuthFilter.class ) );
  doCallRealMethod().when( client ).getHeadHandler();
  doReturn( status ).when( client ).resource( "http://localhost:8080/kettle/status/?xml=Y" );
  doReturn( stop ).when( client ).resource( "http://localhost:8080/kettle/stopCarte" );

  mockStatic( Client.class );
  when( Client.create( any( ClientConfig.class ) ) ).thenReturn( client );

  Carte.callStopCarteRestService( "localhost", "8080", "admin", "Encrypted 2be98afc86aa7f2e4bb18bd63c99dbdde" );

  // the expected value is: "Basic <base64 encoded username:password>"
  assertEquals( "Basic " + new String( Base64.getEncoder().encode( "admin:password".getBytes( "utf-8" ) ) ),
    getInternalState( client.getHeadHandler(), "authentication" ) );
}
 
源代码18 项目: Bats   文件: WebServicesClient.java
public WebServicesClient()
{
  this(new DefaultClientConfig());
  client.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true);
  client.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, DEFAULT_CONNECT_TIMEOUT);
  client.getProperties().put(ClientConfig.PROPERTY_READ_TIMEOUT, DEFAULT_READ_TIMEOUT);
}
 
源代码19 项目: Bats   文件: WebServicesClient.java
public WebServicesClient(ClientConfig config)
{
  if (SecurityUtils.isHadoopWebSecurityEnabled()) {
    HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
    httpClientBuilder.setConnectionManager(connectionManager);
    httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
    httpClientBuilder.setDefaultAuthSchemeRegistry(authRegistry);
    ApacheHttpClient4Handler httpClientHandler = new ApacheHttpClient4Handler(httpClientBuilder.build(), new BasicCookieStore(), false);
    client = new Client(httpClientHandler, config);
  } else {
    client = Client.create(config);
  }
}
 
源代码20 项目: hop   文件: HopServer.java
/**
 * Checks that HopServer is running and if so, shuts down the HopServer server
 *
 * @param hostname
 * @param port
 * @param username
 * @param password
 * @throws ParseException
 * @throws HopServerCommandException
 */
@VisibleForTesting
static void callStopHopServerRestService( String hostname, String port, String username, String password )
  throws ParseException, HopServerCommandException {
  // get information about the remote connection
  try {
    HopClientEnvironment.init();

    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getFeatures().put( JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE );
    Client client = Client.create( clientConfig );

    client.addFilter( new HTTPBasicAuthFilter( username, Encr.decryptPasswordOptionallyEncrypted( password ) ) );

    // check if the user can access the hop server. Don't really need this call but may want to check it's output at
    // some point
    String contextURL = "http://" + hostname + ":" + port + "/hop";
    WebResource resource = client.resource( contextURL + "/status/?xml=Y" );
    String response = resource.get( String.class );
    if ( response == null || !response.contains( "<serverstatus>" ) ) {
      throw new HopServerCommandException( BaseMessages.getString( PKG, "HopServer.Error.NoServerFound", hostname, ""
        + port ) );
    }

    // This is the call that matters
    resource = client.resource( contextURL + "/stopHopServer" );
    response = resource.get( String.class );
    if ( response == null || !response.contains( "Shutting Down" ) ) {
      throw new HopServerCommandException( BaseMessages.getString( PKG, "HopServer.Error.NoShutdown", hostname, ""
        + port ) );
    }
  } catch ( Exception e ) {
    throw new HopServerCommandException( BaseMessages.getString( PKG, "HopServer.Error.NoServerFound", hostname, ""
      + port ), e );
  }
}
 
源代码21 项目: localization_nifi   文件: WebUtils.java
/**
 * A helper method for creating clients. The client will be created using
 * the given configuration and security context. Additionally, the client
 * will be automatically configured for JSON serialization/deserialization.
 *
 * @param config client configuration
 * @param ctx security context, which may be null for non-secure client
 * creation
 *
 * @return a Client instance
 */
private static Client createClientHelper(final ClientConfig config, final SSLContext ctx) {

    final ClientConfig finalConfig = (config == null) ? new DefaultClientConfig() : config;

    if (ctx != null && StringUtils.isBlank((String) finalConfig.getProperty(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES))) {

        // custom hostname verifier that checks subject alternative names against the hostname of the URI
        final HostnameVerifier hostnameVerifier = new HostnameVerifier() {
            @Override
            public boolean verify(final String hostname, final SSLSession ssls) {

                try {
                    for (final Certificate peerCertificate : ssls.getPeerCertificates()) {
                        if (peerCertificate instanceof X509Certificate) {
                            final X509Certificate x509Cert = (X509Certificate) peerCertificate;
                            final List<String> subjectAltNames = CertificateUtils.getSubjectAlternativeNames(x509Cert);
                            if (subjectAltNames.contains(hostname.toLowerCase())) {
                                return true;
                            }
                        }
                    }
                } catch (final SSLPeerUnverifiedException | CertificateParsingException ex) {
                    logger.warn("Hostname Verification encountered exception verifying hostname due to: " + ex, ex);
                }

                return false;
            }
        };

        finalConfig.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(hostnameVerifier, ctx));
    }

    finalConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    finalConfig.getClasses().add(ObjectMapperResolver.class);

    // web client for restful request
    return Client.create(finalConfig);

}
 
源代码22 项目: localization_nifi   文件: YandexTranslate.java
@OnScheduled
public void onScheduled(final ProcessContext context) {
    final ClientConfig config = new DefaultClientConfig();
    config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    config.getClasses().add(ObjectMapperResolver.class);

    client = Client.create(config);
}
 
public void createClient(String ctxPath) throws Exception {
  testProperties = new TestProperties();

  APP_BASE_PATH = testProperties.getApplicationPath("/" + ctxPath);
  LOGGER.info("Connecting to application "+APP_BASE_PATH);

  ClientConfig clientConfig = new DefaultApacheHttpClient4Config();
  clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
  client = ApacheHttpClient4.create(clientConfig);

  defaultHttpClient = (DefaultHttpClient) client.getClientHandler().getHttpClient();
  HttpParams params = defaultHttpClient.getParams();
  HttpConnectionParams.setConnectionTimeout(params, 3 * 60 * 1000);
  HttpConnectionParams.setSoTimeout(params, 10 * 60 * 1000);
}
 
源代码24 项目: phoebus   文件: ChannelFinderClientImpl.java
ChannelFinderClientImpl(URI uri, ClientConfig config, HTTPBasicAuthFilter httpBasicAuthFilter,
            ExecutorService executor) {
        Client client = Client.create(config);
        if (httpBasicAuthFilter != null) {
            client.addFilter(httpBasicAuthFilter);
        }
//        client.addFilter(new RawLoggingFilter(Logger.getLogger(RawLoggingFilter.class.getName())));
        client.setFollowRedirects(true);
        service = client.resource(uri.toString());
        this.executor = executor;
    }
 
源代码25 项目: phoebus   文件: OlogClient.java
private OlogClient(URI ologURI, ClientConfig config, boolean withHTTPBasicAuthFilter, String username, String password) {
    config.getClasses().add(MultiPartWriter.class);
    Client client = Client.create(config);
    if (withHTTPBasicAuthFilter) {
        client.addFilter(new HTTPBasicAuthFilter(username, password));
    }
    if (Logger.getLogger(OlogClient.class.getName()).isLoggable(Level.ALL)) {
        client.addFilter(new RawLoggingFilter(Logger.getLogger(OlogClient.class.getName())));
    }
    client.setFollowRedirects(true);
    client.setConnectTimeout(3000);
    this.service = client.resource(UriBuilder.fromUri(ologURI).build());
}
 
源代码26 项目: camunda-bpm-platform   文件: AbstractWebIT.java
public void createClient(String ctxPath) throws Exception {
  testProperties = new TestProperties();

  APP_BASE_PATH = testProperties.getApplicationPath("/" + ctxPath);
  LOGGER.info("Connecting to application "+APP_BASE_PATH);

  ClientConfig clientConfig = new DefaultApacheHttpClient4Config();
  clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
  client = ApacheHttpClient4.create(clientConfig);

  defaultHttpClient = (DefaultHttpClient) client.getClientHandler().getHttpClient();
  HttpParams params = defaultHttpClient.getParams();
  HttpConnectionParams.setConnectionTimeout(params, 3 * 60 * 1000);
  HttpConnectionParams.setSoTimeout(params, 10 * 60 * 1000);
}
 
源代码27 项目: conductor   文件: MetadataClient.java
/**
 * @param config              REST Client configuration
 * @param clientConfiguration Specific properties configured for the client, see {@link ConductorClientConfiguration}
 * @param handler             Jersey client handler. Useful when plugging in various http client interaction modules (e.g. ribbon)
 * @param filters             Chain of client side filters to be applied per request
 */
public MetadataClient(ClientConfig config, ConductorClientConfiguration clientConfiguration, ClientHandler handler, ClientFilter... filters) {
    super(config, clientConfiguration, handler);
    for (ClientFilter filter : filters) {
        super.client.addFilter(filter);
    }
}
 
源代码28 项目: conductor   文件: ClientBase.java
protected ClientBase(ClientConfig config, ConductorClientConfiguration clientConfiguration, ClientHandler handler) {
    objectMapper = new JsonMapperProvider().get();

    JacksonJsonProvider provider = new JacksonJsonProvider(objectMapper);
    config.getSingletons().add(provider);

    if (handler == null) {
        this.client = Client.create(config);
    } else {
        this.client = new Client(handler, config);
    }

    conductorClientConfiguration = clientConfiguration;
    payloadStorage = new PayloadStorage(this);
}
 
源代码29 项目: conductor   文件: TaskClient.java
/**
 * @param config              REST Client configuration
 * @param clientConfiguration Specific properties configured for the client, see {@link ConductorClientConfiguration}
 * @param handler             Jersey client handler. Useful when plugging in various http client interaction modules (e.g. ribbon)
 * @param filters             Chain of client side filters to be applied per request
 */
public TaskClient(ClientConfig config, ConductorClientConfiguration clientConfiguration, ClientHandler handler, ClientFilter... filters) {
    super(config, clientConfiguration, handler);
    for (ClientFilter filter : filters) {
        super.client.addFilter(filter);
    }
}
 
源代码30 项目: conductor   文件: WorkflowClient.java
/**
 * @param config              REST Client configuration
 * @param clientConfiguration Specific properties configured for the client, see {@link ConductorClientConfiguration}
 * @param handler             Jersey client handler. Useful when plugging in various http client interaction modules (e.g. ribbon)
 * @param filters             Chain of client side filters to be applied per request
 */
public WorkflowClient(ClientConfig config, ConductorClientConfiguration clientConfiguration, ClientHandler handler, ClientFilter... filters) {
    super(config, clientConfiguration, handler);
    for (ClientFilter filter : filters) {
        super.client.addFilter(filter);
    }
}