Example usage for javax.servlet.http Cookie getValue

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

Introduction

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

Prototype

public String getValue() 

Source Link

Document

Gets the current value of this Cookie.

Usage

From source file:com.awt.facebook.account.UserCookieGenerator.java

public String readCookieValue(HttpServletRequest request) {
    Cookie[] cookies = request.getCookies();
    if (cookies == null) {
        return null;
    }/*  ww  w .  ja va2s .  c o  m*/
    for (Cookie cookie : cookies) {
        if (cookie.getName().equals(userCookieGenerator.getCookieName())) {
            return cookie.getValue();
        }
    }
    return null;
}

From source file:eu.supersede.fe.rest.SessionRest.java

@RequestMapping("")
public Session getSession(HttpServletRequest request) throws IOException, ClassNotFoundException {
    Cookie cookie = WebUtils.getCookie(request, "SESSION");
    Session s = sessionTemplate.opsForValue().get(Session.SUPERSEDE_SESSION_PREFIX + cookie.getValue());

    return s;//from ww  w .  j a  v  a2 s  .c o  m
}

From source file:org.codemucker.testserver.capturing.CapturedCookie.java

public CapturedCookie(Cookie c) {
    domain = c.getDomain();//from  w  ww  . j a va  2  s .  c o  m
    path = c.getPath();
    name = c.getName();
    value = c.getValue();
    secure = c.getSecure();
    maxAge = c.getMaxAge();
    version = c.getVersion();
}

From source file:com.demandware.vulnapp.challenge.impl.CookieChallenge.java

private boolean doesCookieValueGrantAccess(Cookie c) {
    boolean grant = false;
    String value = new String(Base64.decodeBase64(c.getValue()));
    try {/*from www . j a v a2s . c  o m*/
        JSONObject o = (JSONObject) new JSONParser().parse(value);
        grant = Helpers.isTruthy((String) o.get(ACCESS_KEY));
    } catch (ParseException e) {
        grant = false;
    }
    return grant;
}

From source file:org.osmsurround.ae.oauth.OauthCookieService.java

public boolean initOauthServiceFromCookies(Cookie[] cookies) {
    if (cookies != null) {
        for (Cookie cookie : cookies) {
            if (OAUTH_TOKEN_COOKIE.equals(cookie.getName())) {
                String data[] = cookie.getValue().split("####");
                if (data != null && data.length == 2) {
                    oauthService.getConsumer().setTokenWithSecret(data[0], data[1]);
                    return true;
                }//from  www.j  a  va  2s .  c  om
            }
        }
    }
    return false;
}

From source file:shiver.me.timbers.spring.security.jwt.AuthenticationRequestJwtTokenParser.java

private String findCookieToken(HttpServletRequest request) {
    final Cookie[] cookies = request.getCookies();
    if (cookies != null) {
        for (Cookie cookie : cookies) {
            if (tokenName.equals(cookie.getName())) {
                return cookie.getValue();
            }/*  w  w  w  .  ja v  a2 s  .  c o  m*/
        }
    }
    return null;
}

From source file:MyServlet.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    out.println("<HTML>");
    out.println("<HEAD>");
    out.println("<TITLE>");
    out.println("A Web Page");
    out.println("</TITLE>");
    out.println("</HEAD>");
    out.println("<BODY");

    Cookie[] cookies = request.getCookies();
    boolean foundCookie = false;

    for (int i = 0; i < cookies.length; i++) {
        Cookie cookie1 = cookies[i];
        if (cookie1.getName().equals("color")) {
            out.println("bgcolor = " + cookie1.getValue());
            foundCookie = true;// ww  w .  java2 s  .  c  om
        }
    }

    if (!foundCookie) {
        Cookie cookie1 = new Cookie("color", "cyan");
        cookie1.setMaxAge(24 * 60 * 60);
        response.addCookie(cookie1);
    }

    out.println(">");
    out.println("<H1>Setting and Reading Cookies</H1>");
    out.println("This page will set its background color using a cookie when reloaded.");
    out.println("</BODY>");
    out.println("</HTML>");
}

From source file:net.sourceforge.vulcan.web.PreferencesFilter.java

private String getCookieData(HttpServletRequest request, String cookieName) {
    final Cookie[] cookies = request.getCookies();
    if (cookies != null) {
        for (Cookie c : cookies) {
            if (c.getName().equals(cookieName)) {
                return c.getValue();
            }/*w  w w.  ja  v a  2s. c o m*/
        }
    }

    return null;
}

From source file:org.unidle.web.LocationMethodArgumentResolver.java

@Override
public Object resolveArgument(final MethodParameter methodParameter,
        final ModelAndViewContainer modelAndViewContainer, final NativeWebRequest nativeWebRequest,
        final WebDataBinderFactory webDataBinderFactory) throws Exception {

    final HttpServletRequest httpServletRequest = nativeWebRequest.getNativeRequest(HttpServletRequest.class);
    final Cookie cookie = WebUtils.getCookie(httpServletRequest, "address");

    final String address = cookie != null ? cookie.getValue()
            : hasText(nativeWebRequest.getHeader("X-Forwarded-For"))
                    ? nativeWebRequest.getHeader("X-Forwarded-For")
                    : httpServletRequest.getRemoteAddr();

    return locationService.locateAddress(address);
}

From source file:com.google.acre.script.AcreCookie.java

public AcreCookie(org.apache.http.cookie.Cookie c) {
    name = c.getName();/*w w w  . j  a  v  a  2s  .  c  o m*/
    value = c.getValue();
    secure = c.isSecure();
    domain = c.getDomain();
    path = c.getPath();
    max_age = -1;
    // XXX translate into max-age?
    // c.getExpiryDate();
}