类org.apache.http.auth.AuthScheme源码实例Demo

下面列出了怎么用org.apache.http.auth.AuthScheme的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jenkins-client-java   文件: PreemptiveAuth.java
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
    AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);

    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.update(authScheme, creds);
        }
    }
}
 
源代码2 项目: activemq-artemis   文件: UriStrategy.java
@Override
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
   AuthState authState = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE);

   // If no auth scheme available yet, try to initialize it preemptively
   if (authState.getAuthScheme() == null) {
      AuthScheme authScheme = (AuthScheme) context.getAttribute("preemptive-auth");
      CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(HttpClientContext.CREDS_PROVIDER);
      HttpHost targetHost = (HttpHost) context.getAttribute(HttpCoreContext.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.update(authScheme, creds);
      }
   }
}
 
源代码3 项目: verigreen   文件: PreemptiveAuth.java
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
    AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
    Credentials creds;
    
    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) {
            creds =
                    credsProvider.getCredentials(new AuthScope(
                            targetHost.getHostName(),
                            targetHost.getPort()));
            if (creds == null) {
                throw new HttpException("No credentials for preemptive authentication");
            }
            authState.update(authScheme, creds);
        }
    }
}
 
@Override
public void process(final HttpRequest request, final HttpContext context) {
    // never ever send credentials preemptively to a host which is not the configured Gerrit host
    if (!isForGerritHost(request)) {
        return;
    }

    AuthState authState = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE);

    // if no auth scheme available yet, try to initialize it preemptively
    if (authState.getAuthScheme() == null) {
        AuthScheme authScheme = (AuthScheme) context.getAttribute(PREEMPTIVE_AUTH);
        UsernamePasswordCredentials creds = new UsernamePasswordCredentials(authData.getLogin(), authData.getPassword());
        authState.update(authScheme, creds);
    }
}
 
源代码5 项目: YiBo   文件: LibRequestDirector.java
private void processChallenges(
        final Map<String, Header> challenges,
        final AuthState authState,
        final AuthenticationHandler authHandler,
        final HttpResponse response,
        final HttpContext context)
            throws MalformedChallengeException, AuthenticationException {

    AuthScheme authScheme = authState.getAuthScheme();
    if (authScheme == null) {
        // Authentication not attempted before
        authScheme = authHandler.selectScheme(challenges, response, context);
        authState.setAuthScheme(authScheme);
    }
    String id = authScheme.getSchemeName();

    Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
    if (challenge == null) {
        throw new AuthenticationException(id +
            " authorization challenge expected, but not found");
    }
    authScheme.processChallenge(challenge);
    if (DEBUG) {
    	Logger.debug("Authorization challenge processed");
    }
}
 
源代码6 项目: fess   文件: WebAuthentication.java
private AuthScheme getAuthScheme() {
    final String scheme = getProtocolScheme();
    if (Constants.BASIC.equals(scheme)) {
        return new BasicScheme();
    } else if (Constants.DIGEST.equals(scheme)) {
        return new DigestScheme();
    } else if (Constants.NTLM.equals(scheme)) {
        final Properties props = new Properties();
        getWebConfig().getConfigParameterMap(ConfigName.CONFIG).entrySet().stream()
                .filter(e -> e.getKey().startsWith(Config.JCIFS_PREFIX)).forEach(e -> {
                    props.setProperty(e.getKey(), e.getValue());
                });
        return new NTLMScheme(new JcifsEngine(props));
    } else if (Constants.FORM.equals(scheme)) {
        final Map<String, String> parameterMap = ParameterUtil.parse(getParameters());
        return new FormScheme(parameterMap);
    }
    return null;
}
 
源代码7 项目: cloudhopper-commons   文件: HttpSender.java
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
    
    AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
    
    // If no auth scheme avaialble yet, try to initialize it preemptively
    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);
        }
    }
    
}
 
源代码8 项目: httpsig-java   文件: Http4Util.java
public static void enableAuth(final AbstractHttpClient client, final Keychain keychain, final KeyId keyId) {
    if (client == null) {
        throw new NullPointerException("client");
    }

    if (keychain == null) {
        throw new NullPointerException("keychain");
    }

    client.getAuthSchemes().register(Constants.SCHEME, new AuthSchemeFactory() {
        public AuthScheme newInstance(HttpParams params) {
            return new Http4SignatureAuthScheme();
        }
    });

    Signer signer = new Signer(keychain, keyId);
    client.getCredentialsProvider().setCredentials(AuthScope.ANY, new SignerCredentials(signer));
    client.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF,
                                    Arrays.asList(Constants.SCHEME));

    HttpClientParams.setAuthenticating(client.getParams(), true);
}
 
源代码9 项目: camel-quarkus   文件: BasicAuthCacheAlias.java
@Substitute
@Override
public void put(final HttpHost host, final AuthScheme authScheme) {
    Args.notNull(host, "HTTP host");
    if (authScheme == null) {
        return;
    }
    this.map.put(getKey(host), authScheme);
}
 
