com.sun.jersey.api.client.config.ClientConfig Java Examples
The following examples show how to use
com.sun.jersey.api.client.config.ClientConfig.
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: EagleServiceBaseClient.java From Eagle with Apache License 2.0 | 6 votes |
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)); }
Example #2
Source File: YarnHttpClient.java From cloudbreak with Apache License 2.0 | 6 votes |
@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); } }
Example #3
Source File: JCRSolutionFileModel.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
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 ); }
Example #4
Source File: HopServerTest.java From hop with Apache License 2.0 | 6 votes |
@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" ) ); }
Example #5
Source File: CPEClientSession.java From tr069-simulator with MIT License | 6 votes |
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); }
Example #6
Source File: CarteTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@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" ) ); }
Example #7
Source File: WebServiceClient.java From nextreports-server with Apache License 2.0 | 6 votes |
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"); }
Example #8
Source File: UserInfoClient.java From maven-framework-project with MIT License | 6 votes |
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)); }
Example #9
Source File: WsClient.java From roboconf-platform with Apache License 2.0 | 6 votes |
/** * 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 ); }
Example #10
Source File: RepositoryCleanupUtil.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * 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" ) ); } }
Example #11
Source File: RestRequestSender.java From osiris with Apache License 2.0 | 6 votes |
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); }
Example #12
Source File: TestStringsWithJersey.java From curator with Apache License 2.0 | 6 votes |
@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()); }
Example #13
Source File: RestRequestSender.java From osiris with Apache License 2.0 | 6 votes |
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); }
Example #14
Source File: RestRequestSender.java From osiris with Apache License 2.0 | 6 votes |
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); }
Example #15
Source File: EagleServiceBaseClient.java From eagle with Apache License 2.0 | 6 votes |
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()); }
Example #16
Source File: ApiClientConfiguration.java From occurrence with Apache License 2.0 | 6 votes |
/** * @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); }
Example #17
Source File: RepositoryCleanupUtilTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@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" ) ); }
Example #18
Source File: CoordinatorClient.java From eagle with Apache License 2.0 | 5 votes |
public CoordinatorClient(String host, int port, String context) { this.host = host; this.port = port; this.context = context; this.basePath = buildBasePath(); 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()); }
Example #19
Source File: YarnHttpClient.java From cloudbreak with Apache License 2.0 | 5 votes |
@Override public void deleteApplication(DeleteApplicationRequest deleteApplicationRequest) throws YarnClientException, MalformedURLException { // Add the application name to the URL YarnEndpoint dashEndpoint = new YarnEndpoint(apiEndpoint, YarnResourceConstants.APPLICATIONS_PATH + '/' + deleteApplicationRequest.getName()); ClientConfig clientConfig = new DefaultClientConfig(); Client client = Client.create(clientConfig); // Delete the application WebResource webResource = client.resource(dashEndpoint.getFullEndpointUrl().toString()); ClientResponse response = webResource.accept("application/json").type("application/json").delete(ClientResponse.class); // Validate HTTP 204 return String msg; switch (response.getStatus()) { case YarnResourceConstants.HTTP_NO_CONTENT: msg = String.format("Successfully deleted application %s", deleteApplicationRequest.getName()); LOGGER.debug(msg); break; case YarnResourceConstants.HTTP_NOT_FOUND: msg = String.format("Application %s not found, already deleted?", deleteApplicationRequest.getName()); LOGGER.debug(msg); break; default: 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 YarnClientException(msg); } }
Example #20
Source File: RestSource.java From ingestion with Apache License 2.0 | 5 votes |
private Client initClient(Context context) { final Boolean skipSsl = context.getBoolean(CONF_SKIP_SSL, Boolean.FALSE); if (skipSsl) { ClientConfig config = new DefaultClientConfig(); // SSL configuration // SSL configuration config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new com.sun.jersey.client.urlconnection.HTTPSProperties(getHostnameVerifier(), getSSLContext())); return Client.create(config); } else { return new Client(); } }
Example #21
Source File: RegistryClientUtil.java From occurrence with Apache License 2.0 | 5 votes |
/** * Creates an HTTP client. */ private static ApacheHttpClient createHttpClient() { ClientConfig cc = new DefaultClientConfig(); cc.getClasses().add(JacksonJsonContextResolver.class); cc.getClasses().add(JacksonJsonProvider.class); cc.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); cc.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, REGISTRY_CLIENT_TO); cc.getProperties().put(ClientConfig.PROPERTY_READ_TIMEOUT, REGISTRY_CLIENT_TO); JacksonJsonContextResolver.addMixIns(Mixins.getPredefinedMixins()); return ApacheHttpClient.create(cc); }
Example #22
Source File: ApiBetaTest.java From attic-aurora with Apache License 2.0 | 5 votes |
@Test public void testPostInvalidJson() throws Exception { replayAndStart(); ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); ClientResponse response = client.resource(makeUrl("/apibeta/createJob")) .accept(MediaType.APPLICATION_JSON) .entity("{this is bad json}", MediaType.APPLICATION_JSON) .post(ClientResponse.class); assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus()); }
Example #23
Source File: AbstractJettyTest.java From attic-aurora with Apache License 2.0 | 5 votes |
protected WebResource.Builder getRequestBuilder(String path) { assertNotNull("HTTP server must be started first", httpServer); ClientConfig config = new DefaultClientConfig(); config.getClasses().add(GsonMessageBodyHandler.class); Client client = Client.create(config); // Disable redirects so we can unit test them. client.setFollowRedirects(false); return client.resource(makeUrl(path)).getRequestBuilder().accept(MediaType.APPLICATION_JSON); }
Example #24
Source File: TestUtil.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public TestUtil(TestProperties testProperties) { this.testProperties = testProperties; // create admin user: ClientConfig clientConfig = new DefaultApacheHttpClient4Config(); clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); client = ApacheHttpClient4.create(clientConfig); defaultHttpClient = (DefaultHttpClient) client.getClientHandler().getHttpClient(); }
Example #25
Source File: TimelineReaderFactory.java From tez with Apache License 2.0 | 5 votes |
@Override public Client getHttpClient() { ClientConfig config = new DefaultClientConfig(JSONRootElementProvider.App.class); HttpURLConnectionFactory urlFactory = new PseudoAuthenticatedURLConnectionFactory(connectionConf); Client httpClient = new Client(new URLConnectionClientHandler(urlFactory), config); return httpClient; }
Example #26
Source File: ResourceAPI.java From tr069-simulator with MIT License | 5 votes |
public WebResource getResourceAPI(String urlstr) { if(service == null) { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(getBaseURI(urlstr)); } return service; }
Example #27
Source File: RestRequestSender.java From osiris with Apache License 2.0 | 5 votes |
public void uploadVoid(String url, File f, String formName) { 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); webResource.type(MULTIPART_MEDIA).accept(MEDIA).post(form); }
Example #28
Source File: MetadataServiceClientImpl.java From eagle with Apache License 2.0 | 5 votes |
public MetadataServiceClientImpl(String host, int port, String context) { this.host = host; this.port = port; this.context = context; this.basePath = buildBasePath(); 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()); }
Example #29
Source File: WebServicesClient.java From Bats with Apache License 2.0 | 5 votes |
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); }
Example #30
Source File: NiFiClient.java From ranger with Apache License 2.0 | 5 votes |
protected WebResource getWebResource() { final ClientConfig config = new DefaultClientConfig(); if (sslContext != null) { config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(hostnameVerifier, sslContext)); } final Client client = Client.create(config); return client.resource(url); }