Search in sources :

Example 36 with DefaultClientConfig

use of com.sun.jersey.api.client.config.DefaultClientConfig in project pentaho-platform by pentaho.

the class CommandLineProcessor method initRestService.

/**
 * Used only for REST Jersey calls
 *
 * @throws ParseException
 */
private void initRestService() throws ParseException, InitializationException {
    // get information about the remote connection
    String username = getOptionValue(INFO_OPTION_USERNAME_NAME, true, false);
    String password = getOptionValue(INFO_OPTION_PASSWORD_NAME, true, false);
    password = KettleTwoWayPasswordEncoder.decryptPasswordOptionallyEncrypted(password);
    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    client = Client.create(clientConfig);
    client.addFilter(new HTTPBasicAuthFilter(username, password));
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) HTTPBasicAuthFilter(com.sun.jersey.api.client.filter.HTTPBasicAuthFilter)

Example 37 with DefaultClientConfig

use of com.sun.jersey.api.client.config.DefaultClientConfig in project tez by apache.

the class ATSImportTool method getHttpClient.

private Client getHttpClient() {
    if (httpClient == null) {
        ClientConfig config = new DefaultClientConfig(JSONRootElementProvider.App.class);
        HttpURLConnectionFactory urlFactory = new PseudoAuthenticatedURLConnectionFactory();
        return new Client(new URLConnectionClientHandler(urlFactory), config);
    }
    return httpClient;
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) URLConnectionClientHandler(com.sun.jersey.client.urlconnection.URLConnectionClientHandler) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) Client(com.sun.jersey.api.client.Client) JSONRootElementProvider(com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider) HttpURLConnectionFactory(com.sun.jersey.client.urlconnection.HttpURLConnectionFactory)

Example 38 with DefaultClientConfig

use of com.sun.jersey.api.client.config.DefaultClientConfig in project ApiEE by avraampiperidis.

the class ApiHttp method postFile.

public static ClientResponse postFile(String url, String name, String filename, byte[] data, String auth) {
    DefaultClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getClasses().add(MultiPartWriter.class);
    Client client = Client.create(clientConfig);
    WebResource webResource = client.resource(url);
    FormDataMultiPart formDataMultiPart = new FormDataMultiPart();
    formDataMultiPart.field(name, filename);
    FormDataBodyPart bodyPart = new FormDataBodyPart(name, new ByteArrayInputStream(data), MediaType.APPLICATION_OCTET_STREAM_TYPE);
    formDataMultiPart.bodyPart(bodyPart);
    ClientResponse response = webResource.type(MediaType.MULTIPART_FORM_DATA_TYPE).header("Authorization", auth).post(ClientResponse.class, formDataMultiPart);
    return response;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ByteArrayInputStream(java.io.ByteArrayInputStream) FormDataBodyPart(org.glassfish.jersey.media.multipart.FormDataBodyPart) WebResource(com.sun.jersey.api.client.WebResource) FormDataMultiPart(org.glassfish.jersey.media.multipart.FormDataMultiPart) Client(com.sun.jersey.api.client.Client)

Example 39 with DefaultClientConfig

use of com.sun.jersey.api.client.config.DefaultClientConfig in project atlas by apache.

the class SecureEmbeddedServerTestBase method setup.

@BeforeMethod
public void setup() throws Exception {
    jksPath = new Path(Files.createTempDirectory("tempproviders").toString(), "test.jks");
    providerUrl = JavaKeyStoreProvider.SCHEME_NAME + "://file/" + jksPath.toUri();
    String baseUrl = String.format("https://localhost:%d/", securePort);
    DefaultClientConfig config = new DefaultClientConfig();
    Client client = Client.create(config);
    client.resource(UriBuilder.fromUri(baseUrl).build());
    service = client.resource(UriBuilder.fromUri(baseUrl).build());
}
Also used : Path(org.apache.hadoop.fs.Path) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) Client(com.sun.jersey.api.client.Client) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 40 with DefaultClientConfig

use of com.sun.jersey.api.client.config.DefaultClientConfig in project ff4j by ff4j.

the class AbstractWebResourceTestIT method configure.

/**
 * {@inheritDoc}
 */
@Override
public WebAppDescriptor configure() {
    ClientConfig cc = new DefaultClientConfig();
    cc.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    return new WebAppDescriptor.Builder().initParam(WebComponent.APPLICATION_CONFIG_CLASS, // 
    SimpleFF4jProvider.class.getName()).clientConfig(cc).build();
}
Also used : WebAppDescriptor(com.sun.jersey.test.framework.WebAppDescriptor) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig)

Aggregations

DefaultClientConfig (com.sun.jersey.api.client.config.DefaultClientConfig)65 ClientConfig (com.sun.jersey.api.client.config.ClientConfig)55 Client (com.sun.jersey.api.client.Client)42 WebResource (com.sun.jersey.api.client.WebResource)21 HTTPBasicAuthFilter (com.sun.jersey.api.client.filter.HTTPBasicAuthFilter)15 ClientResponse (com.sun.jersey.api.client.ClientResponse)14 HTTPSProperties (com.sun.jersey.client.urlconnection.HTTPSProperties)9 HostnameVerifier (javax.net.ssl.HostnameVerifier)7 SSLSession (javax.net.ssl.SSLSession)7 TrustManager (javax.net.ssl.TrustManager)7 ClientHandlerException (com.sun.jersey.api.client.ClientHandlerException)6 URLConnectionClientHandler (com.sun.jersey.client.urlconnection.URLConnectionClientHandler)6 IOException (java.io.IOException)6 VisibleForTesting (com.google.common.annotations.VisibleForTesting)5 ClientFilter (com.sun.jersey.api.client.filter.ClientFilter)5 LoggingFilter (com.sun.jersey.api.client.filter.LoggingFilter)5 SecureRandom (java.security.SecureRandom)5 SSLContext (javax.net.ssl.SSLContext)5 URISyntaxException (java.net.URISyntaxException)4 ArrayList (java.util.ArrayList)4