public Credentials getCredentials(AuthScheme scheme, String host, int port, boolean proxy) throws CredentialsNotAvailableException { if (Constants.SCHEME.equals(scheme.getSchemeName())) { if (signer == null) { throw new CredentialsNotAvailableException("SSHKey Signer not available"); } else { return new SignerCredentials(signer); } } else { if (this.delegatee != null) { return this.delegatee.getCredentials(scheme, host, port, proxy); } } return null; }
private void authenticateProxy(final HttpMethod method) throws AuthenticationException { // Clean up existing authentication headers if (!cleanAuthHeaders(method, PROXY_AUTH_RESP)) { // User defined authentication header(s) present return; } AuthState authstate = method.getProxyAuthState(); AuthScheme authscheme = authstate.getAuthScheme(); if (authscheme == null) { return; } if (authstate.isAuthRequested() || !authscheme.isConnectionBased()) { AuthScope authscope = new AuthScope( conn.getProxyHost(), conn.getProxyPort(), authscheme.getRealm(), authscheme.getSchemeName()); if (LOG.isDebugEnabled()) { LOG.debug("Authenticating with " + authscope); } Credentials credentials = this.state.getProxyCredentials(authscope); if (credentials != null) { String authstring = authscheme.authenticate(credentials, method); if (authstring != null) { method.addRequestHeader(new Header(PROXY_AUTH_RESP, authstring, true)); } } else { if (LOG.isWarnEnabled()) { LOG.warn("Required proxy credentials not available for " + authscope); if (method.getProxyAuthState().isPreemptive()) { LOG.warn("Preemptive authentication requested but no default " + "proxy credentials available"); } } } } }
private Credentials promptForCredentials( final AuthScheme authScheme, final HttpParams params, final AuthScope authscope) { LOG.debug("Credentials required"); Credentials creds = null; CredentialsProvider credProvider = (CredentialsProvider)params.getParameter(CredentialsProvider.PROVIDER); if (credProvider != null) { try { creds = credProvider.getCredentials( authScheme, authscope.getHost(), authscope.getPort(), false); } catch (CredentialsNotAvailableException e) { LOG.warn(e.getMessage()); } if (creds != null) { this.state.setCredentials(authscope, creds); if (LOG.isDebugEnabled()) { LOG.debug(authscope + " new credentials given"); } } } else { LOG.debug("Credentials provider not available"); } return creds; }
private Credentials promptForProxyCredentials( final AuthScheme authScheme, final HttpParams params, final AuthScope authscope) { LOG.debug("Proxy credentials required"); Credentials creds = null; CredentialsProvider credProvider = (CredentialsProvider)params.getParameter(CredentialsProvider.PROVIDER); if (credProvider != null) { try { creds = credProvider.getCredentials( authScheme, authscope.getHost(), authscope.getPort(), true); } catch (CredentialsNotAvailableException e) { LOG.warn(e.getMessage()); } if (creds != null) { this.state.setProxyCredentials(authscope, creds); if (LOG.isDebugEnabled()) { LOG.debug(authscope + " new credentials given"); } } } else { LOG.debug("Proxy credentials provider not available"); } return creds; }
public Credentials getCredentials(AuthScheme scheme, String host, int port, boolean proxy) throws CredentialsNotAvailableException { if (!proxy) { this.hostcount++; return provideCredentials(this.hostcount); } else { this.proxycount++; return provideCredentials(this.proxycount); } }
private void authenticateHost(final HttpMethod method) throws AuthenticationException { // Clean up existing authentication headers if (!cleanAuthHeaders(method, WWW_AUTH_RESP)) { // User defined authentication header(s) present return; } AuthState authstate = method.getHostAuthState(); AuthScheme authscheme = authstate.getAuthScheme(); if (authscheme == null) { return; } if (authstate.isAuthRequested() || !authscheme.isConnectionBased()) { String host = method.getParams().getVirtualHost(); if (host == null) { host = conn.getHost(); } int port = conn.getPort(); AuthScope authscope = new AuthScope( host, port, authscheme.getRealm(), authscheme.getSchemeName()); if (LOG.isDebugEnabled()) { LOG.debug("Authenticating with " + authscope); } Credentials credentials = this.state.getCredentials(authscope); if (credentials != null) { String authstring = authscheme.authenticate(credentials, method); if (authstring != null) { method.addRequestHeader(new Header(WWW_AUTH_RESP, authstring, true)); } } else { if (LOG.isWarnEnabled()) { LOG.warn("Required credentials not available for " + authscope); if (method.getHostAuthState().isPreemptive()) { LOG.warn("Preemptive authentication requested but no default " + "credentials available"); } } } } }