: state.getCredentials(realm, host); if (credentials == null) { StringBuffer buffer = new StringBuffer();
? state.getProxyCredentials(null, host) : state.getCredentials(null, host); if (credentials == null) { return false;
Credentials credentials = this.state.getCredentials(authscope); if (credentials == null) { credentials = promptForCredentials(
LOG.debug("Authenticating with " + authscope); Credentials credentials = this.state.getCredentials(authscope); if (credentials != null) { String authstring = authscheme.authenticate(credentials, method);
public UsernamePasswordCredentials getDefaultCredentials() { return (UsernamePasswordCredentials) this.httpClient.getState().getCredentials(AuthScope.ANY); }
/** * Retrieve the username and password previously set by setUsernameAndPassword. * * @return An array of two Strings. The first element is the username (or null) * and the second element is the password (or null). */ public String[] getUsernameAndPassword() { String[] res = new String[2]; // WARNING: The call to getCredentials will throw an IllegalArgumentException of credentials have not previously // been set with a call to setUsernameAndPassword UsernamePasswordCredentials cred = (UsernamePasswordCredentials) httpClient.getState().getCredentials(authScope); res[0] = cred.getUserName(); res[1] = cred.getPassword(); return res; }
/** * Enable NTLM authentication on http client * * @param httpClient HttpClient instance */ public static void addNTLM(HttpClient httpClient) { // disable preemptive authentication httpClient.getParams().setParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, false); // register the jcifs based NTLMv2 implementation AuthPolicy.registerAuthScheme(AuthPolicy.NTLM, NTLMv2Scheme.class); ArrayList<String> authPrefs = new ArrayList<String>(); authPrefs.add(AuthPolicy.NTLM); authPrefs.add(AuthPolicy.DIGEST); authPrefs.add(AuthPolicy.BASIC); httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); // make sure NTLM is always active needNTLM = true; // separate domain from username in credentials AuthScope authScope = new AuthScope(null, -1); NTCredentials credentials = (NTCredentials) httpClient.getState().getCredentials(authScope); if (credentials != null && credentials.getDomain() == null) { setCredentials(httpClient, credentials.getUserName(), credentials.getPassword()); } }
public void processRequest(HttpMethod method) { DigestScheme scheme = digestScheme; if (scheme != null) { if (DEBUG_AUTH) { System.err.println(location.getUrl() + ": Digest scheme is present"); //$NON-NLS-1$ } Credentials creds = httpClient.getState().getCredentials(authScope); if (creds != null) { if (DEBUG_AUTH) { System.err.println(location.getUrl() + ": Setting digest scheme for request"); //$NON-NLS-1$ } method.getHostAuthState().setAuthScheme(digestScheme); method.getHostAuthState().setAuthRequested(true); } } }
/** * Builds the HTTP GET method used to fetch the metadata. The returned method advertises support for GZIP and * deflate compression, enables conditional GETs if the cached metadata came with either an ETag or Last-Modified * information, and sets up basic authentication if such is configured. * * @return the constructed GET method */ protected GetMethod buildGetMethod() { GetMethod getMethod = new GetMethod(getMetadataURI()); getMethod.addRequestHeader("Connection", "close"); getMethod.setRequestHeader("Accept-Encoding", "gzip,deflate"); if (cachedMetadataETag != null) { getMethod.setRequestHeader("If-None-Match", cachedMetadataETag); } if (cachedMetadataLastModified != null) { getMethod.setRequestHeader("If-Modified-Since", cachedMetadataLastModified); } if (httpClient.getState().getCredentials(authScope) != null) { log.debug("Using BASIC authentication when retrieving metadata from '{}", metadataURI); getMethod.setDoAuthentication(true); } return getMethod; }
? state.getProxyCredentials(null, host) : state.getCredentials(null, host); if (credentials == null) { return false;
protected final void setDoAuthentication(HttpMethod method) { if (authScope != null && httpClient.getState().getCredentials(authScope) != null) { method.setDoAuthentication(true); } else { //method.setDoAuthentication(false); } if (masqueradeAsUser != null) { method.addRequestHeader(new Header("x-masquerade-as-user", masqueradeAsUser)); } // TODO probably doesn't belong here, need another method that // HttpMethod objects pass through. method.addRequestHeader(new Header("Connection", "keep-alive")); }
Credentials credentials = this.state.getCredentials(authscope); if (credentials == null) { credentials = promptForCredentials(
? state.getProxyCredentials(null, host) : state.getCredentials(null, host); if (credentials == null) { return false;
? state.getProxyCredentials(null, host) : state.getCredentials(null, host); if (credentials == null) { return false;
? state.getProxyCredentials(null, host) : state.getCredentials(null, host); if (credentials == null) { return false;
LOG.debug("Authenticating with " + authscope); Credentials credentials = this.state.getCredentials(authscope); if (credentials != null) { String authstring = authscheme.authenticate(credentials, method);
LOG.debug("Authenticating with " + authscope); Credentials credentials = this.state.getCredentials(authscope); if (credentials != null) { String authstring = authscheme.authenticate(credentials, method);
HostConfiguration hostConfig = client.getHostConfiguration(); Credentials creds = client.getState().getCredentials(null, hostConfig.getHost()); String userName = null; String password = null;
LOG.debug("Authenticating with " + authscope); Credentials credentials = this.state.getCredentials(authscope); if (credentials != null) { String authstring = authscheme.authenticate(credentials, method);
LOG.debug("Authenticating with " + authscope); Credentials credentials = this.state.getCredentials(authscope); if (credentials != null) { String authstring = authscheme.authenticate(credentials, method);