List of usage examples for javax.servlet.http HttpServletRequest getAttribute
public Object getAttribute(String name);
Object
, or null
if no attribute of the given name exists. From source file:org.surfnet.oaaas.resource.AbstractResource.java
protected String getUserId(HttpServletRequest request) { VerifyTokenResponse verifyTokenResponse = (VerifyTokenResponse) request .getAttribute(AuthorizationServerFilter.VERIFY_TOKEN_RESPONSE); return verifyTokenResponse.getPrincipal().getName(); }
From source file:edu.emory.cci.aiw.cvrg.eureka.servlet.LoginServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try {// www. jav a2 s . com User user = (User) req.getAttribute("user"); user.setLastLogin(new Date()); this.servicesClient.updateUser(user, user.getId()); resp.sendRedirect(req.getContextPath() + "/index.jsp"); } catch (ClientException e) { Status responseStatus = e.getResponseStatus(); if (responseStatus == Status.FORBIDDEN) { HttpSession session = req.getSession(false); if (session != null) { session.invalidate(); } resp.sendError(HttpStatus.SC_FORBIDDEN); } else { throw new ServletException(e); } } }
From source file:com.zuoxiaolong.blog.common.web.AbstractController.java
/** * HttpServletRequest ?//from w w w. ja v a 2s .c om * @param name ?? * @return */ protected Object getRequestAttribute(String name) { HttpServletRequest request = this.getRequest(); Object value = request.getAttribute(name); return value; }
From source file:com.googlesource.gerrit.plugins.gitblit.auth.GerritAuthFilter.java
/** * Returns the user making the request, if the user has authenticated. * @param httpRequest/*from ww w. ja v a 2 s . c o m*/ * @return user */ public UserModel getUser(HttpServletRequest httpRequest) { UserModel user = null; String username = (String) httpRequest.getAttribute("gerrit-username"); String token = (String) httpRequest.getAttribute("gerrit-token"); if (token == null || username == null) { return null; } user = GitBlit.self().authenticate(username, (GerritToGitBlitUserService.SESSIONAUTH + token).toCharArray()); if (user != null) { return user; } return null; }
From source file:br.com.edo.atmlist.config.CsrfHeaderFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { CsrfToken csrf = (CsrfToken) request.getAttribute(CsrfToken.class.getName()); if (csrf != null) { Cookie cookie = WebUtils.getCookie(request, "XSRF-TOKEN"); String token = csrf.getToken(); if (cookie == null || token != null && !token.equals(cookie.getValue())) { cookie = new Cookie("XSRF-TOKEN", token); cookie.setPath("/"); response.addCookie(cookie);/*from ww w . ja v a 2 s .c o m*/ } } filterChain.doFilter(request, response); }
From source file:net.thewaffleshop.nimbus.web.LoginController.java
@RequestMapping(value = "/authenticationFailure", method = RequestMethod.POST) @ResponseBody//from w w w . j a v a2 s.c o m public Object authenticationFailure(HttpServletRequest request, HttpServletResponse response) { AuthenticationException ae = (AuthenticationException) request.getAttribute("authenticationException"); ExtAjaxResponse ret = new ExtAjaxResponse(false); if (!(ae instanceof InternalAuthenticationServiceException)) { ret.setMsg(ae.getLocalizedMessage()); } return ret; }
From source file:com.adito.policyframework.actions.ResourceInformationAction.java
public ActionForward information(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Resource r = (Resource) request.getAttribute(Constants.REQ_ATTR_INFO_RESOURCE); Collection<Policy> policies = null; if (r.getResourceType().isPolicyRequired()) { policies = PolicyDatabaseFactory.getInstance().getPoliciesAttachedToResource(r, getSessionInfo(request).getRealm()); }/*from w ww . j a v a2s . co m*/ ((ResourceInformationForm) form).initialise(r, policies); return mapping.findForward("display"); }
From source file:com.aplikasi.penjualan.config.CsrfAttributeToCookieFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { CsrfToken csrf = (CsrfToken) request.getAttribute(CsrfToken.class.getName()); if (csrf != null) { Cookie cookie = WebUtils.getCookie(request, "XSRF-TOKEN"); String token = csrf.getToken(); if (cookie == null || token != null && !token.equals(cookie.getValue())) { cookie = new Cookie("XSRF-TOKEN", token); cookie.setPath("/"); response.addCookie(cookie);//w ww.j a va 2 s . co m } } filterChain.doFilter(request, response); }
From source file:org.covito.kit.web.springmvc.controller.BaseController.java
/** * ?reuqest//from w w w . java 2 s . c o m * <p>??</p> * * @author covito * @param request * @param name * @param obj ?set * @return */ protected <T> T getOrCreateRequestAttribute(HttpServletRequest request, String name, T obj) { T value = (T) request.getAttribute(name); if (value == null) { value = obj; request.setAttribute(name, value); } return value; }
From source file:co.edu.utb.softeng.springtodos.config.security.CsrfHeaderFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { CsrfToken csrf = (CsrfToken) request.getAttribute(CsrfToken.class.getName()); if (csrf != null) { Cookie cookie = WebUtils.getCookie(request, "XSRF-TOKEN"); String token = csrf.getToken(); if (cookie == null || token != null && !token.equals(cookie.getValue())) { cookie = new Cookie("XSRF-TOKEN", token); cookie.setPath("/"); response.addCookie(cookie);/* w ww.j a v a2 s . c o m*/ } } filterChain.doFilter(request, response); }