use of org.apache.http.impl.auth.DigestScheme in project android_frameworks_base by ParanoidAndroid.
the class DefaultHttpClientTest method authenticateDigestAlgorithm.
private void authenticateDigestAlgorithm(String algorithm) throws Exception {
String challenge = "Digest realm=\"protected area\", " + "nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", " + "algorithm=" + algorithm;
DigestScheme digestScheme = new DigestScheme();
digestScheme.processChallenge(new BasicHeader("WWW-Authenticate", challenge));
HttpGet get = new HttpGet();
digestScheme.authenticate(new UsernamePasswordCredentials("username", "password"), get);
}
use of org.apache.http.impl.auth.DigestScheme in project android_frameworks_base by ResurrectionRemix.
the class DefaultHttpClientTest method authenticateDigestAlgorithm.
private void authenticateDigestAlgorithm(String algorithm) throws Exception {
String challenge = "Digest realm=\"protected area\", " + "nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", " + "algorithm=" + algorithm;
DigestScheme digestScheme = new DigestScheme();
digestScheme.processChallenge(new BasicHeader("WWW-Authenticate", challenge));
HttpGet get = new HttpGet();
digestScheme.authenticate(new UsernamePasswordCredentials("username", "password"), get);
}
use of org.apache.http.impl.auth.DigestScheme in project android_frameworks_base by crdroidandroid.
the class DefaultHttpClientTest method authenticateDigestAlgorithm.
private void authenticateDigestAlgorithm(String algorithm) throws Exception {
String challenge = "Digest realm=\"protected area\", " + "nonce=\"dcd98b7102dd2f0e8b11d0f600bfb0c093\", " + "algorithm=" + algorithm;
DigestScheme digestScheme = new DigestScheme();
digestScheme.processChallenge(new BasicHeader("WWW-Authenticate", challenge));
HttpGet get = new HttpGet();
digestScheme.authenticate(new UsernamePasswordCredentials("username", "password"), get);
}
use of org.apache.http.impl.auth.DigestScheme in project syncope by apache.
the class HttpUtils method postWithStringEntity.
public int postWithStringEntity(final String url, final String stringEntity) {
int status = 0;
try {
final HttpPost httPost = httpPost(url, new StringEntity(stringEntity));
httPost.addHeader("Content-Type", ContentType.APPLICATION_JSON.getMimeType());
try (CloseableHttpResponse response = httpClient.execute(targetHost, httPost, setAuth(targetHost, new DigestScheme()))) {
status = response.getStatusLine().getStatusCode();
handler.logOutput("Http status: " + status, true);
InstallLog.getInstance().info("Http status: " + status);
}
} catch (final IOException ioe) {
final String messageError = "Error calling " + url + ": " + ioe.getMessage();
handler.emitError(messageError, messageError);
InstallLog.getInstance().error(messageError);
}
return status;
}
use of org.apache.http.impl.auth.DigestScheme in project tutorials by eugenp.
the class HttpComponentsClientHttpRequestFactoryDigestAuth method createHttpContext.
private HttpContext createHttpContext() {
// Create AuthCache instance
final AuthCache authCache = new BasicAuthCache();
// Generate DIGEST scheme object, initialize it and add it to the local auth cache
final DigestScheme digestAuth = new DigestScheme();
// If we already know the realm name
digestAuth.overrideParamter("realm", "Custom Realm Name");
// digestAuth.overrideParamter("nonce", "MTM3NTU2OTU4MDAwNzoyYWI5YTQ5MTlhNzc5N2UxMGM5M2Y5M2ViOTc4ZmVhNg==");
authCache.put(host, digestAuth);
// Add AuthCache to the execution context
final BasicHttpContext localcontext = new BasicHttpContext();
localcontext.setAttribute(HttpClientContext.AUTH_CACHE, authCache);
return localcontext;
}
Aggregations