Package org.apache.http.auth

Examples of org.apache.http.auth.AuthScope


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

        httpclient.getCredentialsProvider().setCredentials(
                new AuthScope("localhost", 8080),
                new UsernamePasswordCredentials("username", "password"));

        HttpHost targetHost = new HttpHost("www.verisign.com", 443, "https");
        HttpHost proxy = new HttpHost("localhost", 8080);
View Full Code Here


        });
      localHttpClient.setRedirectStrategy(new DefaultRedirectStrategy());
      if (strippedUserName != null)
      {
        localHttpClient.getCredentialsProvider().setCredentials(
          new AuthScope(serverName,serverPort),
          new NTCredentials(strippedUserName, password, currentHost, ntlmDomain));
      }

      httpClient = localHttpClient;
     
View Full Code Here

            proxyAuthPassword = "";
          if (proxyAuthDomain == null)
            proxyAuthDomain = "";

          localHttpClient.getCredentialsProvider().setCredentials(
            new AuthScope(proxyHost, proxyPort),
            new NTCredentials(proxyAuthUsername, proxyAuthPassword, currentHost, proxyAuthDomain));
        }

        HttpHost proxy = new HttpHost(proxyHost, proxyPort);
View Full Code Here

          proxyPassword = "";
        if (proxyDomain == null)
          proxyDomain = "";

        localHttpClient.getCredentialsProvider().setCredentials(
          new AuthScope(proxyHost, proxyPortInt),
          new NTCredentials(proxyUsername, proxyPassword, currentHost, proxyDomain));
      }

      HttpHost proxy = new HttpHost(proxyHost, proxyPortInt);
View Full Code Here

          proxyPassword = "";
        if (proxyDomain == null)
          proxyDomain = "";

        localHttpClient.getCredentialsProvider().setCredentials(
          new AuthScope(proxyHost, proxyPortInt),
          new NTCredentials(proxyUsername, proxyPassword, currentHost, proxyDomain));
      }

      HttpHost proxy = new HttpHost(proxyHost, proxyPortInt);
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);
    }

    String httpSolrServerUrl = protocol + "://" + server + ":" + port + location;
View Full Code Here

      if (remotePassword != null) {
        try {
          URL urlParsed = new URL(url);
          String host = urlParsed.getHost();
          CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
          credentialsProvider.setCredentials(new AuthScope(host, AuthScope.ANY_PORT), new UsernamePasswordCredentials(
              remoteUsername, remotePassword));
          clientBuilder.setDefaultCredentialsProvider(credentialsProvider);
          isAuthConfigured = true;
        } catch (MalformedURLException e) {
          // this should never happen due validation before
View Full Code Here

        final Scheme sch = new Scheme("https", 443, socketFactory);
        httpclient.getConnectionManager().getSchemeRegistry().register(sch);
    }

    private void configureAuthentication(final DefaultHttpClient httpclient, final String scheme, final Principal principal) {
        httpclient.getCredentialsProvider().setCredentials(new AuthScope(ANY_HOST, ANY_PORT, ANY_REALM, scheme), new Credentials() {
            public Principal getUserPrincipal() {
                return principal;
            }

            public String getPassword() {
View Full Code Here

      {
         if (registration.getAuthenticationMechanism().getType() instanceof BasicAuth)
         {
            BasicAuth basic = (BasicAuth) registration.getAuthenticationMechanism().getType();
            UsernamePasswordCredentials creds = new UsernamePasswordCredentials(basic.getUsername(), basic.getPassword());
            AuthScope authScope = new AuthScope(AuthScope.ANY);
            ((DefaultHttpClient)client).getCredentialsProvider().setCredentials(authScope, creds);

            localContext = new BasicHttpContext();

            // Generate BASIC scheme object and stick it to the local execution context
View Full Code Here

         if (authState.getAuthScheme() == null) {
            AuthScheme authScheme = (AuthScheme) context.getAttribute("preemptive-auth");
            CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(ClientContext.CREDS_PROVIDER);
            HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
            if (authScheme != null) {
               Credentials creds = credsProvider.getCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort()));
               if (creds == null) {
                  throw new HttpException("No credentials for preemptive authentication");
               }
               authState.setAuthScheme(authScheme);
               authState.setCredentials(creds);
View Full Code Here

TOP

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

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.