List of usage examples for javax.servlet.http Cookie getName
public String getName()
From source file:net.yoomai.service.TicketService.java
/** * TGTcookie.//w ww . j a va2s. c om * * @param cookies * @return */ public String verifyTGT(Cookie[] cookies) { String _tgt_id = null; if (cookies != null) { for (int index = 0; index < cookies.length; index++) { Cookie cookie = cookies[index]; if ("_id_".equals(cookie.getName())) { _tgt_id = cookie.getValue(); } } } return _tgt_id; }
From source file:com.ms.commons.summer.security.web.DefaultSecurityFormResolver.java
/** * ?token????InvalidTokenException/* w w w. j a v a 2 s. c om*/ * * @param request * @param response * @throws InvalidTokenException */ public void validSessionToken(final HttpServletRequest request, final HttpServletResponse response) throws InvalidTokenException { Cookie[] cookies = request.getCookies(); String ctoken = null; if (cookies != null) { for (Cookie cookie : cookies) { if (FORM_RESUBMIT_TOKEN.equals(cookie.getName())) { ctoken = cookie.getValue(); break; } } } String rtoken = request.getParameter(FORM_RESUBMIT_TOKEN); if (rtoken == null || rtoken.length() == 0) { throw new InvalidTokenException("can't find token in request"); } if (ctoken == null || ctoken.length() == 0) { throw new InvalidTokenException("can't find token in cookie"); } if (!ctoken.equals(rtoken)) { throw new InvalidTokenException("failed to check for token in request"); } // cookietoken? Cookie c = new Cookie(FORM_RESUBMIT_TOKEN, ""); c.setPath("/"); response.addCookie(c); }
From source file:fr.univlille2.ecm.platform.ui.web.auth.cas2.AnonymousAuthenticatorForCAS2.java
@Override public Boolean handleLogout(HttpServletRequest httpRequest, HttpServletResponse httpResponse) { boolean isRedirectionToCas = false; log.debug(httpRequest.getRequestURL().toString()); Cookie[] cookies = httpRequest.getCookies(); for (Cookie cookie : cookies) { log.debug(String.format("ANONYMOUS_AUTH : cookie->%s:%s", cookie.getName(), cookie.getValue())); if (NXAuthConstants.SSO_INITIAL_URL_REQUEST_KEY.equals(cookie.getName())) { isRedirectionToCas = true;/*from w w w . j a v a2 s. c o m*/ log.debug("isRedirectionToCAS"); break; } } if (isRedirectionToCas) { String authURL = getCas2Authenticator().getServiceURL(httpRequest, Cas2Authenticator.LOGIN_ACTION); String appURL = getCas2Authenticator().getAppURL(httpRequest); try { Map<String, String> urlParameters = new HashMap<String, String>(); urlParameters.put("service", URLEncoder.encode(appURL, "UTF-8")); String location = URIUtils.addParametersToURIQuery(authURL, urlParameters); httpResponse.sendRedirect(location); return true; } catch (IOException e) { log.error("Unable to redirect to CAS logout screen:", e); return false; } } return super.handleLogout(httpRequest, httpResponse); }
From source file:fr.mby.portal.coreimpl.app.BasicAppSigner.java
@Override public String retrieveSignature(final HttpServletRequest request) { String signature = null;/*from www . j a v a 2 s .co m*/ final Object attrObject = request.getAttribute(IPortal.SIGNATURE_PARAM_NAME); if (attrObject != null && attrObject instanceof String) { signature = (String) attrObject; } if (!StringUtils.hasText(signature)) { signature = request.getParameter(IPortal.SIGNATURE_PARAM_NAME); } if (!StringUtils.hasText(signature)) { final Cookie[] cookies = request.getCookies(); if (cookies != null) { for (final Cookie cookie : cookies) { if (cookie != null && IPortal.SIGNATURE_PARAM_NAME.equals(cookie.getName())) { signature = cookie.getValue(); } } } } if (!StringUtils.hasText(signature)) { request.setAttribute(IPortal.SIGNATURE_PARAM_NAME, signature); } return signature; }
From source file:org.geonode.security.GeoNodeCookieProcessingFilter.java
private String getGeoNodeCookieValue(HttpServletRequest request) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Inspecting the http request looking for the GeoNode Session ID."); }/*w w w . j a v a 2s .c o m*/ Cookie[] cookies = request.getCookies(); if (cookies != null) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Found " + cookies.length + " cookies!"); } for (Cookie c : cookies) { if (GEONODE_COOKIE_NAME.equals(c.getName())) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Found GeoNode cookie: " + c.getValue()); } return c.getValue(); } } } else { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Found no cookies!"); } } return null; }
From source file:com.mobileman.projecth.web.util.PersistentCookieHelper.java
public void removeUser(HttpServletRequest request, HttpServletResponse response) { //remove from request Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie c : cookies) { if (COOKIE_NAME.equals(c.getName())) { c.setValue("deleted"); break; }/*from w ww . j a v a 2s. co m*/ } } //remove from browser Cookie cookie = new Cookie(COOKIE_NAME, "1"); cookie.setPath(PATH); cookie.setMaxAge(0); //0 = remove cookie response.setContentType("text/html"); //else delete cookie not works response.addCookie(cookie); }
From source file:com.baron.bm.controller.MemberController.java
@RequestMapping("/modify") public String modifyidentity(String password, HttpServletRequest request) { String pass = null;/*w ww . j av a2 s .c o m*/ for (Cookie cookie : request.getCookies()) { if (cookie.getName().equals("bm_id")) { pass = joinService.identify(cookie.getValue()); } } return (pass.equals(password)) ? "modifyidentity" : "identifyfail"; }
From source file:com.baron.bm.controller.MemberController.java
@RequestMapping("/modifySuccess") public String modifySuccess(@Valid MemberModel model, HttpServletRequest request) { for (Cookie cookie : request.getCookies()) { if (cookie.getName().equals("bm_id")) { model.setId(cookie.getValue()); }/* w w w. ja v a2 s. co m*/ } joinService.updateMember(model); return "modifySuccess"; }
From source file:controllers.Parent_Controller.java
public int checkSetCookie(HttpServletRequest request) { cookies = request.getCookies();//ww w .ja v a 2 s.c om int countcookies = 0; for (Cookie cookie1 : cookies) { switch (cookie1.getName()) { case "handle": System.out.println("Got Handle cookie"); handle = cookie1.getValue(); countcookies++; break; case "uid": System.out.println("Got uid cookie"); uid = Integer.parseInt(cookie1.getValue()); countcookies++; break; } } if (countcookies == 0) { return 0; } else { cookiesSet = true; return 2; } }
From source file:com.baron.bm.controller.MemberController.java
@RequestMapping("/logout") // public String logout(HttpServletRequest request, MemberModel model, HttpServletResponse response) { for (Cookie cookie : request.getCookies()) { if (cookie.getName().equals("bm_id")) { cookie.setMaxAge(0);//from w w w . j ava 2s .c o m model.setId("0"); response.addCookie(new Cookie("bm_id", model.getId())); } else if (cookie.getName().equals("bm_permission")) { cookie.setMaxAge(0); model.setPermission("0"); response.addCookie(new Cookie("bm_permission", model.getPermission())); } } return "logout"; }