Example usage for javax.servlet.http Cookie getName

List of usage examples for javax.servlet.http Cookie getName

Introduction

In this page you can find the example usage for javax.servlet.http Cookie getName.

Prototype

public String getName() 

Source Link

Document

Returns the name of the cookie.

Usage

From source file:io.syndesis.credential.CredentialFlowStateHelper.java

static javax.ws.rs.core.Cookie toJaxRsCookie(final Cookie cookie) {
    return new javax.ws.rs.core.Cookie(cookie.getName(), cookie.getValue(), cookie.getPath(),
            cookie.getDomain());/*from ww  w .j  a v  a 2  s. c  o  m*/
}

From source file:com.woonoz.proxy.servlet.CookieFormatter.java

public static CookieFormatter createFromServletCookie(javax.servlet.http.Cookie cookie) {
    return new CookieFormatter(cookie.getName(), cookie.getValue(), cookie.getPath());
}

From source file:com.eryansky.common.web.utils.RequestUtil.java

public static Cookie getCookie(HttpServletRequest request, String name) {
    Cookie[] cookies = request.getCookies();
    Cookie returnCookie = null;/*w  ww  .j  ava2 s  .co  m*/

    if (cookies == null) {
        return returnCookie;
    }

    for (Cookie thisCookie : cookies) {
        if (thisCookie.getName().equals(name)) {
            if (!thisCookie.getValue().equals("")) {
                returnCookie = thisCookie;

                break;
            }
        }
    }

    return returnCookie;
}

From source file:com.pureinfo.tgirls.utils.servlet.CookieUtils.java

public static String getCookieValue(Cookie[] _cookies, String _attrLoginUser) {
    logger.debug("to get cookie value of name [" + _attrLoginUser + "]");

    if (_cookies == null) {
        return null;
    }/* ww w. j  a  va  2s. c  om*/
    for (int i = 0; i < _cookies.length; i++) {
        Cookie c = _cookies[i];
        if (c.getName().equals(_attrLoginUser)) {
            logger.debug("cookie[" + _attrLoginUser + "] value[" + c.getValue() + "]");

            return c.getValue();
        }
    }

    return null;
}

From source file:CookieUtils.java

/**
 * Gets a reference to a named cookie from an array of cookies.
 *
 * @param cookies   an array of cookies/*ww  w.  j a  v  a  2  s.  c  o m*/
 * @param name      the name of the cookie to find
 * @return    a reference to a Cookie, or null if the cookie couldn't be found
 */
public static Cookie getCookie(Cookie cookies[], String name) {

    if (cookies != null) {
        for (Cookie cookie : cookies) {
            if (cookie.getName().equals(name)) {
                return cookie;
            }
        }
    }

    // we've got this far so the specified cookie wasn't found
    return null;
}

From source file:com.ieasy.basic.util.CookieSupport.java

/**
 * cookies/*  www  . j a va  2 s. c o m*/
 * 
 * @param request
 * @param response
 */
public static final void removeAllCookies(HttpServletRequest request, HttpServletResponse response) {
    Cookie[] cookies = request.getCookies();
    if (cookies == null || cookies.length == 0)
        return;
    Map<String, String> cookiesMap = new HashMap<String, String>();
    for (Cookie cookie : cookies) {
        cookiesMap.put(cookie.getName(), "");
    }
    writeCookies(response, cookiesMap, 0);
}

From source file:org.apache.camel.example.gauth.TutorialController.java

private static String getCookieValue(Cookie[] cookies, String name) {
    if (cookies == null) {
        return null;
    }/*from w  ww .  j a  va 2s.  c om*/
    for (Cookie cookie : cookies) {
        if (name.equals(cookie.getName())) {
            return cookie.getValue();
        }
    }
    return null;
}

From source file:com.netsteadfast.greenstep.base.sys.UserCurrentCookie.java

public static boolean foundCurrent(HttpServletRequest request) {
    boolean f = false;
    try {/*  w w w.ja v  a  2  s  .c  o m*/
        Cookie[] cookies = request.getCookies();
        for (int i = 0; !f && cookies != null && i < cookies.length; i++) {
            Cookie cookie = cookies[i];
            if (cookie.getName().equals(Constants.APP_SITE_CURRENTID_COOKIE_NAME)) {
                f = true;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return f;
}

From source file:scratch.cucumber.example.security.servlet.XAuthTokenHttpServletRequestBinder.java

private static String findToken(HttpServletRequest request) {

    final String headerToken = request.getHeader(X_AUTH_TOKEN);

    if (headerToken != null) {
        return headerToken;
    }/*from  ww w  .  j ava2s.com*/

    final Cookie[] cookies = request.getCookies();

    if (cookies != null) {
        for (Cookie cookie : cookies) {
            if (X_AUTH_TOKEN.equals(cookie.getName())) {
                return cookie.getValue();
            }
        }
    }

    return null;
}

From source file:fedroot.dacs.http.DacsCookie.java

public static boolean isDacsCookie(javax.servlet.http.Cookie cookie) {
    return isDacsCookieName(cookie.getName());
}