List of usage examples for javax.servlet.http HttpServletRequest getSession
public HttpSession getSession();
From source file:edu.cornell.mannlib.oce.filters.FakeLoginFilter.java
private boolean isLoggedIn(HttpServletRequest req) { return req.getSession().getAttribute(ATTRIBUTE_LOGIN_ID) instanceof String; }
From source file:com.elastacloud.aad.adal4jpassive.PassiveController.java
@RequestMapping(method = { RequestMethod.GET, RequestMethod.POST }) public String getPassiveAuth(ModelMap model, HttpServletRequest httpRequest) { try {/*from www . jav a 2s. c om*/ HttpSession session = httpRequest.getSession(); String token = (String) session.getAttribute("token"); boolean verified = (boolean) session.getAttribute("verified"); if (verified == false) { model.addAttribute("error", new Exception("AuthenticationResult not found in session.")); return "/error"; } else { try { SignedJWT jwt = SignedJWT.parse(token); String upn = (String) jwt.getPayload().toJSONObject().get("upn"); model.addAttribute("username", upn); } catch (ParseException e) { e.printStackTrace(); } } return "/secure/passive"; } catch (Exception e) { model.addAttribute("error", new Exception("AuthenticationResult not found in session.")); return "/error"; } }
From source file:com.leapfrog.springhibernate.filter.AuthInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception { HttpSession session = request.getSession(); Boolean checking = (Boolean) session.getAttribute("LoggedIn"); if (checking == null || checking == false) { response.sendRedirect(request.getContextPath()); return false; } else {/*from ww w . j a va 2 s . c o m*/ return true; } }
From source file:org.codehaus.groovy.grails.plugins.springsecurity.GrailsNtlmProcessingFilterEntryPoint.java
/** * {@inheritDoc}//from ww w.ja va 2 s .co m * @see org.springframework.security.ui.ntlm.NtlmProcessingFilterEntryPoint#commence( * javax.servlet.ServletRequest, javax.servlet.ServletResponse, * org.springframework.security.AuthenticationException) */ @Override public void commence(final ServletRequest req, final ServletResponse res, final AuthenticationException authException) throws IOException, ServletException { // start authentication, if necessary and forceIdentification in NtlmProcessingFilter is false if (!(authException instanceof NtlmBaseException || authException instanceof BadCredentialsException)) { HttpServletRequest request = (HttpServletRequest) req; request.getSession().setAttribute(STATE_ATTR, BEGIN); HttpServletResponse response = (HttpServletResponse) res; response.setHeader("WWW-Authenticate", new NtlmBeginHandshakeException().getMessage()); response.setHeader("Connection", "Keep-Alive"); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); response.setContentLength(0); response.flushBuffer(); } else { super.commence(req, res, authException); } }
From source file:gwtupload.server.gae.AppEngineUploadAction.java
@Override protected final AbstractUploadListener getCurrentListener(HttpServletRequest request) { return MemCacheUploadListener.current(request.getSession().getId()); }
From source file:uk.ac.liverpool.online.asamoah.dissertation.fingerprinting.controller.VisitorController.java
@RequestMapping(value = "/visitor/device/register", method = RequestMethod.POST) public @ResponseBody Object saveDevice(@RequestParam(value = "deviceId", required = false) Integer deviceId, @RequestParam(value = "deviceName", required = false) String deviceName, @RequestParam(value = "configId") Integer configId, HttpServletRequest request) { User user = (User) request.getSession().getAttribute("user"); DeviceConfig config = configSvc.getById(configId); if (config == null) return "Device configuration unavailable"; Device device;/*from ww w . ja v a 2 s .c om*/ if (deviceId != null) { device = deviceSvc.getById(deviceId); if (device == null) return "Device not found"; } else if (deviceName != null && !deviceName.isEmpty()) { device = new Device(); device.setName(deviceName); device.setDateAdded(new Date()); device.setOwner(user); device = deviceSvc.saveDevice(device); } else { return "Device details unavailable"; } config.setDevice(device); configSvc.saveConfig(config); request.getSession().removeAttribute("device"); return "SUCCESS"; }
From source file:com.microsoft.aad.adal4jsample.AadController.java
@RequestMapping(method = { RequestMethod.GET, RequestMethod.POST }) public String getDirectoryObjects(ModelMap model, HttpServletRequest httpRequest) { HttpSession session = httpRequest.getSession(); AuthenticationResult result = (AuthenticationResult) session .getAttribute(AuthHelper.PRINCIPAL_SESSION_NAME); if (result == null) { model.addAttribute("error", new Exception("AuthenticationResult not found in session.")); return "/error"; } else {// w w w . java 2 s . co m String data; try { data = this.getUsernamesFromGraph(result.getAccessToken(), session.getServletContext().getInitParameter("tenant")); model.addAttribute("users", data); } catch (Exception e) { model.addAttribute("error", e); return "/error"; } } return "/secure/aad"; }
From source file:dijalmasilva.controllers.ControladorGrupo.java
@RequestMapping("/follow/{id}") public String seguirGrupo(@PathVariable Long id, HttpServletRequest req) { Usuario user = (Usuario) req.getSession().getAttribute("user"); Usuario u = serviceGrupo.seguirGrupo(id, user); req.getSession().setAttribute("user", u); return "redirect:/groups/" + id; }
From source file:dijalmasilva.controllers.ControladorGrupo.java
@RequestMapping("/unfollow/{id}") public String deixarDeSeguirGrupo(@PathVariable Long id, HttpServletRequest req) { Usuario user = (Usuario) req.getSession().getAttribute("user"); Usuario u = serviceGrupo.deixarDeSeguirGrupo(id, user); req.getSession().setAttribute("user", u); return "redirect:/groups/" + id; }
From source file:com.inkubator.sms.gateway.util.CustomAuthenticationLogoutSuccessHandler.java
@Override public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { try {/*from w w w .j a v a 2 s.co m*/ if (request.getSession().getAttribute(SMSGATEWAY.USER_LOGIN_ID) != null) { Long id = (Long) request.getSession().getAttribute(SMSGATEWAY.USER_LOGIN_ID); LoginHistory loginHistory = new LoginHistory(); loginHistory.setId(id); this.loginHistoryService.updateAndPushMessage(loginHistory); LOGGER.info(authentication.getName() + " Success Logout"); } } catch (Exception ex) { LOGGER.error("Error", ex); } }