Java Code Examples for org.apache.http.impl.cookie.BasicClientCookie#setComment()

The following examples show how to use org.apache.http.impl.cookie.BasicClientCookie#setComment() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZdsHttp.java    From zest-writer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Authentication with google account
 * @param cookies cookies list keys from google auth
 * @param login username associated to zds login
 * @param id user id on ZdS associated to login
 */
public void authToGoogle(List<HttpCookie> cookies, String login, String id) {
    if(login != null && id != null) {
        this.login = login;
        this.idUser = id;
        log.info("L'identifiant de l'utilisateur " + this.login + " est : " + idUser);
        cookieStore = new BasicCookieStore();
        for(HttpCookie cookie:cookies) {
            BasicClientCookie c = new BasicClientCookie(cookie.getName(), cookie.getValue());
            c.setDomain(cookie.getDomain());
            c.setPath(cookie.getPath());
            c.setSecure(cookie.getSecure());
            c.setVersion(cookie.getVersion());
            c.setComment(cookie.getComment());
            cookieStore.addCookie(c);
        }
        context.setCookieStore(cookieStore);
        this.authenticated = true;
    }
    else {
        log.debug("Le login de l'utilisateur n'a pas pu être trouvé");
    }
}
 
Example 2
Source File: PreferencesCookieStore.java    From Android-Basics-Codes with Artistic License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String)in.readObject();
    String value = (String)in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String)in.readObject());
    clientCookie.setDomain((String)in.readObject());
    clientCookie.setExpiryDate((Date)in.readObject());
    clientCookie.setPath((String)in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
Example 3
Source File: SerializableCookie.java    From Roid-Library with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
Example 4
Source File: PreferencesCookieStore.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
Example 5
Source File: SerializableCookie.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException,
        ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
Example 6
Source File: SerializableCookie.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException,
		ClassNotFoundException {
	String name = (String) in.readObject();
	String value = (String) in.readObject();
	clientCookie = new BasicClientCookie(name, value);
	clientCookie.setComment((String) in.readObject());
	clientCookie.setDomain((String) in.readObject());
	clientCookie.setExpiryDate((Date) in.readObject());
	clientCookie.setPath((String) in.readObject());
	clientCookie.setVersion(in.readInt());
	clientCookie.setSecure(in.readBoolean());
}
 
Example 7
Source File: SerializableCookie.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream objectinputstream)
{
    b = new BasicClientCookie((String)objectinputstream.readObject(), (String)objectinputstream.readObject());
    b.setComment((String)objectinputstream.readObject());
    b.setDomain((String)objectinputstream.readObject());
    b.setExpiryDate((Date)objectinputstream.readObject());
    b.setPath((String)objectinputstream.readObject());
    b.setVersion(objectinputstream.readInt());
    b.setSecure(objectinputstream.readBoolean());
}
 
Example 8
Source File: SerializableCookie.java    From Android-Basics-Codes with Artistic License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
Example 9
Source File: SerializableCookie.java    From Android-Basics-Codes with Artistic License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
Example 10
Source File: MyCookieDBManager.java    From Huochexing12306 with Apache License 2.0 5 votes vote down vote up
public List<Cookie> getAllCookies() {
	List<Cookie> cookies = new ArrayList<Cookie>();

	Cursor cursor = db
			.query(TABLE_NAME, null, null, null, null, null, null);

	for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
		String name = cursor.getString(cursor.getColumnIndex(Column.NAME));
		String value = cursor
				.getString(cursor.getColumnIndex(Column.VALUE));

		BasicClientCookie cookie = new BasicClientCookie(name, value);

		cookie.setComment(cursor.getString(cursor
				.getColumnIndex(Column.COMMENT)));
		cookie.setDomain(cursor.getString(cursor
				.getColumnIndex(Column.DOMAIN)));
		long expireTime = cursor.getLong(cursor
				.getColumnIndex(Column.EXPIRY_DATE));
		if (expireTime != 0) {
			cookie.setExpiryDate(new Date(expireTime));
		}
		cookie.setPath(cursor.getString(cursor.getColumnIndex(Column.PATH)));
		cookie.setSecure(cursor.getInt(cursor.getColumnIndex(Column.SECURE)) == 1);
		cookie.setVersion(cursor.getInt(cursor
				.getColumnIndex(Column.VERSION)));

		cookies.add(cookie);
	}

	cursor.close();

	return cookies;
}
 
Example 11
Source File: SerializableCookie.java    From Libraries-for-Android-Developers with MIT License 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
Example 12
Source File: SerializableCookie.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException,
        ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
