1 28 package net.sf.jguard.ext.authentication.manager; 29 30 31 32 import java.util.Map ; 33 import java.util.logging.Logger ; 34 35 import net.sf.jguard.ext.authentication.AuthenticationException; 36 37 38 39 43 public class AuthenticationManagerFactory { 44 45 private static AuthenticationManager authenticationManager; 46 private static Logger logger = Logger.getLogger(AuthenticationManagerFactory.class.getName()); 47 48 55 public static AuthenticationManager getAuthenticationManager() { 56 return authenticationManager; 57 } 58 59 66 public static boolean createAuthenticationManager(String authenticationManagerImpl,Map map) throws AuthenticationException{ 67 if(authenticationManager!=null){ 68 return false; 69 } 70 logger.info("authenticationManagerImpl="+authenticationManagerImpl); 71 if(authenticationManagerImpl==null || authenticationManagerImpl.equals("")){ 72 throw new AuthenticationException(" authenticationManager implementation is null or empty "+authenticationManagerImpl); 73 } 74 try { 75 76 authenticationManager = (AuthenticationManager)Class.forName(authenticationManagerImpl).newInstance(); 77 authenticationManager.init(map); 78 79 } catch (InstantiationException e) { 80 System.out.println("InstantiationException DAOImpl problem"+e.getMessage()); 81 throw new AuthenticationException(" InstantiationException DAOImpl "+e.getMessage(),e); 82 } catch (IllegalAccessException e) { 83 System.out.println("IllegalAccessException DAOImpl problem"+e.getMessage()); 84 throw new AuthenticationException(" IllegalAccessException DAOImpl "+e.getMessage(),e); 85 } catch (ClassNotFoundException e) { 86 System.out.println("ClassNotFoundException DAOImpl problem"+e.getMessage()); 87 throw new AuthenticationException(" ClassNotFoundException DAOImpl "+e.getMessage(),e); 88 } 89 return true; 90 } 91 92 public static void setAuthenticationManager( 93 AuthenticationManager authenticationManager) { 94 AuthenticationManagerFactory.authenticationManager = authenticationManager; 95 } 96 } 97 | Popular Tags |