use of com.sun.jersey.api.client.filter.HTTPBasicAuthFilter in project ORCID-Source by ORCID.
the class OrcidClientHelper method addBasicAuth.
public void addBasicAuth(String username, String password) {
basicAuthFilter = new HTTPBasicAuthFilter(username, password);
jerseyClient.addFilter(basicAuthFilter);
}
use of com.sun.jersey.api.client.filter.HTTPBasicAuthFilter in project microservices by pwillhan.
the class ComponentFinder method main.
public static void main(String[] args) {
Scanner scanner = null;
try {
scanner = new Scanner(System.in);
System.out.println("Enter component type in plural form (e.g. queues, exchanges) ");
String type = scanner.nextLine();
System.out.println("Enter vhost (leave empty for default vhost) ");
String vhost = scanner.nextLine();
System.out.println("Enter name pattern (leave empty for match-all pattern)");
String pattern = scanner.nextLine();
Client client = Client.create();
String path;
if (vhost.trim().isEmpty()) {
path = API_ROOT + "/" + type + "?columns=name";
} else {
path = API_ROOT + "/" + type + "/" + vhost + "?columns=name";
}
WebResource resource = client.resource(path);
resource.header("Content-Type", "application/json;charset=UTF-8");
resource.addFilter(new HTTPBasicAuthFilter("guest", "guest".getBytes()));
String result = resource.get(String.class);
JSONArray jsonResult = new JSONArray(result);
LOGGER.debug("Result: \n" + jsonResult.toString(4));
filterResult(jsonResult, pattern);
} finally {
if (scanner != null) {
scanner.close();
}
}
}
use of com.sun.jersey.api.client.filter.HTTPBasicAuthFilter in project activityinfo by bedatadriven.
the class DataEntrySteps method field_has_downloadable_link.
@Then("^\"([^\"]*)\" field has downloadable link.$")
public void field_has_downloadable_link(String attachmentFieldName) throws Throwable {
String blobLink = firstDownloadableLinkOfFirstSubmission(attachmentFieldName);
UserAccount currentUser = driver.setup().getCurrentUser();
Client client = new Client();
client.addFilter(new HTTPBasicAuthFilter(currentUser.getEmail(), currentUser.getPassword()));
client.setFollowRedirects(false);
ClientResponse clientResponse = client.resource(blobLink).get(ClientResponse.class);
assertEquals(Response.Status.OK.getStatusCode(), clientResponse.getStatus());
}
use of com.sun.jersey.api.client.filter.HTTPBasicAuthFilter in project activityinfo by bedatadriven.
the class XFormApplicationDriver method submitForm.
@Override
public ResourceId submitForm(String formName, List<FieldValue> values) throws Exception {
Client client = Client.create();
if (currentUser != null) {
client.addFilter(new HTTPBasicAuthFilter(currentUser.getEmail(), currentUser.getPassword()));
}
WebResource root = client.resource(server.getRootUrl());
// root.path("formList").get()
throw new UnsupportedOperationException();
}
use of com.sun.jersey.api.client.filter.HTTPBasicAuthFilter in project java-docs-samples by GoogleCloudPlatform.
the class MailgunServlet method sendSimpleMessage.
// [START simple]
private ClientResponse sendSimpleMessage(String recipient) {
Client client = Client.create();
client.addFilter(new HTTPBasicAuthFilter("api", MAILGUN_API_KEY));
MultivaluedMapImpl formData = new MultivaluedMapImpl();
formData.add("from", "Mailgun User <mailgun@" + MAILGUN_DOMAIN_NAME + ">");
formData.add("to", recipient);
formData.add("subject", "Simple Mailgun Example");
formData.add("text", "Plaintext content");
WebResource webResource = client.resource("https://api.mailgun.net/v3/" + MAILGUN_DOMAIN_NAME + "/messages");
return webResource.type(MediaType.APPLICATION_FORM_URLENCODED).post(ClientResponse.class, formData);
}
Aggregations