Example 13
Source File: SerializableCookie.java    From android-project-wo2b with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
Example 14
Source File: SerializableCookie.java    From sealtalk-android with MIT License 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
Example 15
Source File: PreferencesCookieStore.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
Example 16
Source File: SerializableCookie.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
Example 17
Source File: SerializableCookie.java    From AndroidWear-OpenWear with MIT License 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String key = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(key, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
Example 18
Source File: SerializableCookie.java    From Mobike with Apache License 2.0 5 votes vote down vote up
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
Example 19
Source File: RequestParser.java    From Lanmitm with GNU General Public License v2.0 4 votes vote down vote up
public static ArrayList<BasicClientCookie> parseRawCookie(String rawCookie) {
	String[] rawCookieParams = rawCookie.split(";");
	ArrayList<BasicClientCookie> cookies = new ArrayList<BasicClientCookie>();

	for (String rawCookieParam : rawCookieParams) {
		String[] rawCookieNameAndValue = rawCookieParam.split("=");

		if (rawCookieNameAndValue.length != 2)
			continue;

		String cookieName = rawCookieNameAndValue[0].trim();
		String cookieValue = rawCookieNameAndValue[1].trim();
		BasicClientCookie cookie = new BasicClientCookie(cookieName,
				cookieValue);

		for (int i = 1; i < rawCookieParams.length; i++) {
			String rawCookieParamNameAndValue[] = rawCookieParams[i].trim()
					.split("=");
			String paramName = rawCookieParamNameAndValue[0].trim();

			if (paramName.equalsIgnoreCase("secure"))
				cookie.setSecure(true);

			else {
				// attribute not a flag or missing value.
				if (rawCookieParamNameAndValue.length == 2) {
					String paramValue = rawCookieParamNameAndValue[1]
							.trim();
					if (paramName.equalsIgnoreCase("max-age")) {
						long maxAge = Long.parseLong(paramValue);
						Date expiryDate = new Date(
								java.lang.System.currentTimeMillis()
										+ maxAge);
						cookie.setExpiryDate(expiryDate);
					} else if (paramName.equalsIgnoreCase("domain"))
						cookie.setDomain(paramValue);
					else if (paramName.equalsIgnoreCase("path"))
						cookie.setPath(paramValue);
					else if (paramName.equalsIgnoreCase("comment"))
						cookie.setComment(paramValue);
				}
			}
		}
		cookies.add(cookie);
	}
	return cookies;
}
 
Example 20
Source File: DefaultCookieManager.java    From esigate with Apache License 2.0 4 votes vote down vote up
protected static Cookie rewriteForBrowser(Cookie cookie, DriverRequest request) {
    String name = cookie.getName();
    // Rewrite name if JSESSIONID because it will interfere with current
    // server session
    if ("JSESSIONID".equalsIgnoreCase(name)) {
        name = "_" + name;
    }

    // Rewrite domain
    String domain =
            rewriteDomain(cookie.getDomain(), request.getBaseUrl().getHost(),
                    UriUtils.extractHostName(request.getOriginalRequest().getRequestLine().getUri()));

    // Rewrite path
    String originalPath = cookie.getPath();
    String requestPath = UriUtils.getPath(request.getOriginalRequest().getRequestLine().getUri());
    String path = originalPath;
    if (requestPath == null || !requestPath.startsWith(originalPath)) {
        path = "/";
    }

    // Rewrite secure
    boolean secure =
            (cookie.isSecure() && request.getOriginalRequest().getRequestLine().getUri().startsWith("https"));

    BasicClientCookie cookieToForward = new BasicClientCookie(name, cookie.getValue());
    if (domain != null) {
        cookieToForward.setDomain(domain);
    }
    cookieToForward.setPath(path);
    cookieToForward.setSecure(secure);
    cookieToForward.setComment(cookie.getComment());
    cookieToForward.setVersion(cookie.getVersion());
    cookieToForward.setExpiryDate(cookie.getExpiryDate());

    if (((BasicClientCookie) cookie).containsAttribute(CookieUtil.HTTP_ONLY_ATTR)) {
        cookieToForward.setAttribute(CookieUtil.HTTP_ONLY_ATTR, "");
    }

    if (LOG.isDebugEnabled()) {
        // Ensure .toString is only called if debug enabled.
        LOG.debug("Forwarding cookie {} -> {}", cookie.toString(), cookieToForward.toString());
    }
    return cookieToForward;
}