Package org.apache.http.auth

Examples of org.apache.http.auth.UsernamePasswordCredentials


        Header authChallenge = new BasicHeader(AUTH.WWW_AUTH, challenge);

        DigestScheme authscheme = new DigestScheme();
        authscheme.processChallenge(authChallenge);

        Credentials cred = new UsernamePasswordCredentials(username, password);
        HttpRequest request = new BasicHttpRequest("Simple", "/");
        authscheme.authenticate(cred, request);
    }
View Full Code Here


    @Test
    public void testDigestNouceCount() throws Exception {
        String challenge1 = "Digest realm=\"realm1\", nonce=\"f2a3f18799759d4f1a1c068b92b573cb\", qop=auth";
        Header authChallenge1 = new BasicHeader(AUTH.WWW_AUTH, challenge1);
        HttpRequest request = new BasicHttpRequest("GET", "/");
        Credentials cred = new UsernamePasswordCredentials("username","password");
        DigestScheme authscheme = new DigestScheme();
        authscheme.processChallenge(authChallenge1);
        Header authResponse1 = authscheme.authenticate(cred, request);
        Map<String, String> table1 = parseAuthResponse(authResponse1);
        Assert.assertEquals("00000001", table1.get("nc"));
View Full Code Here

    public void testDigestMD5SessA1AndCnonceConsistency() throws Exception {
        String challenge1 = "Digest qop=\"auth\", algorithm=MD5-sess, nonce=\"1234567890abcdef\", " +
                "charset=utf-8, realm=\"subnet.domain.com\"";
        Header authChallenge1 = new BasicHeader(AUTH.WWW_AUTH, challenge1);
        HttpRequest request = new BasicHttpRequest("GET", "/");
        Credentials cred = new UsernamePasswordCredentials("username","password");
        DigestScheme authscheme = new DigestScheme();
        authscheme.processChallenge(authChallenge1);
        Header authResponse1 = authscheme.authenticate(cred, request);
        Map<String, String> table1 = parseAuthResponse(authResponse1);
        Assert.assertEquals("00000001", table1.get("nc"));
View Full Code Here

    
      });
   
    if (userID != null && userID.length() > 0 && password != null)
    {
      Credentials credentials = new UsernamePasswordCredentials(userID, password);
      if (realm != null)
        localClient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, realm), credentials);
      else
        localClient.getCredentialsProvider().setCredentials(AuthScope.ANY, credentials);
    }
View Full Code Here

    // If authentication needed, set that
    if (clientId != null)
    {
      localHttpClient.getCredentialsProvider().setCredentials(
        AuthScope.ANY,
        new UsernamePasswordCredentials(clientId,clientSecret));
    }
   
    // If there's a proxy, set that too.
    if (proxyHost != null && proxyHost.length() > 0)
    {
View Full Code Here

    // If authentication needed, set that
    if (clientId != null)
    {
      localHttpClient.getCredentialsProvider().setCredentials(
        AuthScope.ANY,
        new UsernamePasswordCredentials(clientId,clientSecret));
    }

    // If there's a proxy, set that too.
    if (proxyHost != null && proxyHost.length() > 0)
    {
View Full Code Here

  protected DefaultHttpClient getClient() throws ManifoldCFException {
    DefaultHttpClient cl = new DefaultHttpClient();
    if (genericLogin != null && !genericLogin.isEmpty()) {
      try {
        URL url = new URL(genericEntryPoint);
        Credentials credentials = new UsernamePasswordCredentials(genericLogin, genericPassword);
        cl.getCredentialsProvider().setCredentials(new AuthScope(url.getHost(), url.getPort() > 0 ? url.getPort() : 80, AuthScope.ANY_REALM), credentials);
        cl.addRequestInterceptor(new PreemptiveAuth(credentials), 0);
      } catch (MalformedURLException ex) {
        throw new ManifoldCFException("getClient exception: " + ex.getMessage(), ex);
      }
View Full Code Here

    public static void main(String[] args) throws Exception {
        DefaultHttpClient httpclient = new DefaultHttpClient();

        httpclient.getCredentialsProvider().setCredentials(
                new AuthScope("localhost", 443),
                new UsernamePasswordCredentials("username", "password"));
       
        HttpGet httpget = new HttpGet("https://localhost/protected");
       
        System.out.println("executing request" + httpget.getRequestLine());
        HttpResponse response = httpclient.execute(httpget);
View Full Code Here

      }
      DefaultHttpClient cl = new DefaultHttpClient();
      if (genericLogin != null && !genericLogin.isEmpty()) {
        try {
          URL url = new URL(genericEntryPoint);
          Credentials credentials = new UsernamePasswordCredentials(genericLogin, genericPassword);
          cl.getCredentialsProvider().setCredentials(new AuthScope(url.getHost(), url.getPort() > 0 ? url.getPort() : 80, AuthScope.ANY_REALM), credentials);
          cl.addRequestInterceptor(new PreemptiveAuth(credentials), 0);
        } catch (MalformedURLException ex) {
          client = null;
          sessionExpirationTime = -1L;
View Full Code Here

                String user = console.readLine();  
                System.out.print("Enter password: ");
                String password = console.readLine();
               
                if (user != null && user.length() > 0) {
                    Credentials creds = new UsernamePasswordCredentials(user, password);
                    httpclient.getCredentialsProvider().setCredentials(authScope, creds);
                    trying = true;
                } else {
                    trying = false;
                }
View Full Code Here

TOP

Related Classes of org.apache.http.auth.UsernamePasswordCredentials

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.