Search in sources :

Example 41 with Credentials

use of org.apache.http.auth.Credentials in project janusgraph by JanusGraph.

the class RestClientSetupTest method testHttpBasicAuthConfiguration.

@Test
public void testHttpBasicAuthConfiguration() throws Exception {
    // testing that the appropriate values are passed to the client builder via credentials provider
    final String testRealm = "testRealm";
    final String testUser = "testUser";
    final String testPassword = "testPassword";
    final CredentialsProvider cp = basicAuthTestBase(ImmutableMap.<String, String>builder().build(), testRealm, testUser, testPassword);
    final Credentials credentials = cp.getCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, testRealm));
    assertNotNull(credentials);
    assertEquals(testUser, credentials.getUserPrincipal().getName());
    assertEquals(testPassword, credentials.getPassword());
}
Also used : AuthScope(org.apache.http.auth.AuthScope) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) CredentialsProvider(org.apache.http.client.CredentialsProvider) Credentials(org.apache.http.auth.Credentials) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 42 with Credentials

use of org.apache.http.auth.Credentials in project janusgraph by JanusGraph.

the class BasicAuthHttpClientConfigCallbackTest method testSetDefaultCredentialsProviderNoRealm.

@Test
public void testSetDefaultCredentialsProviderNoRealm() throws Exception {
    final CredentialsProvider cp = basicAuthTestBase("");
    // expected: will match any host and any realm
    final Credentials credentialsForRealm1 = cp.getCredentials(new AuthScope("dummyhost1", 1234, "dummyrealm1"));
    assertEquals(HTTP_USER, credentialsForRealm1.getUserPrincipal().getName());
    assertEquals(HTTP_PASSWORD, credentialsForRealm1.getPassword());
}
Also used : AuthScope(org.apache.http.auth.AuthScope) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) CredentialsProvider(org.apache.http.client.CredentialsProvider) Credentials(org.apache.http.auth.Credentials) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Credentials (org.apache.http.auth.Credentials)42 AuthScope (org.apache.http.auth.AuthScope)25 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)16 CredentialsProvider (org.apache.http.client.CredentialsProvider)16 AuthScheme (org.apache.http.auth.AuthScheme)15 AuthState (org.apache.http.auth.AuthState)11 BasicCredentialsProvider (org.apache.http.impl.client.BasicCredentialsProvider)10 AuthenticationException (org.apache.http.auth.AuthenticationException)9 HttpHost (org.apache.http.HttpHost)8 Test (org.junit.Test)6 NTCredentials (org.apache.http.auth.NTCredentials)5 IOException (java.io.IOException)4 Header (org.apache.http.Header)4 HttpException (org.apache.http.HttpException)4 HttpRequest (org.apache.http.HttpRequest)4 HttpResponse (org.apache.http.HttpResponse)4 Scheme (org.apache.http.conn.scheme.Scheme)4 BasicScheme (org.apache.http.impl.auth.BasicScheme)4 HttpEntity (org.apache.http.HttpEntity)3 AbortableHttpRequest (org.apache.http.client.methods.AbortableHttpRequest)3