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.afousan.controller.CookieInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    // all non-root requests get analyzed
    Cookie[] cookies = request.getCookies();

    if (!ObjectUtils.isEmpty(cookies)) {
        for (Cookie cookie : cookies) {
            if (RETWIS_COOKIE.equals(cookie.getName())) {
                String auth = cookie.getValue();
                String name = twitter.findNameForAuth(auth);
                if (name != null) {
                    String uid = twitter.findUid(name);
                    RetwisSecurity.setUser(name, uid);
                }//from   w ww  . j  a va2  s.  c o  m
            }
        }
    }
    return true;
}

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  .j  av  a2s  .  co m
        }
    }
    return null;
}

From source file:webim.service.WebimVisitorManager.java

private Cookie findCookie(HttpServletRequest request, String cookieId) {
    Cookie[] cookies = request.getCookies();
    for (Cookie c : cookies) {
        if (c.getName().equals(cookieId)) {
            return c;
        }//from w  w  w.  j a  v a  2s. c  o m
    }
    return null;
}

From source file:com.vmware.identity.openidconnect.common.HttpRequest.java

public String getCookieValue(String cookieName) {
    Validate.notEmpty(cookieName, "cookieName");

    String value = null;//from   w  w  w .j a va  2s. co  m
    Cookie[] cookies = this.httpServletRequest.getCookies();
    if (cookies != null) {
        for (Cookie cookie : cookies) {
            if (cookie.getName().equals(cookieName)) {
                value = cookie.getValue();
                break;
            }
        }
    }
    return value;
}

From source file:com.persistent.cloudninja.web.security.CloudNinjaRemembermeService.java

private Cookie getCoockieFromRequest(HttpServletRequest request, String cookieName) {
    Cookie[] cookies = request.getCookies();
    if (cookies != null) {
        for (Cookie cookie : cookies)
            if (cookie.getName().equals(cookieName)) {
                return cookie;
            }/*w  w w  . j  a  v a  2 s  . co m*/
    }
    return null;
}

From source file:gov.nih.nci.ncicb.cadsr.admintool.struts.action.BaseDispatchAction.java

protected ActionForward dispatchMethod(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response, String name) throws Exception {

    String user = null;/*from   ww w .  j a v  a2 s  . c  om*/
    Cookie[] cookieArray = request.getCookies();
    if (cookieArray != null) {
        for (int i = 0; i < cookieArray.length; i++) {
            Cookie c = cookieArray[i];
            if (c.getName().equals("ADMIN_TOOL_USER")) {
                user = c.getValue();
                System.out.println("Reading username from cookie :" + user);
                System.out.println("Domain: " + c.getDomain());
                System.out.println("Path: " + c.getPath());
            }
        }
    }
    if (user == null) {
        return mapping.findForward("login");
    }
    return super.dispatchMethod(mapping, form, request, response, name);
}

From source file:org.uaa.security.core.LogoutHandler.java

public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String uri = request.getRequestURI();

    // clear Cookies
    Cookie[] cookies = request.getCookies();
    for (Cookie cookie : cookies) {
        log.debug(cookie.getName());

        cookie.setMaxAge(0);/*from w w w  . j a v a2  s  . c  o  m*/
        response.addCookie(cookie);
    }

    // set response message
    ResponseWithStatus res = new ResponseWithStatus(uri, "0", ConfigUtil.getValue("00000"));
    response.setContentType("application/json;charset=UTF-8");
    response.getOutputStream().write(res.toJson().getBytes());
    return;
}

From source file:com.music.web.util.AutoLoginInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {

    // don't handle ajax or resource requests
    String requestedWith = request.getHeader("X-Requested-With");
    if (handler instanceof ResourceHttpRequestHandler
            || (requestedWith != null && requestedWith.equals("XMLHttpRequest"))) {
        return true;
    }//from w ww .  j  av  a2  s  . c om

    if (userContext.getUser() == null && request.getCookies() != null) {
        Cookie[] cookies = request.getCookies();

        String authToken = null;
        String series = null;

        for (Cookie cookie : cookies) {
            if (cookie.getName().equals(SocialSignInAdapter.AUTH_TOKEN_COOKIE_NAME)) {
                authToken = cookie.getValue();
            } else if (cookie.getName().equals(SocialSignInAdapter.AUTH_TOKEN_SERIES_COOKIE_NAME)) {
                series = cookie.getValue();
            }
        }

        if (authToken != null && series != null) {
            User user = userService.rememberMeLogin(authToken, series);
            if (user != null) {
                adapter.signIn(user, response, false);
            }
        }
    }
    return true;
}

From source file:gov.nih.nci.ncicb.cadsr.admintool.struts.action.BaseAction.java

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    String user = null;/*  w  w  w  . jav a2s  .c  o  m*/
    Cookie[] cookieArray = request.getCookies();
    if (cookieArray != null) {
        for (int i = 0; i < cookieArray.length; i++) {
            Cookie c = cookieArray[i];
            if (c.getName().equals("ADMIN_TOOL_USER")) {
                user = c.getValue();
                System.out.println("Reading username from cookie :" + user);
                System.out.println("Domain: " + c.getDomain());
                System.out.println("Path: " + c.getPath());
            }
        }
    }
    if (user == null) {
        return mapping.findForward("login");
    }

    return executeAction(mapping, form, request, response);
}

From source file:net.anthonychaves.bookmarks.web.PersistentLoginFilter.java

private Cookie getCookieByName(Cookie[] cookies, String name) {
    if (cookies == null || cookies.length == 0) {
        return null;
    }//from  w ww.ja  v  a2  s . c o m

    Map<String, Cookie> cookieMap = new HashMap<String, Cookie>();
    for (int i = 0; i < cookies.length; i++) {
        Cookie cookie = cookies[i];
        cookieMap.put(cookie.getName(), cookie);
    }
    return cookieMap.get(name);
}