List of usage examples for javax.servlet.http HttpServletResponse addCookie
public void addCookie(Cookie cookie);
From source file:fi.helsinki.opintoni.security.CustomAuthenticationSuccessHandler.java
private void addCookie(HttpServletResponse response, Cookie cookie) { cookie.setDomain("helsinki.fi"); cookie.setPath("/"); response.addCookie(cookie); }
From source file:eu.semlibproject.annotationserver.managers.CookiesManager.java
/** * Remove an annotation server cookie *///from www. ja v a2 s . c o m public void removeASCookie(HttpServletResponse response, Cookie cookie) { cookie.setMaxAge(0); response.addCookie(cookie); }
From source file:com.netflix.genie.web.controllers.UIController.java
/** * Return the index.html file for requests to root. * * @param response The servlet response to add cookies to * @param authentication The Spring Security authentication if present * @return getIndex// w w w .java 2 s. c o m */ @GetMapping(value = { "/", "/applications/**", "/clusters/**", "/commands/**", "/jobs/**", "/output/**" }) public String getIndex(@NotNull final HttpServletResponse response, @Nullable final Authentication authentication) { if (authentication != null) { response.addCookie(new Cookie("genie.user", authentication.getName())); } else { response.addCookie(new Cookie("genie.user", "user@genie")); } return "index.html"; }
From source file:com.kcs.action.GenerateXmlDfFxmAction.java
private void setCookieDownloadStatus(String status) { Cookie cookie = new Cookie("downloadStatus", status); cookie.setMaxAge(60 * 60 * 24 * 365); // Make the cookie last a year HttpServletResponse response = ServletActionContext.getResponse(); response.addCookie(cookie); }
From source file:scratch.cucumber.example.security.servlet.XAuthTokenHttpServletRequestBinder.java
@Override public void add(HttpServletResponse response, String username) { final String token = tokenFactory.create(username); response.addHeader(X_AUTH_TOKEN, token); response.addCookie(new Cookie(X_AUTH_TOKEN, token)); }
From source file:com.intuit.karate.demo.controller.HeadersController.java
@GetMapping public ResponseEntity getToken(HttpServletResponse response) { String token = UUID.randomUUID().toString(); String time = System.currentTimeMillis() + ""; tokens.put(token, time);/*from w w w . j av a 2 s . c o m*/ response.addCookie(new Cookie("time", time)); return ResponseEntity.ok().body(token); }
From source file:org.apache.oltu.oauth2.client.demo.controller.AuthzController.java
@RequestMapping("/authorize") public ModelAndView authorize(@ModelAttribute("oauthParams") OAuthParams oauthParams, HttpServletRequest req, HttpServletResponse res) throws OAuthSystemException, IOException { try {/* ww w . j a v a 2s . co m*/ Utils.validateAuthorizationParams(oauthParams); res.addCookie(new Cookie("clientId", oauthParams.getClientId())); res.addCookie(new Cookie("clientSecret", oauthParams.getClientSecret())); res.addCookie(new Cookie("authzEndpoint", oauthParams.getAuthzEndpoint())); res.addCookie(new Cookie("tokenEndpoint", oauthParams.getTokenEndpoint())); res.addCookie(new Cookie("redirectUri", oauthParams.getRedirectUri())); res.addCookie(new Cookie("scope", oauthParams.getScope())); res.addCookie(new Cookie("state", oauthParams.getState())); res.addCookie(new Cookie("app", oauthParams.getApplication())); OAuthClientRequest request = OAuthClientRequest.authorizationLocation(oauthParams.getAuthzEndpoint()) .setClientId(oauthParams.getClientId()).setRedirectURI(oauthParams.getRedirectUri()) .setResponseType(ResponseType.CODE.toString()).setScope(oauthParams.getScope()) .setState(oauthParams.getState()).buildQueryMessage(); return new ModelAndView(new RedirectView(request.getLocationUri())); } catch (ApplicationException e) { oauthParams.setErrorMessage(e.getMessage()); return new ModelAndView("get_authz"); } }
From source file:net.smartam.leeloo.controller.AuthzController.java
@RequestMapping("/authorize") public ModelAndView authorize(@ModelAttribute("oauthParams") OAuthParams oauthParams, HttpServletRequest req, HttpServletResponse res) throws OAuthSystemException, IOException { try {//from w ww. j ava 2s . co m Utils.validateAuthorizationParams(oauthParams); res.addCookie(new Cookie("clientId", oauthParams.getClientId())); res.addCookie(new Cookie("clientSecret", oauthParams.getClientSecret())); res.addCookie(new Cookie("authzEndpoint", oauthParams.getAuthzEndpoint())); res.addCookie(new Cookie("tokenEndpoint", oauthParams.getTokenEndpoint())); res.addCookie(new Cookie("redirectUri", oauthParams.getRedirectUri())); res.addCookie(new Cookie("scope", oauthParams.getScope())); res.addCookie(new Cookie("app", oauthParams.getApplication())); OAuthClientRequest request = OAuthClientRequest.authorizationLocation(oauthParams.getAuthzEndpoint()) .setClientId(oauthParams.getClientId()).setRedirectURI(oauthParams.getRedirectUri()) .setResponseType(ResponseType.CODE.toString()).setScope(oauthParams.getScope()) .buildQueryMessage(); return new ModelAndView(new RedirectView(request.getLocationUri())); } catch (ApplicationException e) { oauthParams.setErrorMessage(e.getMessage()); return new ModelAndView("get_authz"); } }
From source file:nl.strohalm.cyclos.controls.members.printsettings.RemoveReceiptPrinterSettingsAction.java
@Override protected ActionForward executeAction(final ActionContext context) throws Exception { final HttpServletRequest request = context.getRequest(); final RemoveReceiptPrinterSettingsForm form = context.getForm(); final Long id = form.getId(); receiptPrinterSettingsService.remove(id); context.sendMessage("receiptPrinterSettings.removed"); final String currentReceiptPrinter = RequestHelper.getCookieValue(request, "receiptPrinterId"); // If the member removes a printer he's currently using, clear the cookie. We cannot, however, do this for cookies on other clients. // They'll get an error when trying to print if (StringUtils.isNotEmpty(currentReceiptPrinter) && id.toString().equals(currentReceiptPrinter)) { final HttpServletResponse response = context.getResponse(); final Cookie cookie = new Cookie("receiptPrinterId", ""); cookie.setPath(request.getContextPath()); response.addCookie(cookie); }//from ww w . j av a 2 s . c om return context.getSuccessForward(); }
From source file:com.balero.controllers.LogoutController.java
/** * Simple. Set cookie's content to 'init' * init equals to empty or null//from w w w.jav a2 s. co m * * @param response HTTP headers * @param redirectAttributes Show in message center * @return View */ @RequestMapping(method = RequestMethod.GET) public String logout(HttpServletResponse response, RedirectAttributes redirectAttributes) { // create cookie and set it in response Cookie cookie = new Cookie("baleroAdmin", "init"); response.addCookie(cookie); /** * Base on: * stackoverflow.com/questions/19249049/ * how-to-pass-parameters- * to-redirect-page-in-spring-mvc */ ResourceBundle bundle = ResourceBundle.getBundle("messages"); redirectAttributes.addFlashAttribute("message", bundle.getString("label.login.logout")); return "redirect:/"; }