Skip to content

Commit 1ee6f5b

Browse files
committed
added the authentication page
1 parent 05b77cb commit 1ee6f5b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/site/apt/auth.apt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
------
2+
Async Http Client - Configuring Authentication: BASIC, DIGEST or NTLM
3+
------
4+
Jeanfrancois Arcand
5+
------
6+
2012
7+
8+
Configuring Authentication: BASIC, DIGEST or NTLM
9+
10+
Configuring authentication with AsyncHttpClient is simple. You can configure it at the <<<Request>>> level using the
11+
<<<RealmBuilder>>>:
12+
13+
+-----+
14+
AsyncHttpClient client = new AsyncHttpClient();
15+
Realm realm = new Realm.RealmBuilder()
16+
.setPrincipal(user)
17+
.setPassword(admin)
18+
.setUsePreemptiveAuth(true)
19+
.setScheme(AuthScheme.BASIC)
20+
.build();
21+
client.prepareGet("http://...").setRealm(realm).execute();
22+
+-----+
23+
24+
You can also set the realm at the AsyncHttpClientConfig level:
25+
26+
+-----+
27+
Builder builder = new AsyncHttpClientConfig.Builder();
28+
Realm realm = new Realm.RealmBuilder()
29+
.setPrincipal(user)
30+
.setPassword(admin)
31+
.setUsePreemptiveAuth(true)
32+
.setScheme(AuthScheme.BASIC)
33+
.build();
34+
builder.setRealm(realm).build();
35+
AsyncHttpClient client = new AsyncHttpClient(builder.build());
36+
+-----+
37+
38+
The authentication type supported are <<<BASIC>>>, <<<DIGEST>>> and <<<NTLM>>>. You can also customize your own
39+
authentication mechanism by using the Response Filter.

0 commit comments

Comments
 (0)