源代码10 项目: quarkus   文件: Substitute_RestClient.java
@Override
public void put(final HttpHost host, final AuthScheme authScheme) {
    Args.notNull(host, "HTTP host");
    if (authScheme == null) {
        return;
    }
    this.map.put(getKey(host), authScheme);
}
 
@Override
public void authSucceeded(final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
    final HttpClientContext clientContext = HttpClientContext.adapt(context);
    final Credentials credentials = clientContext.getAttribute(PROXY_CREDENTIALS_INPUT_ID, Credentials.class);
    if(null != credentials) {
        clientContext.removeAttribute(PROXY_CREDENTIALS_INPUT_ID);
        if(log.isInfoEnabled()) {
            log.info(String.format("Save passphrase for proxy %s", authhost));
        }
        keychain.addCredentials(authhost.toURI(), credentials.getUsername(), credentials.getPassword());
    }
    super.authSucceeded(authhost, authScheme, context);
}
 
源代码12 项目: sputnik   文件: HttpHelper.java
@NotNull
public HttpClientContext buildClientContext(@NotNull HttpHost httpHost, @NotNull AuthScheme authScheme) {
    AuthCache basicAuthCache = new BasicAuthCache();
    basicAuthCache.put(httpHost, authScheme);
    HttpClientContext httpClientContext = HttpClientContext.create();
    httpClientContext.setAuthCache(basicAuthCache);
    httpClientContext.setTargetHost(httpHost);
    return httpClientContext;
}
 
源代码13 项目: cloudhopper-commons   文件: HttpPostMain.java
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
    
    AuthState authState = (AuthState) context.getAttribute(
            ClientContext.TARGET_AUTH_STATE);
    
    // If no auth scheme avaialble yet, try to initialize it preemptively
    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);
        }
    }
    
}
 
源代码14 项目: camel-quarkus   文件: BasicAuthCacheAlias.java
@Substitute
@Override
public AuthScheme get(final HttpHost host) {
    Args.notNull(host, "HTTP host");
    return this.map.get(getKey(host));
}
 
源代码15 项目: pushfish-android   文件: NTLMSchemeFactory.java
public AuthScheme newInstance(HttpParams params) {
    return new NTLMScheme(new JCIFSEngine());
}
 
源代码16 项目: pushfish-android   文件: NTLMSchemeFactory.java
public AuthScheme newInstance(HttpParams params) {
    return new NTLMScheme(new JCIFSEngine());
}
 
源代码17 项目: htmlunit   文件: HttpWebConnection.java
@Override
public synchronized void put(final HttpHost host, final AuthScheme authScheme) {
    super.put(host, authScheme);
}
 
源代码18 项目: htmlunit   文件: HttpWebConnection.java
@Override
public synchronized AuthScheme get(final HttpHost host) {
    return super.get(host);
}
 
源代码19 项目: davmail   文件: JCIFSNTLMSchemeFactory.java
@Override
public AuthScheme create(HttpContext context) {
    return new NTLMScheme(new JCIFSEngine());
}
 
源代码20 项目: quarkus   文件: Substitute_RestClient.java
@Override
public AuthScheme get(final HttpHost host) {
    Args.notNull(host, "HTTP host");
    return this.map.get(getKey(host));
}
 
@Override
public void put(HttpHost host, AuthScheme authScheme) {
    map.put(host, authScheme);
}
 
@Override
public AuthScheme get(HttpHost host) {
    return map.get(host);
}
 
源代码23 项目: ats-framework   文件: SPNegoSchemeFactory.java
public AuthScheme newInstance(
                               final HttpParams params ) {

    return new SPNegoScheme(gssClient, servicePrincipalName, servicePrincipalOid);
}
 
源代码24 项目: ats-framework   文件: SPNegoSchemeFactory.java
public AuthScheme create(
                          final HttpContext context ) {

    return new SPNegoScheme(gssClient, servicePrincipalName, servicePrincipalOid);
}
 
@Override
public AuthScheme create(final HttpContext context) {
    return new BackportWindowsNegotiateScheme(AuthSchemes.NTLM, servicePrincipalName);
}
 
@Override
public void authFailed(final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
    keychain.deleteCredentials(authhost.getHostName());
    super.authFailed(authhost, authScheme, context);
}
 
@Override
public AuthScheme create(final HttpContext context) {
    return new BackportWindowsNegotiateScheme(AuthSchemes.SPNEGO, servicePrincipalName);
}
 
源代码28 项目: lucene-solr   文件: PreemptiveAuth.java
public PreemptiveAuth(AuthScheme authScheme) {
  this.authScheme = authScheme;
}
 
源代码29 项目: Pushjet-Android   文件: NTLMSchemeFactory.java
public AuthScheme newInstance(HttpParams params) {
    return new NTLMScheme(new JCIFSEngine());
}
 
源代码30 项目: Pushjet-Android   文件: NTLMSchemeFactory.java
public AuthScheme newInstance(HttpParams params) {
    return new NTLMScheme(new JCIFSEngine());
}
 
 类所在包
 同包方法