List of usage examples for org.apache.commons.httpclient HttpState clearCredentials
public void clearCredentials()
From source file:org.apache.jmeter.protocol.http.sampler.HTTPHC3Impl.java
/** * Extracts all the required authorization for that particular URL request * and sets it in the <code>HttpMethod</code> passed in. * * @param client the HttpClient object//from w w w . j a v a 2 s .c o m * * @param u * <code>URL</code> of the URL request * @param authManager * the <code>AuthManager</code> containing all the authorisations for * this <code>UrlConfig</code> */ private void setConnectionAuthorization(HttpClient client, URL u, AuthManager authManager) { HttpState state = client.getState(); if (authManager != null) { HttpClientParams params = client.getParams(); Authorization auth = authManager.getAuthForURL(u); if (auth != null) { String username = auth.getUser(); String realm = auth.getRealm(); String domain = auth.getDomain(); if (log.isDebugEnabled()) { log.debug(username + " > D=" + username + " D=" + domain + " R=" + realm); } state.setCredentials(new AuthScope(u.getHost(), u.getPort(), realm.length() == 0 ? null : realm //"" is not the same as no realm , AuthScope.ANY_SCHEME), // NT Includes other types of Credentials new NTCredentials(username, auth.getPass(), localHost, domain)); // We have credentials - should we set pre-emptive authentication? if (canSetPreEmptive) { log.debug("Setting Pre-emptive authentication"); params.setAuthenticationPreemptive(true); } } else { state.clearCredentials(); if (canSetPreEmptive) { params.setAuthenticationPreemptive(false); } } } else { state.clearCredentials(); } }
From source file:org.exist.xquery.modules.httpclient.ClearFunction.java
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { if (isCalledAs("clear-all")) { context.setXQueryContextVar(HTTP_MODULE_PERSISTENT_STATE, null); } else {/* w w w . j a va 2 s. c o m*/ HttpState state = (HttpState) context.getXQueryContextVar(HTTP_MODULE_PERSISTENT_STATE); if (state != null) { if (isCalledAs("clear-persistent-cookies")) { state.clearCookies(); } else if (isCalledAs("clear-persistent-credentials")) { state.clearCredentials(); } else if (isCalledAs("clear-persistent-proxy-credentials")) { state.clearProxyCredentials(); } } } return (Sequence.EMPTY_SEQUENCE); }