use of com.sun.jersey.api.client.config.DefaultClientConfig in project ranger by apache.
the class NiFiRegistryClient method getWebResource.
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);
}
use of com.sun.jersey.api.client.config.DefaultClientConfig in project pentaho-kettle by pentaho.
the class Wadl2JavaRestConnectivetyCheck method initRestService1.
/**
* Test stand alone generated code web service connectivity
*/
private void initRestService1() throws InitializationException {
// get information about the remote connection
String username = "admin";
String password = "password";
ClientConfig clientConfig = new DefaultClientConfig();
client = Client.create(clientConfig);
client.addFilter(new HTTPBasicAuthFilter(username, password));
URI baseUri = null;
try {
baseUri = new URI(uri + "/plugin/");
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
PentahoDiPlugin.PurRepositoryPluginApiRevision revisionService = PentahoDiPlugin.purRepositoryPluginApiRevision(client, baseUri);
PentahoDiPlugin.PurRepositoryPluginApiRevision.PathIdVersioningConfiguration versioningConfigurationMethod = revisionService.pathIdVersioningConfiguration("foo.ktr");
FileVersioningConfiguration fileVersioningConfiguration = versioningConfigurationMethod.getAsXml(FileVersioningConfiguration.class);
System.out.println("Test1: " + fileVersioningConfiguration.isVersioningEnabled());
}
use of com.sun.jersey.api.client.config.DefaultClientConfig in project pentaho-kettle by pentaho.
the class RepositoryCleanupUtil method authenticateLoginCredentials.
/**
* 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"));
}
}
use of com.sun.jersey.api.client.config.DefaultClientConfig in project ranger by apache.
the class KmsKeyMgr method getClient.
private synchronized Client getClient() {
Client ret = null;
ClientConfig cc = new DefaultClientConfig();
cc.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true);
ret = Client.create(cc);
return ret;
}
use of com.sun.jersey.api.client.config.DefaultClientConfig in project coprhd-controller by CoprHD.
the class CustomServicesRESTExecution method executeTask.
@Override
public CustomServicesTaskResult executeTask() throws Exception {
try {
ExecutionUtils.currentContext().logInfo("customServicesRESTExecution.startInfo", step.getId(), step.getFriendlyName());
final Map<String, String> attrs = primitive.attributes();
final String authType = attrs.get(CustomServicesConstants.AUTH_TYPE);
if (StringUtils.isEmpty(authType)) {
logger.error("Auth type cannot be undefined");
ExecutionUtils.currentContext().logError("customServicesOperationExecution.logStatus", step.getId(), step.getFriendlyName(), "Auth type cannot be undefined");
throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("Cannot find Auth type");
}
final Client client = BuildRestRequest.makeClient(new DefaultClientConfig(), coordinator, authType, attrs.get(CustomServicesConstants.PROTOCOL), AnsibleHelper.getOptions(CustomServicesConstants.USER, input), AnsibleHelper.getOptions(CustomServicesConstants.PASSWORD, input));
final Map<String, List<InputParameter>> inputKeys = primitive.input() == null ? Collections.emptyMap() : primitive.input();
final List<InputParameter> queryParams = inputKeys.get(CustomServicesConstants.QUERY_PARAMS);
final WebResource webResource = BuildRestRequest.makeWebResource(client, getUrl(primitive, queryParams).toString());
final WebResource.Builder builder = BuildRestRequest.makeRequestBuilder(webResource, step, input);
final CustomServicesConstants.RestMethods method = CustomServicesConstants.RestMethods.valueOf(attrs.get(CustomServicesConstants.METHOD));
final CustomServicesTaskResult result;
switch(method) {
case PUT:
case POST:
final String body = RESTHelper.makePostBody(primitive.attributes().get(CustomServicesConstants.BODY), 0, input);
result = executeRest(method, body, builder);
break;
default:
result = executeRest(method, null, builder);
}
ExecutionUtils.currentContext().logInfo("customServicesRESTExecution.doneInfo", step.getId(), step.getFriendlyName());
return result;
} catch (final Exception e) {
ExecutionUtils.currentContext().logError("customServicesRESTExecution.doneInfo", step.getId(), step.getFriendlyName() + "Custom Service Task Failed" + e);
logger.error("Exception:", e);
throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("Custom Service Task Failed" + e);
}
}
Aggregations