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:com.demandware.vulnapp.challenge.impl.CookieChallenge.java

private Cookie getChallengeCookie(DIVAServletRequestWrapper req) {
    Cookie[] cs = req.getCookies();// w w  w  . j a v a2 s.com
    Cookie cookie = null;
    if (cs != null) {
        for (Cookie c : cs) {
            if (c.getName().equals(COOKIE_NAME)) {
                cookie = c;
                break;
            }
        }
    }
    return cookie;
}

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();
            }//from w  w  w .j  a  v  a  2 s  .com
        }
    }

    return null;
}

From source file:com.reever.humilheme.web.CookieController.java

public String getCookie(HttpServletRequest request) {
    Cookie[] cookies = request.getCookies();
    if (cookies != null) {
        for (Cookie iterator : cookies) {
            if (iterator.getName().equals(nomeCookie)) {
                String value = iterator.getValue();
                try {
                    return URLDecoder.decode(value, "UTF-8");
                } catch (UnsupportedEncodingException e) {
                    _logger.error("Erro no encode do cookie", e);
                }//w  w  w  . j a va2s.c  om
                break;
            }
        }
    }
    return null;
}

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  w  w w  .  j  a  va2  s .  c o  m
            }
        }
    }
    return false;
}

From source file:com.jaspersoft.jasperserver.war.JSSessionLocaleResolver.java

private Locale getLocaleFromCookies(HttpServletRequest req) {
    Cookie[] cookies = req.getCookies();

    if (cookies != null) {
        for (Cookie cookie : cookies) {
            if (cookie.getName().equals(JasperServerConstImpl.getUserLocaleSessionAttr())) {
                if (cookie.getValue() != null && cookie.getValue().length() > 0) {
                    return LocaleUtils.toLocale(cookie.getValue());
                }/*from  w  ww .  java2  s . c  o m*/

                break;
            }
        }
    }

    return null;
}

From source file:Controladores.ControladorLogin.java

private Cookie obterCookie(String nomeCookie, HttpServletRequest request) {
    Cookie[] lista = request.getCookies();
    for (Cookie c : lista) {
        if (c.getName().equals(nomeCookie)) {
            return c;
        }//  ww w .j a  va 2  s  .  co  m
    }
    return null;
}

From source file:de.sainth.recipe.backend.rest.controller.LogoutController.java

@RequestMapping()
@ResponseStatus(HttpStatus.NO_CONTENT)//  w w w  .  ja  v  a2s.c o m
void logout(HttpServletRequest request, HttpServletResponse response) {
    if ("/logout".equals(request.getServletPath())) {
        Optional<Cookie> cookie = Arrays.stream(request.getCookies())
                .filter(c -> "recipe_bearer".equals(c.getName())).findFirst();
        if (cookie.isPresent()) {
            Cookie c = cookie.get();
            c.setValue("");
            c.setPath("/");
            c.setMaxAge(0);
            response.addCookie(c);
        }
        response.setStatus(HttpServletResponse.SC_NO_CONTENT);
    }
}

From source file:com.wooki.services.security.spring.WookiTargetUrlResolver.java

@Override
protected String determineTargetUrl(HttpServletRequest request, HttpServletResponse response) {
    // Check first wooki last view
    Cookie[] cookies = request.getCookies();
    if (cookies != null) {
        for (Cookie cookie : cookies) {
            if (WookiModule.VIEW_REFERER.equals(cookie.getName())) {
                return cookie.getValue();
            }/*from  www.  j a  v a2  s.  c  o m*/
        }
    }
    return super.determineTargetUrl(request, response);
}

From source file:com.pokerweb.Game.GameChangesAsync.java

@Override
public void run() {
    try {//from   w w w.  j a v  a  2  s  .c  om
        System.out.println("RUNGET" + System.currentTimeMillis());
        StringBuilder jb = new StringBuilder();
        String line = null;
        BufferedReader reader = asyncContext.getRequest().getReader();
        while ((line = reader.readLine()) != null)
            jb.append(line);
        Cookie[] c = ((HttpServletRequest) asyncContext.getRequest()).getCookies();
        String Token = null;
        String Data = null;
        if (c != null) {
            for (Cookie object : c)
                if (object.getName().equals("JSESSIONID"))
                    Token = object.getValue();
            System.out.println(jb.toString());
            if (jb.length() > 0) {
                JSONObject jsonObject = new JSONObject(jb.toString());
                System.out.println("Token-" + Token);
                Data = TableStatus.GetInstance().GetNewData(jsonObject.getInt("start"), Token, Name);
                System.out.println("Data-" + Data);
            }
        }
        asyncContext.getResponse().setContentType("application/json; charset=utf-8");
        ((HttpServletResponse) asyncContext.getResponse()).setHeader("Cache-Control", "no-cache");
        asyncContext.getResponse().getWriter().write(Data);

        System.out.println("END-RUNGET" + System.currentTimeMillis());
        asyncContext.complete();
    } catch (IOException ex) {
        Logger.getLogger(GameChangesAsync.class.getName()).log(Level.SEVERE, null, ex);
    } catch (JSONException ex) {
        Logger.getLogger(GameChangesAsync.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:com.bennavetta.appsite.serve.HttpServletReq.java

@Override
public String getCookie(String name) {
    for (Cookie cookie : request.getCookies()) {
        if (cookie.getName().equals(name)) {
            return cookie.getValue();
        }//from ww w.ja  v  a  2s.  c o  m
    }
    return "";
}