use of org.apache.commons.httpclient.params.DefaultHttpParams in project ecf by eclipse.
the class TestChallengeProcessor method testUnsupportedChallenge.
public void testUnsupportedChallenge() throws Exception {
List authPrefs = new ArrayList(3);
authPrefs.add(AuthPolicy.NTLM);
authPrefs.add(AuthPolicy.BASIC);
authPrefs.add(AuthPolicy.DIGEST);
HttpParams httpparams = new DefaultHttpParams();
httpparams.setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
AuthChallengeProcessor processor = new AuthChallengeProcessor(httpparams);
Map map = new HashMap();
map.put("unsupported1", "unsupported1 realm=\"whatever\"");
map.put("unsupported2", "unsupported2 realm=\"whatever\"");
try {
AuthScheme authscheme = processor.selectAuthScheme(map);
fail("AuthChallengeException should have been thrown");
} catch (AuthChallengeException e) {
// expected
}
}
use of org.apache.commons.httpclient.params.DefaultHttpParams in project ecf by eclipse.
the class TestChallengeProcessor method testChallengeSelection.
public void testChallengeSelection() throws Exception {
List authPrefs = new ArrayList(3);
authPrefs.add(AuthPolicy.NTLM);
authPrefs.add(AuthPolicy.DIGEST);
authPrefs.add(AuthPolicy.BASIC);
HttpParams httpparams = new DefaultHttpParams();
httpparams.setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
AuthChallengeProcessor processor = new AuthChallengeProcessor(httpparams);
Map map = new HashMap();
map.put("unknown", "unknown realm=\"whatever\"");
map.put("basic", "basic realm=\"whatever\"");
AuthScheme authscheme = processor.selectAuthScheme(map);
assertTrue(authscheme instanceof BasicScheme);
}
use of org.apache.commons.httpclient.params.DefaultHttpParams in project ecf by eclipse.
the class TestChallengeProcessor method testChallengeProcessing.
public void testChallengeProcessing() throws Exception {
HttpParams httpparams = new DefaultHttpParams();
AuthChallengeProcessor processor = new AuthChallengeProcessor(httpparams);
Map map = new HashMap();
map.put("basic", "basic realm=\"whatever\", param=\"value\"");
AuthState authstate = new AuthState();
AuthScheme authscheme = processor.processChallenge(authstate, map);
assertTrue(authscheme instanceof BasicScheme);
assertEquals("whatever", authscheme.getRealm());
assertEquals(authscheme, authstate.getAuthScheme());
assertEquals("value", authscheme.getParameter("param"));
}
use of org.apache.commons.httpclient.params.DefaultHttpParams in project ecf by eclipse.
the class TestChallengeProcessor method testInvalidChallenge.
public void testInvalidChallenge() throws Exception {
List authPrefs = new ArrayList(3);
authPrefs.add("unsupported1");
authPrefs.add("unsupported2");
HttpParams httpparams = new DefaultHttpParams();
httpparams.setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
AuthChallengeProcessor processor = new AuthChallengeProcessor(httpparams);
Map map = new HashMap();
map.put("unsupported1", "unsupported1 realm=\"whatever\"");
map.put("unsupported2", "unsupported2 realm=\"whatever\"");
try {
AuthScheme authscheme = processor.selectAuthScheme(map);
fail("AuthChallengeException should have been thrown");
} catch (AuthChallengeException e) {
// ignore
}
}
use of org.apache.commons.httpclient.params.DefaultHttpParams in project ecf by eclipse.
the class TestChallengeProcessor method testInvalidChallengeProcessing.
public void testInvalidChallengeProcessing() throws Exception {
HttpParams httpparams = new DefaultHttpParams();
AuthChallengeProcessor processor = new AuthChallengeProcessor(httpparams);
Map map = new HashMap();
map.put("basic", "basic realm=\"whatever\", param=\"value\"");
AuthState authstate = new AuthState();
AuthScheme authscheme = processor.processChallenge(authstate, map);
assertTrue(authscheme instanceof BasicScheme);
assertEquals("whatever", authscheme.getRealm());
assertEquals(authscheme, authstate.getAuthScheme());
assertEquals("value", authscheme.getParameter("param"));
Map map2 = new HashMap();
map2.put("ntlm", "NTLM");
try {
// Basic authentication scheme expected
authscheme = processor.processChallenge(authstate, map2);
fail("AuthenticationException should have been thrown");
} catch (AuthenticationException e) {
// expected
}
}
Aggregations