1 17 package org.alfresco.web.app.servlet; 18 19 import java.io.IOException ; 20 21 import javax.servlet.Filter ; 22 import javax.servlet.FilterChain ; 23 import javax.servlet.FilterConfig ; 24 import javax.servlet.ServletContext ; 25 import javax.servlet.ServletException ; 26 import javax.servlet.ServletRequest ; 27 import javax.servlet.ServletResponse ; 28 import javax.servlet.http.HttpServletRequest ; 29 import javax.servlet.http.HttpServletResponse ; 30 31 import org.alfresco.web.app.Application; 32 33 45 public class AuthenticationFilter implements Filter  46 { 47 50 public void init(FilterConfig config) throws ServletException  51 { 52 this.context = config.getServletContext(); 53 } 54 55 58 public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) 59 throws IOException , ServletException  60 { 61 HttpServletRequest httpReq = (HttpServletRequest )req; 62 HttpServletResponse httpRes = (HttpServletResponse )res; 63 64 if (httpReq.getRequestURI().endsWith(getLoginPage()) == false) 66 { 67 AuthenticationStatus status = 68 AuthenticationHelper.authenticate(this.context, httpReq, httpRes, false); 69 70 if (status == AuthenticationStatus.Success || status == AuthenticationStatus.Guest) 71 { 72 chain.doFilter(req, res); 74 } 75 else 76 { 77 78 BaseServlet.redirectToLoginPage(httpReq, httpRes, context); 81 } 82 } 83 else 84 { 85 chain.doFilter(req, res); 87 } 88 } 89 90 93 public void destroy() 94 { 95 } 97 98 101 private String getLoginPage() 102 { 103 if (this.loginPage == null) 104 { 105 this.loginPage = Application.getLoginPage(this.context); 106 } 107 108 return this.loginPage; 109 } 110 111 112 private String loginPage = null; 113 114 private ServletContext context; 115 } 116 | Popular Tags |