1 package com.atlassian.seraph.auth; 2 3 import com.atlassian.seraph.config.SecurityConfig; 4 5 import javax.servlet.http.HttpServletRequest ; 6 import javax.servlet.http.HttpServletResponse ; 7 import java.io.Serializable ; 8 import java.util.Map ; 9 import java.security.Principal ; 10 11 14 public abstract class AbstractAuthenticator implements Authenticator, Serializable 15 { 16 private Map params; 17 private SecurityConfig config; 18 19 public void init(Map params, SecurityConfig config) 20 { 21 this.params = params; 22 this.config = config; 23 } 24 25 public void destroy() 26 { 27 } 28 29 30 public abstract boolean isUserInRole(HttpServletRequest request, String role); 31 32 public String getRemoteUser(HttpServletRequest request) 33 { 34 Principal user = getUser(request); 35 36 if (user == null) 37 return null; 38 39 return user.getName(); 40 } 41 42 public Principal getUser(HttpServletRequest request) 43 { 44 return getUser(request, null); 45 } 46 47 public abstract Principal getUser(HttpServletRequest request, HttpServletResponse response); 48 49 public boolean login(HttpServletRequest request, HttpServletResponse response, String username, String password) throws AuthenticatorException 50 { 51 return login(request, response, username, password, false); 52 53 } 54 55 public abstract boolean login(HttpServletRequest request, HttpServletResponse response, String username, String password, boolean cookie) throws AuthenticatorException; 56 57 public abstract boolean logout(HttpServletRequest request, HttpServletResponse response) throws AuthenticatorException; 58 59 protected SecurityConfig getConfig() { 60 return config; 61 } 62 } 63 | Popular Tags |