Java Code Examples for java.net.HttpCookie#getName()
The following examples show how to use
java.net.HttpCookie#getName() .
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: CommonToHttpServletRequest.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
private Cookie[] createCookies() { List<String> strCookies = httpHeaders.get(HttpHeaders.COOKIE); if (strCookies == null) { return new Cookie[] {}; } List<Cookie> result = new ArrayList<>(); for (String strCookie : strCookies) { List<HttpCookie> httpCookies = HttpCookie.parse(strCookie); for (HttpCookie httpCookie : httpCookies) { Cookie cookie = new Cookie(httpCookie.getName(), httpCookie.getValue()); result.add(cookie); } } return result.toArray(new Cookie[result.size()]); }
Example 2
Source File: DBCookieStore.java From NoHttp with Apache License 2.0 | 6 votes |
@Override public boolean remove(URI uri, HttpCookie httpCookie) { checkInitialization(); mLock.lock(); try { if (httpCookie == null || !isEnable()) return true; if (mCookieStoreListener != null) mCookieStoreListener.onRemoveCookie(uri, httpCookie); Where where = new Where(CookieSQLHelper.NAME, Options.EQUAL, httpCookie.getName()); String domain = httpCookie.getDomain(); if (!TextUtils.isEmpty(domain)) where.and(CookieSQLHelper.DOMAIN, Options.EQUAL, domain); String path = httpCookie.getPath(); if (!TextUtils.isEmpty(path)) { if (path.length() > 1 && path.endsWith("/")) { path = path.substring(0, path.length() - 1); } where.and(CookieSQLHelper.PATH, Options.EQUAL, path); } return mCookieEntityDao.delete(where.toString()); } finally { mLock.unlock(); } }
Example 3
Source File: ZdsHttp.java From zest-writer with GNU General Public License v3.0 | 6 votes |
/** * 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 4
Source File: CookieEntity.java From NoHttp with Apache License 2.0 | 6 votes |
/** * Cookie building database entities. * * @param uri cookie corresponding uri. * @param cookie cookie. */ public CookieEntity(URI uri, HttpCookie cookie) { this.uri = uri == null ? null : uri.toString(); this.name = cookie.getName(); this.value = cookie.getValue(); this.comment = cookie.getComment(); this.commentURL = cookie.getCommentURL(); this.discard = cookie.getDiscard(); this.domain = cookie.getDomain(); long maxAge = cookie.getMaxAge(); if (maxAge != -1 && maxAge > 0) { this.expiry = (maxAge * 1000L) + System.currentTimeMillis(); if (this.expiry < 0L) // 溢出 this.expiry = HeaderUtils.getMaxExpiryMillis(); } else this.expiry = -1L; this.path = cookie.getPath(); if (!TextUtils.isEmpty(path) && path.length() > 1 && path.endsWith("/")) { this.path = path.substring(0, path.length() - 1); } this.portList = cookie.getPortlist(); this.secure = cookie.getSecure(); this.version = cookie.getVersion(); }
Example 5
Source File: CookiesUtils.java From XS2A-Sandbox with Apache License 2.0 | 6 votes |
public String resetCookies(List<String> cookieStrings) { String result = null; for (String cookieString : cookieStrings) { List<HttpCookie> parse = HttpCookie.parse(cookieString); for (HttpCookie httpCookie : parse) { if(StringUtils.isNoneBlank(httpCookie.getValue())) { String cookie = httpCookie.getName()+"="+httpCookie.getValue(); if(result==null) { result = cookie; } else { result = result + " ; " + cookie; } } } } return result; }
Example 6
Source File: ApiProxyServlet.java From onboard with Apache License 2.0 | 6 votes |
/** * Copy cookie from the proxy to the servlet client. Replaces cookie path to local path and renames cookie to avoid * collisions. */ protected void copyProxyCookie(HttpServletRequest servletRequest, HttpServletResponse servletResponse, Header header) { List<HttpCookie> cookies = HttpCookie.parse(header.getValue()); String path = getServletContext().getServletContextName(); if (path == null) { path = ""; } path += servletRequest.getServletPath(); for (HttpCookie cookie : cookies) { // set cookie name prefixed w/ a proxy value so it won't collide w/ other cookies String proxyCookieName = getCookieNamePrefix() + cookie.getName(); Cookie servletCookie = new Cookie(proxyCookieName, cookie.getValue()); servletCookie.setComment(cookie.getComment()); servletCookie.setMaxAge((int) cookie.getMaxAge()); servletCookie.setPath(path); // set to the path of the proxy servlet // don't set cookie domain servletCookie.setSecure(cookie.getSecure()); servletCookie.setVersion(cookie.getVersion()); servletResponse.addCookie(servletCookie); } }
Example 7
Source File: HttpProxy.java From haven-platform with Apache License 2.0 | 6 votes |
/** * Copy cookie from the proxy to the servlet client. * Replaces cookie path to local path and renames cookie to avoid collisions. */ private void copyProxyCookie(HttpServletRequest servletRequest, HttpServletResponse servletResponse, Header header) { List<HttpCookie> cookies = HttpCookie.parse(header.getValue()); String path = servletRequest.getContextPath(); // path starts with / or is empty string path += servletRequest.getServletPath(); // servlet path starts with / or is empty string for (int i = 0, l = cookies.size(); i < l; i++) { HttpCookie cookie = cookies.get(i); //set cookie name prefixed w/ a proxy value so it won't collide w/ other cookies String proxyCookieName = getCookieNamePrefix() + cookie.getName(); Cookie servletCookie = new Cookie(proxyCookieName, cookie.getValue()); servletCookie.setComment(cookie.getComment()); servletCookie.setMaxAge((int) cookie.getMaxAge()); servletCookie.setPath(path); //set to the path of the proxy servlet // don't set cookie domain servletCookie.setSecure(cookie.getSecure()); servletCookie.setVersion(cookie.getVersion()); servletResponse.addCookie(servletCookie); } }
Example 8
Source File: TransportableHttpCookie.java From Nimingban with Apache License 2.0 | 6 votes |
public static List<TransportableHttpCookie> from(URL url, List<HttpCookieWithId> list) { List<TransportableHttpCookie> result = new ArrayList<>(list.size()); for (HttpCookieWithId hcwi : list) { HttpCookie cookie = hcwi.httpCookie; TransportableHttpCookie thc = new TransportableHttpCookie(); thc.name = cookie.getName(); thc.value = cookie.getValue(); thc.comment = cookie.getComment(); thc.commentURL = cookie.getCommentURL(); thc.discard = cookie.getDiscard(); thc.domain = cookie.getDomain(); thc.maxAge = cookie.getMaxAge(); thc.path = cookie.getPath(); thc.portList = cookie.getPortlist(); thc.secure = cookie.getSecure(); thc.version = cookie.getVersion(); thc.url = url.toString(); result.add(thc); } return result; }
Example 9
Source File: KafkaWebSocketCreator.java From opensoc-streaming with Apache License 2.0 | 5 votes |
@Override public Object createWebSocket(ServletUpgradeRequest request, ServletUpgradeResponse response) { boolean authGood = false; List<HttpCookie> cookies = request.getCookies(); for( HttpCookie cookie : cookies ) { String name = cookie.getName(); if( name!= null && name.equals( "authToken" )) { String value = cookie.getValue(); try { if( value != null && AuthToken.validateToken(configProps, value)) { authGood = true; break; } } catch( Exception e ) { logger.error(" Exception validating authToken:", e ); authGood = false; break; } } else { continue; } } return new KafkaMessageSenderSocket( configProps, authGood ); }
Example 10
Source File: CookieAdapter.java From SimpleProject with MIT License | 5 votes |
public CookieAdapter(HttpCookie cookie) { this.name = cookie.getName(); this.value = cookie.getValue(); this.domain = cookie.getDomain(); this.path = cookie.getPath(); this.secure = cookie.getSecure(); }
Example 11
Source File: ServerCookieHelper.java From rawhttp with Apache License 2.0 | 5 votes |
/** * Compute the value of the "Set-Cookie" header to represent the given cookie, * with an optional {@link SameSite} attribute and extension. * * @param cookie the cookie * @param sameSite attribute for the cookie (given separately as {@link HttpCookie} does not currently * support it * @param extension cookie extension * @return the value of the "Set-Cookie" header */ public static String setCookieHeaderValue(HttpCookie cookie, @Nullable SameSite sameSite, @Nullable Object extension) { StringBuilder builder = new StringBuilder(cookie.getName()); builder.append("=\"").append(cookie.getValue()).append('"'); List<String> attributes = attributesForSetCookie(cookie, sameSite, extension); for (String attribute : attributes) { builder.append("; ").append(attribute); } return builder.toString(); }
Example 12
Source File: NonBlockingCookieStore.java From http-builder-ng with Apache License 2.0 | 4 votes |
public UriKey(final URI uri, final HttpCookie cookie) { super(cookie.getName()); this.host = forStorage(uri.getHost()); }
Example 13
Source File: PersistentCookieStore.java From AndroidStudyDemo with GNU General Public License v2.0 | 4 votes |
protected String getCookieToken(URI uri, HttpCookie cookie) { return cookie.getName() + cookie.getDomain(); }
Example 14
Source File: NonBlockingCookieStore.java From http-builder-ng with Apache License 2.0 | 4 votes |
public DomainKey(final HttpCookie cookie) { super(cookie.getName()); this.domain = cookie.getDomain(); this.path = cookie.getPath(); }
Example 15
Source File: PersistentCookieStore.java From mattermost-android-classic with Apache License 2.0 | 4 votes |
protected String getCookieToken(URI uri, HttpCookie cookie) { return cookie.getName() + cookie.getDomain(); }
Example 16
Source File: PersistentCookieStore.java From NewsMe with Apache License 2.0 | 4 votes |
protected String getCookieToken(URI uri, HttpCookie cookie) { return cookie.getName() + cookie.getDomain(); }
Example 17
Source File: PersistentCookieStore.java From FimiX8-RE with MIT License | 4 votes |
public String getCookieToken(URI uri, HttpCookie cookie) { return cookie.getName() + cookie.getDomain(); }