List of usage examples for javax.servlet.http HttpServletResponse sendRedirect
public void sendRedirect(String location) throws IOException;
From source file:com.pearson.pdn.demos.chainoflearning.RegisterServlet.java
@Override protected void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { String email = req.getParameter("email"); if (email == null || !email.matches(EMAIL_PATTERN)) { res.sendRedirect(req.getContextPath() + "/register.jsp"); return;//from w w w . j a v a 2 s .co m } HttpSession session = req.getSession(true); // TODO - do this better. actually persist it... String verifyCode = Base64.encodeBase64String(String.valueOf(System.currentTimeMillis()).getBytes()); session.setAttribute("auth", Base64.encodeBase64String((email + ":" + verifyCode).getBytes())); // TODO - actually send an email String linkParams = "?e=" + email + "&v=" + verifyCode; String emailContent = "Hello " + email + ",<br /><br /><a id=\"email-link\" href=\"./oauth2" + linkParams + "\">Link</a> your calendar with ChainOfLearning. <br/ > <br /> Thanks!"; req.setAttribute("emailContent", emailContent); req.setAttribute("email", email); req.getRequestDispatcher("/activation.jsp").forward(req, res); }
From source file:com.nkapps.billing.configs.LoginInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException { String uri = request.getRequestURI(); if (!uri.startsWith("/auth")) { if (!authService.isAuthenticated()) { response.sendRedirect("/auth/login"); return false; }// ww w . j a va 2 s .c om } return true; }
From source file:com.blauadvisors.pentaho.plugins.redirect.RedirectPluginContentGenerator.java
public void createContent() throws Exception { this.session = PentahoSessionHolder.getSession(); this.repository = PentahoSystem.get(IUnifiedRepository.class, session); RepositoryFile repositoryFile = (RepositoryFile) parameterProviders.get("path").getParameter("file"); SimpleRepositoryFileData data = repository.getDataForRead(repositoryFile.getId(), SimpleRepositoryFileData.class); RedirectPluginFileContectExtractor fileData = new RedirectPluginFileContectExtractor(data.getInputStream()); /*/*ww w . j a v a 2 s.com*/ * Redirect to Specified URL */ try { // Get informations about user context IUserRoleListService service = PentahoSystem.get(IUserRoleListService.class); String roles = ""; ListIterator li = service.getRolesForUser(null, session.getName()).listIterator(); while (li.hasNext()) { roles = roles + li.next().toString() + ","; } // Build URL String redirectURL = fileData.getUrl(); String parameters = ""; parameters += (fileData.getIncludeRoles() ? "&" + fileData.getRolesParameterName() + "=" + roles : ""); parameters += (fileData.getIncludeUserName() ? "&" + fileData.getUserNameParameterName() + "=" + session.getName() : ""); parameters += (fileData.getIncludeTimeStamp() ? "&" + "timeStamp=" + (new Date()).toString() : ""); redirectURL += (!fileData.getUrlIncludesParameters() ? "?" : "") + parameters; // Redirect HttpServletResponse response = (HttpServletResponse) this.parameterProviders.get("path") .getParameter("httpresponse"); response.sendRedirect(redirectURL); } catch (Exception e) { Logger.error(getClass().getName(), e.getMessage()); } }
From source file:fi.helsinki.opintoni.security.SAMLLogoutSuccessHandler.java
@Override public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { String serverName = request.getServerName(); String ssoLogoutUri = appConfiguration.get("ssoLogoutUri"); response.sendRedirect(ssoLogoutUri + "?return=" + "https://" + serverName); }
From source file:uk.gov.hmrc.controllers.HelloWorldController.java
@RequestMapping("/hello-user") @ResponseBody/*from w ww .java2 s .c o m*/ public String helloUser(HttpSession session, HttpServletResponse response) throws UnauthorizedException, IOException { if (session.getAttribute("userToken") == null) { response.sendRedirect(getAuthorizationRequestUrl()); return ""; } else { Token userToken = (Token) session.getAttribute("userToken"); try { return doCallHelloUser(userToken.getAccessToken()); } catch (UnauthorizedException ue) { Token refreshedToken = oauthService.refreshToken(userToken.getRefreshToken()); session.setAttribute("userToken", refreshedToken); return doCallHelloUser(refreshedToken.getAccessToken()); } } }
From source file:com.nec.harvest.security.handler.HarvestAuthenticationSuccessHandler.java
protected void sendRedirectToLogout(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(HttpServletContentType.PLAN_TEXT); response.sendRedirect(request.getContextPath() + "/logout"); response.flushBuffer();//w ww . j a v a 2s . c o m }
From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.Properties2PropertiesOperationController.java
public void doGet(HttpServletRequest request, HttpServletResponse response) { String defaultLandingPage = getDefaultLandingPage(request); try {/*from w w w .j av a2 s . c o m*/ response.sendRedirect(defaultLandingPage); } catch (IOException e) { log.error("Unable to redirect to default landing page", e); } }
From source file:cn.vlabs.umt.ui.servlet.ThirdPartyLoginServlet.java
/** * ???requestToken// www . ja v a 2 s . co m * @param request * @param response * */ private void doQQRequestToken(HttpServletRequest request, HttpServletResponse response) { try { String url = new com.qq.connect.oauth.Oauth().getAuthorizeURL(request); response.sendRedirect(url); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } catch (QQConnectException e) { LOGGER.error(e.getMessage(), e); } }
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 {/* w ww .j a v a 2 s . c o m*/ return true; } }
From source file:com.trailmagic.image.ui.ImageAccessController.java
private String redirectForSuccess(HttpServletRequest request, HttpServletResponse response) throws IOException { final SavedRequest savedRequest = requestCache.getRequest(request, response); if (savedRequest != null) { response.sendRedirect(savedRequest.getRedirectUrl()); return null; }/*from w w w. j a va 2 s . c om*/ return "redirect:"; }