static AuthScope uriToAuthScope(String surl) throws HTTPException { try { URI uri = HTTPUtil.parseToURI(surl); return uriToAuthScope(uri); } catch (URISyntaxException e) { throw new HTTPException(e); } }
protected boolean sessionCompatible(URI otheruri) { AuthScope other = HTTPAuthUtil.uriToAuthScope(otheruri); return sessionCompatible(other); }
static public void setGlobalCredentials(AuthScope scope, Credentials creds) { CredentialsProvider provider = new HTTPConstantProvider(creds); setGlobalCredentialsProvider(scope, provider); }
static public String getUrlAsString(String url) throws HTTPException { try ( HTTPSession session = HTTPFactory.newSession(url); HTTPMethod m = HTTPFactory.Get(session);) { int status = m.execute(); String content = null; if(status == 200) { content = m.getResponseAsString(); } return content; } }
static String getUrlAsString(String url) throws HTTPException { try ( HTTPMethod m = HTTPFactory.Get(url);) { int status = m.execute(); String content = null; if(status == 200) { content = m.getResponseAsString(); } return content; } }
static synchronized public void setGlobalCompression() { globalsettings.setParameter(COMPRESSION, "gzip,deflate"); HttpResponseInterceptor hrsi = new GZIPResponseInterceptor(); rspintercepts.add(hrsi); hrsi = new DeflateResponseInterceptor(); rspintercepts.add(hrsi); }
public void setCredentials(String scheme, Credentials creds) { CredentialsProvider provider = new HTTPConstantProvider(creds); setCredentialsProvider(scheme, provider); }
static public void setGlobalCredentialsProvider(CredentialsProvider provider) { defineCredentialsProvider(ANY_PRINCIPAL, HTTPAuthScope.ANY, provider, HTTPAuthStore.getDefault()); }
static final void buildsslfactory(AuthControls authcontrols) { KeyStore keystore = (KeyStore) authcontrols.get(AuthProp.KEYSTORE); String keypass = (String) authcontrols.get(AuthProp.KEYPASSWORD); KeyStore truststore = (KeyStore) authcontrols.get(AuthProp.TRUSTSTORE); buildsslfactory(authcontrols, truststore, keystore, keypass); }
HTTPSession(HttpHost httphost) throws HTTPException { init(HTTPAuthUtil.hostToAuthScope(httphost), null); }
HTTPSession(String uri) throws HTTPException { init(HTTPAuthUtil.uriToAuthScope(uri), uri); }
static synchronized public void setGlobalProxy(String host, int port) { Proxy proxy = new Proxy(); proxy.host = host; proxy.port = port; globalsettings.setParameter(PROXY, proxy); }
/** * @param scope * @param provider * @return old provider if entry already existed and was replaced, else null. */ synchronized public CredentialsProvider insert(String principal, AuthScope scope, CredentialsProvider provider) throws HTTPException { return insert(new Entry(principal, scope, provider)); }
/** * Test that the given url is "compatible" with the * session specified dataset. Wrapper around * HTTPAuthUtil.httphostCompatible(). * * @param other to test for compatibility against this method's * @return true if compatible, false otherwise. */ protected boolean sessionCompatible(AuthScope other) { return HTTPAuthUtil.authscopeCompatible(session.getAuthScope(), other); }
public HTTPMethod setMaxRedirects(int n) { this.session.setMaxRedirects(n); return this; }
public HTTPMethod setFollowRedirects(boolean tf) { this.session.setFollowRedirects(tf); return this; }
static void setDefaults(Settings props) { if(false) {// turn off for now props.setParameter(HANDLE_REDIRECTS, Boolean.TRUE); props.setParameter(HANDLE_AUTHENTICATION, Boolean.TRUE); } props.setParameter(ALLOW_CIRCULAR_REDIRECTS, Boolean.TRUE); props.setParameter(MAX_REDIRECTS, (Integer) DFALTREDIRECTS); props.setParameter(SO_TIMEOUT, (Integer) DFALTSOTIMEOUT); props.setParameter(CONN_TIMEOUT, (Integer) DFALTCONNTIMEOUT); props.setParameter(USER_AGENT, DFALTUSERAGENT); }
public void setCredentialsProvider(AuthScope scope, CredentialsProvider provider) { defineCredentialsProvider(ANY_PRINCIPAL, scope, provider, this.authlocal); }
static public void setGlobalCredentialsProvider(AuthScope scope, CredentialsProvider provider) { defineCredentialsProvider(ANY_PRINCIPAL, scope, provider, HTTPAuthStore.getDefault()); }