List of usage examples for org.apache.commons.httpclient Cookie Cookie
public Cookie()
From source file:ir.keloud.android.lib.common.KeloudSamlSsoCredentials.java
@Override public void applyTo(KeloudClient client) { client.getParams().setAuthenticationPreemptive(false); client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); client.setFollowRedirects(false);/*from w w w .java2 s. c o m*/ Uri serverUri = client.getBaseUri(); String[] cookies = mSessionCookie.split(";"); if (cookies.length > 0) { Cookie cookie = null; for (int i = 0; i < cookies.length; i++) { int equalPos = cookies[i].indexOf('='); if (equalPos >= 0) { cookie = new Cookie(); cookie.setName(cookies[i].substring(0, equalPos)); cookie.setValue(cookies[i].substring(equalPos + 1)); cookie.setDomain(serverUri.getHost()); // VERY IMPORTANT cookie.setPath(serverUri.getPath()); // VERY IMPORTANT client.getState().addCookie(cookie); } } } }
From source file:com.cerema.cloud2.lib.common.OwnCloudSamlSsoCredentials.java
@Override public void applyTo(OwnCloudClient client) { client.getParams().setAuthenticationPreemptive(false); client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); client.setFollowRedirects(false);/*from w w w. ja v a 2 s .c o m*/ Uri serverUri = client.getBaseUri(); String[] cookies = mSessionCookie.split(";"); if (cookies.length > 0) { Cookie cookie = null; for (int i = 0; i < cookies.length; i++) { int equalPos = cookies[i].indexOf('='); if (equalPos >= 0) { cookie = new Cookie(); cookie.setName(cookies[i].substring(0, equalPos)); cookie.setValue(cookies[i].substring(equalPos + 1)); cookie.setDomain(serverUri.getHost()); // VERY IMPORTANT cookie.setPath(serverUri.getPath()); // VERY IMPORTANT client.getState().addCookie(cookie); } } } }
From source file:com.intuit.tank.http.BaseResponseTest.java
/** * Run the String getCookie(String) method test. * /* w w w . j a v a2s.co m*/ * @throws Exception * * @generatedBy CodePro at 12/16/14 3:57 PM */ @Test public void testGetCookie_1() throws Exception { BinaryResponse fixture = new BinaryResponse(); fixture.responseTime = 1L; fixture.cookiesByDomain = new HashMap(); fixture.httpCode = 1; fixture.response = ""; fixture.responseByteArray = new byte[] {}; fixture.cookies = new Cookie[] { new Cookie() }; fixture.rspMessage = ""; fixture.headers = new HashMap(); fixture.responseLogMsg = ""; String key = ""; String result = fixture.getCookie(key); }
From source file:com.gs.jrpip.client.FastServletProxyFactory.java
private Cookie createCookieFromToken(String token, String path, String domain) { Cookie cookie = new Cookie(); cookie.setPath(path);// w ww .ja v a 2s.c o m cookie.setDomain(domain); cookie.setName(token.substring(0, token.indexOf('='))); cookie.setValue(token.substring(token.indexOf('=') + 1)); return cookie; }
From source file:ir.keloud.android.lib.common.accounts.AccountUtils.java
/** * Restore the client cookies/*from www . j av a2 s . c o m*/ * @param account * @param client * @param context */ public static void restoreCookies(Account account, KeloudClient client, Context context) { Log_OC.d(TAG, "Restoring cookies for " + account.name); // Account Manager AccountManager am = AccountManager.get(context.getApplicationContext()); Uri serverUri = (client.getBaseUri() != null) ? client.getBaseUri() : client.getWebdavUri(); String cookiesString = am.getUserData(account, Constants.KEY_COOKIES); if (cookiesString != null) { String[] cookies = cookiesString.split(";"); if (cookies.length > 0) { for (int i = 0; i < cookies.length; i++) { Cookie cookie = new Cookie(); int equalPos = cookies[i].indexOf('='); cookie.setName(cookies[i].substring(0, equalPos)); cookie.setValue(cookies[i].substring(equalPos + 1)); cookie.setDomain(serverUri.getHost()); // VERY IMPORTANT cookie.setPath(serverUri.getPath()); // VERY IMPORTANT client.getState().addCookie(cookie); } } } }
From source file:com.cerema.cloud2.lib.common.accounts.AccountUtils.java
/** * Restore the client cookies/*w ww. j a v a 2s . c om*/ * @param account * @param client * @param context */ public static void restoreCookies(Account account, OwnCloudClient client, Context context) { Log_OC.d(TAG, "Restoring cookies for " + account.name); // Account Manager AccountManager am = AccountManager.get(context.getApplicationContext()); Uri serverUri = (client.getBaseUri() != null) ? client.getBaseUri() : client.getWebdavUri(); String cookiesString = am.getUserData(account, Constants.KEY_COOKIES); if (cookiesString != null) { String[] cookies = cookiesString.split(";"); if (cookies.length > 0) { for (int i = 0; i < cookies.length; i++) { Cookie cookie = new Cookie(); int equalPos = cookies[i].indexOf('='); cookie.setName(cookies[i].substring(0, equalPos)); cookie.setValue(cookies[i].substring(equalPos + 1)); cookie.setDomain(serverUri.getHost()); // VERY IMPORTANT cookie.setPath(serverUri.getPath()); // VERY IMPORTANT client.getState().addCookie(cookie); } } } }
From source file:com.intuit.tank.http.BaseResponseTest.java
/** * Run the void logResponse() method test. * /*from www . java 2s . c o m*/ * @throws Exception * * @generatedBy CodePro at 12/16/14 3:57 PM */ @Test public void testLogResponse_1() throws Exception { BinaryResponse fixture = new BinaryResponse(); fixture.responseTime = 1L; fixture.cookiesByDomain = new HashMap(); fixture.httpCode = 1; fixture.response = ""; fixture.responseByteArray = new byte[] {}; fixture.cookies = new Cookie[] { new Cookie() }; fixture.rspMessage = ""; fixture.headers = new HashMap(); fixture.responseLogMsg = ""; fixture.logResponse(); // An unexpected exception was thrown in user code while executing this test: // java.lang.NoClassDefFoundError: Could not initialize class com.intuit.tank.http.binary.BinaryResponse }
From source file:com.intuit.tank.http.BaseResponseTest.java
/** * Run the void logResponse() method test. * /*from w w w. j av a 2 s . c o m*/ * @throws Exception * * @generatedBy CodePro at 12/16/14 3:57 PM */ @Test public void testLogResponse_3() throws Exception { BinaryResponse fixture = new BinaryResponse(); fixture.responseTime = 1L; fixture.cookiesByDomain = new HashMap(); fixture.httpCode = 1; fixture.response = ""; fixture.responseByteArray = new byte[] {}; fixture.cookies = new Cookie[] { new Cookie() }; fixture.rspMessage = ""; fixture.headers = new HashMap(); fixture.responseLogMsg = ""; fixture.logResponse(); // An unexpected exception was thrown in user code while executing this test: // java.lang.NoClassDefFoundError: Could not initialize class com.intuit.tank.http.binary.BinaryResponse }
From source file:com.intuit.tank.http.BaseResponseTest.java
/** * Run the void logResponse() method test. * //w w w . ja v a 2s . co m * @throws Exception * * @generatedBy CodePro at 12/16/14 3:57 PM */ @Test public void testLogResponse_4() throws Exception { BinaryResponse fixture = new BinaryResponse(); fixture.responseTime = 1L; fixture.cookiesByDomain = new HashMap(); fixture.httpCode = 1; fixture.response = ""; fixture.responseByteArray = new byte[] {}; fixture.cookies = new Cookie[] { new Cookie() }; fixture.rspMessage = ""; fixture.headers = new HashMap(); fixture.responseLogMsg = ""; fixture.logResponse(); // An unexpected exception was thrown in user code while executing this test: // java.lang.NoClassDefFoundError: Could not initialize class com.intuit.tank.http.binary.BinaryResponse }
From source file:com.intuit.tank.http.BaseResponseTest.java
/** * Run the void logResponse() method test. * //w w w. j ava 2 s .co m * @throws Exception * * @generatedBy CodePro at 12/16/14 3:57 PM */ @Test public void testLogResponse_7() throws Exception { BinaryResponse fixture = new BinaryResponse(); fixture.responseTime = 1L; fixture.cookiesByDomain = new HashMap(); fixture.httpCode = 1; fixture.response = ""; fixture.responseByteArray = new byte[] {}; fixture.cookies = new Cookie[] { new Cookie() }; fixture.rspMessage = ""; fixture.headers = new HashMap(); fixture.responseLogMsg = ""; fixture.logResponse(); // An unexpected exception was thrown in user code while executing this test: // java.lang.NoClassDefFoundError: Could not initialize class com.intuit.tank.http.binary.BinaryResponse }