List of usage examples for javax.servlet.http Cookie getName
public String getName()
From source file:com.persistent.cloudninja.web.security.CloudNinjaRemembermeService.java
/** * Find the cookie in request and // w w w . j a v a 2 s . com * @param request * @param cookieName * @return */ protected String getCookieValue(HttpServletRequest request, String cookieName) { String cookieValue = null; Cookie[] cookies = request.getCookies(); if (cookies != null) for (Cookie cookie : cookies) if (cookie.getName().equals(cookieName)) { cookieValue = cookie.getValue(); break; } return cookieValue; }
From source file:com.orangeleap.webtools.controller.json.LogoutController.java
@RequestMapping("/logout.json") public void logout(final HttpServletRequest request, final HttpServletResponse response) throws Exception { final String guid = request.getParameter("guid"); final String sessionId = request.getParameter("sessionId"); if (StringUtils.isNotBlank(sessionId)) { final Cookie sessionCookies[] = request.getCookies(); Cookie sessionCookie = null;//from w w w .j a v a 2 s . c om for (final Cookie aCookie : sessionCookies) { if (aCookie.getName().equals("sessionId")) { aCookie.setMaxAge(0); aCookie.setValue(""); sessionCookie = aCookie; break; } } if (sessionCookie == null) { sessionCookie = new Cookie("sessionId", ""); } response.addCookie(sessionCookie); sessionCache.remove(sessionId); } final Widget widget = widgetService.getWidget(guid); final String authenticationUrl = widget.getWidgetAuthenticationURL(); response.sendRedirect(authenticationUrl); }
From source file:com.google.acre.script.AcreCookie.java
public AcreCookie(Cookie servlet_cookie) { name = servlet_cookie.getName(); value = servlet_cookie.getValue();/*w ww . j av a 2 s . c o m*/ domain = servlet_cookie.getDomain(); path = servlet_cookie.getPath(); secure = servlet_cookie.getSecure(); max_age = servlet_cookie.getMaxAge(); }
From source file:com.persistent.cloudninja.controller.LogoutFilter.java
private void removeCookie(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, String authCookieName) {/*from w w w . j a va2 s .c om*/ Cookie[] cookies = httpServletRequest.getCookies(); Cookie currentCookie = null; if (cookies != null && cookies.length > 0) { for (Cookie c : cookies) { if (authCookieName.equals(c.getName())) { currentCookie = c; currentCookie.setMaxAge(0); currentCookie.setValue(""); currentCookie.setPath("/"); httpServletResponse.addCookie(currentCookie); } } } }
From source file:net.nikey.interceptor.LoginRequiredInterceptor.java
@Override public Object before(Invocation inv) throws Exception { // all non-root requests get analyzed Cookie[] cookies = inv.getRequest().getCookies(); if (!ObjectUtils.isEmpty(cookies)) { for (Cookie cookie : cookies) { if (RETWIS_COOKIE.equals(cookie.getName())) { String auth = cookie.getValue(); String name = user.findNameForAuth(auth); if (StringUtils.hasText(name)) { String uid = user.findUid(name); if (StringUtils.hasText(uid)) { inv.addModel("isSignedIn", true); inv.addModel("uid", uid); NikeySecurity.setUser(name, uid); return super.before(inv); }/*from www . j av a 2 s .c om*/ } } } } inv.addModel("isSignedIn", false); return super.before(inv); }
From source file:org.slc.sli.dashboard.web.interceptor.SessionCheckInterceptor.java
/** * Prehandle performs a session check on all incoming requests to ensure a user with an active spring security session, * is still authenticated against the api. *//* www .java2 s .c om*/ @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { String token = SecurityUtil.getToken(); JsonObject json = restClient.sessionCheck(token); // If the user is not authenticated, expire the cookie and set oauth_token to null if (!json.get(Constants.ATTR_AUTHENTICATED).getAsBoolean()) { SecurityContextHolder.getContext().setAuthentication(null); HttpSession session = request.getSession(); session.setAttribute(SLIAuthenticationEntryPoint.OAUTH_TOKEN, null); for (Cookie c : request.getCookies()) { if (c.getName().equals(SLIAuthenticationEntryPoint.DASHBOARD_COOKIE)) { c.setMaxAge(0); } } // Only redirect if not error page if (!(request.getServletPath().equalsIgnoreCase(ErrorController.EXCEPTION_URL) || request.getServletPath().equalsIgnoreCase(ErrorController.TEST_EXCEPTION_URL))) { response.sendRedirect(request.getRequestURI()); return false; } } return true; }
From source file:com.data2semantics.yasgui.server.servlets.AppCacheServlet.java
private String getPermutationFromCookies(Cookie[] cookies) { String permutationStrongName = null; for (Cookie cookie : cookies) { if (cookie.getName().equals(CookieKeys.GWT_STRONG_NAME)) { permutationStrongName = cookie.getValue(); }/* ww w. java 2 s .c o m*/ } return permutationStrongName; }
From source file:com.zextras.zimbradrive.BackendUtils.java
private String assertZmAuthTokenFromCookies(HttpServletRequest httpServletRequest) { Cookie[] cookies = httpServletRequest.getCookies(); for (Cookie cookie : cookies) { if (cookie.getName().equals(AUTH_TOKEN)) { return cookie.getValue(); }// www .j a va2 s . c o m } throw new NoZmAuthTokenCookieFoundException(); }
From source file:org.codemucker.testserver.capturing.CapturedCookie.java
public CapturedCookie(Cookie c) { domain = c.getDomain();/*from ww w .ja 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.nkapps.billing.services.SearchServiceImpl.java
@Override public String execSearchBy(HttpServletRequest request, HttpServletResponse response) throws Exception { Cookie sbtCookie = null;/*ww w.ja va 2s .co m*/ String searchBy = request.getParameter("searchBy"); if (searchBy == null) { Cookie[] requestCookies = request.getCookies(); for (Cookie c : requestCookies) { if (c.getName().equals("searchBy")) { sbtCookie = c; } } if (sbtCookie != null) { searchBy = URLDecoder.decode(sbtCookie.getValue(), "UTF-8"); } else { searchBy = ""; } } else { sbtCookie = new Cookie("searchBy", URLEncoder.encode(searchBy, "UTF-8")); sbtCookie.setPath("/"); response.addCookie(sbtCookie); } return searchBy; }