List of usage examples for org.apache.http.client.protocol ClientContext COOKIE_STORE
String COOKIE_STORE
To view the source code for org.apache.http.client.protocol ClientContext COOKIE_STORE.
Click Source Link
From source file:com.c0124.k9.mail.store.WebDavStore.java
public WebDavHttpClient getHttpClient() throws MessagingException { if (mHttpClient == null) { mHttpClient = new WebDavHttpClient(); // Disable automatic redirects on the http client. mHttpClient.getParams().setBooleanParameter("http.protocol.handle-redirects", false); // Setup a cookie store for forms-based authentication. mContext = new BasicHttpContext(); mAuthCookies = new BasicCookieStore(); mContext.setAttribute(ClientContext.COOKIE_STORE, mAuthCookies); SchemeRegistry reg = mHttpClient.getConnectionManager().getSchemeRegistry(); try {/* ww w . j av a 2 s . c o m*/ Scheme s = new Scheme("https", new WebDavSocketFactory(mHost, 443, mSecure), 443); reg.register(s); } catch (NoSuchAlgorithmException nsa) { Log.e(K9.LOG_TAG, "NoSuchAlgorithmException in getHttpClient: " + nsa); throw new MessagingException("NoSuchAlgorithmException in getHttpClient: " + nsa); } catch (KeyManagementException kme) { Log.e(K9.LOG_TAG, "KeyManagementException in getHttpClient: " + kme); throw new MessagingException("KeyManagementException in getHttpClient: " + kme); } } return mHttpClient; }
From source file:com.fsck.k9.mail.store.WebDavStore.java
public WebDavHttpClient getHttpClient() throws MessagingException { if (mHttpClient == null) { mHttpClient = new WebDavHttpClient(); // Disable automatic redirects on the http client. mHttpClient.getParams().setBooleanParameter("http.protocol.handle-redirects", false); // Setup a cookie store for forms-based authentication. mContext = new BasicHttpContext(); mAuthCookies = new BasicCookieStore(); mContext.setAttribute(ClientContext.COOKIE_STORE, mAuthCookies); SchemeRegistry reg = mHttpClient.getConnectionManager().getSchemeRegistry(); try {/* w ww.ja v a 2 s . c om*/ Scheme s = new Scheme("https", new TrustedSocketFactory(mHost, mSecure), 443); reg.register(s); } catch (NoSuchAlgorithmException nsa) { Log.e(K9.LOG_TAG, "NoSuchAlgorithmException in getHttpClient: " + nsa); throw new MessagingException("NoSuchAlgorithmException in getHttpClient: " + nsa); } catch (KeyManagementException kme) { Log.e(K9.LOG_TAG, "KeyManagementException in getHttpClient: " + kme); throw new MessagingException("KeyManagementException in getHttpClient: " + kme); } } return mHttpClient; }
From source file:com.jmv.frre.moduloestudiante.mail.store.WebDavStore.java
public WebDavHttpClient getHttpClient() throws MessagingException { if (mHttpClient == null) { mHttpClient = new WebDavHttpClient(); // Disable automatic redirects on the http client. mHttpClient.getParams().setBooleanParameter("http.protocol.handle-redirects", false); // Setup a cookie store for forms-based authentication. mContext = new BasicHttpContext(); mAuthCookies = new BasicCookieStore(); mContext.setAttribute(ClientContext.COOKIE_STORE, mAuthCookies); SchemeRegistry reg = mHttpClient.getConnectionManager().getSchemeRegistry(); try {/*from w ww . j av a 2s. c o m*/ Scheme s = new Scheme("https", new WebDavSocketFactory(mHost, mSecure), 443); reg.register(s); } catch (NoSuchAlgorithmException nsa) { Log.e(K9.LOG_TAG, "NoSuchAlgorithmException in getHttpClient: " + nsa); throw new MessagingException("NoSuchAlgorithmException in getHttpClient: " + nsa); } catch (KeyManagementException kme) { Log.e(K9.LOG_TAG, "KeyManagementException in getHttpClient: " + kme); throw new MessagingException("KeyManagementException in getHttpClient: " + kme); } } return mHttpClient; }
From source file:org.apache.http.impl.client.AbstractHttpClient.java
protected HttpContext createHttpContext() { final HttpContext context = new BasicHttpContext(); context.setAttribute(ClientContext.SCHEME_REGISTRY, getConnectionManager().getSchemeRegistry()); context.setAttribute(ClientContext.AUTHSCHEME_REGISTRY, getAuthSchemes()); context.setAttribute(ClientContext.COOKIESPEC_REGISTRY, getCookieSpecs()); context.setAttribute(ClientContext.COOKIE_STORE, getCookieStore()); context.setAttribute(ClientContext.CREDS_PROVIDER, getCredentialsProvider()); return context; }
From source file:org.apache.http.impl.client.AbstractStatisticsGatheringHttpClient.java
protected HttpContext createHttpContext() { HttpContext context = new BasicHttpContext(); context.setAttribute(ClientContext.SCHEME_REGISTRY, getConnectionManager().getSchemeRegistry()); context.setAttribute(ClientContext.AUTHSCHEME_REGISTRY, getAuthSchemes()); context.setAttribute(ClientContext.COOKIESPEC_REGISTRY, getCookieSpecs()); context.setAttribute(ClientContext.COOKIE_STORE, getCookieStore()); context.setAttribute(ClientContext.CREDS_PROVIDER, getCredentialsProvider()); return context; }
From source file:org.everit.authentication.http.form.ecm.tests.FormAuthenticationServletTestComponent.java
@Test @TestDuringDevelopment//from ww w. ja v a2s . c om public void testAccessHelloPage() throws Exception { CookieStore cookieStore = new BasicCookieStore(); HttpContext httpContext = new BasicHttpContext(); httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore); hello(httpContext, defaultResourceId); login(httpContext, USERNAME, WRONG_PASSWORD, loginFailedUrl); login(httpContext, USERNAME, PASSWORD, loginSuccessUrl); hello(httpContext, authenticatedResourceId); }
From source file:org.everit.osgi.authentication.http.form.tests.FormAuthenticationServletTestComponent.java
@Test public void testAccessHelloPage() throws Exception { CookieStore cookieStore = new BasicCookieStore(); HttpContext httpContext = new BasicHttpContext(); httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore); hello(httpContext, defaultResourceId); login(httpContext, USERNAME, WRONG_PASSWORD, loginFailedUrl); login(httpContext, USERNAME, PASSWORD, loginSuccessUrl); hello(httpContext, authenticatedResourceId); }
From source file:org.wso2.carbon.appmgt.impl.publishers.WSO2APIPublisher.java
/** * The method to publish WebApp to external WSO2 Store * @param api WebApp//from w w w .j a v a 2s . co m * @param store Store * @return published/not */ public boolean publishToStore(WebApp api, APIStore store) throws AppManagementException { boolean published = false; if (store.getEndpoint() == null || store.getUsername() == null || store.getPassword() == null) { String msg = "External APIStore endpoint URL or credentials are not defined.Cannot proceed with publishing WebApp to the APIStore - " + store.getDisplayName(); throw new AppManagementException(msg); } else { CookieStore cookieStore = new BasicCookieStore(); HttpContext httpContext = new BasicHttpContext(); httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore); boolean authenticated = authenticateAPIM(store, httpContext); if (authenticated) { //First try to login to store boolean added = addAPIToStore(api, store.getEndpoint(), store.getUsername(), httpContext); if (added) { //If WebApp creation success,then try publishing the WebApp published = publishAPIToStore(api.getId(), store.getEndpoint(), store.getUsername(), httpContext); } logoutFromExternalStore(store, httpContext); } } return published; }
From source file:org.wso2.carbon.appmgt.impl.publishers.WSO2APIPublisher.java
@Override public boolean deleteFromStore(APIIdentifier apiId, APIStore store) throws AppManagementException { boolean deleted = false; if (store.getEndpoint() == null || store.getUsername() == null || store.getPassword() == null) { String msg = "External APIStore endpoint URL or credentials are not defined.Cannot proceed with publishing WebApp to the APIStore - " + store.getDisplayName(); throw new AppManagementException(msg); } else {// w w w. ja v a 2 s .co m CookieStore cookieStore = new BasicCookieStore(); HttpContext httpContext = new BasicHttpContext(); httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore); boolean authenticated = authenticateAPIM(store, httpContext); if (authenticated) { deleted = deleteWSO2Store(apiId, store.getUsername(), store.getEndpoint(), httpContext); logoutFromExternalStore(store, httpContext); } return deleted; } }