1 16 package org.outerj.daisy.authentication; 17 18 import org.apache.avalon.framework.service.ServiceManager; 19 import org.apache.avalon.framework.service.Serviceable; 20 import org.apache.avalon.framework.service.ServiceException; 21 import org.apache.avalon.framework.logger.Logger; 22 import org.apache.avalon.framework.logger.LogEnabled; 23 import org.apache.avalon.framework.activity.Disposable; 24 import org.apache.avalon.framework.activity.Initializable; 25 26 import java.util.List ; 27 import java.util.ArrayList ; 28 import java.util.Iterator ; 29 30 public class AbstractAuthenticationFactory implements LogEnabled, Serviceable, Disposable, Initializable { 31 private ServiceManager serviceManager; 32 private AuthenticationSchemeRegistrar authenticationSchemeRegistrar; 33 protected Logger logger; 34 protected List schemes = new ArrayList (); 35 36 public void enableLogging(Logger logger) { 37 this.logger = logger; 38 } 39 40 43 public void service(ServiceManager serviceManager) throws ServiceException { 44 this.serviceManager = serviceManager; 45 this.authenticationSchemeRegistrar = (AuthenticationSchemeRegistrar)serviceManager.lookup("auth-scheme-registrar"); 46 } 47 48 public void initialize() throws Exception { 49 Iterator schemesIt = schemes.iterator(); 50 while (schemesIt.hasNext()) { 51 authenticationSchemeRegistrar.registerAuthenticationScheme((AuthenticationScheme)schemesIt.next()); 52 } 53 } 54 55 public void dispose() { 56 Iterator schemesIt = schemes.iterator(); 57 while (schemesIt.hasNext()) { 58 authenticationSchemeRegistrar.unregisterAuthenticationScheme((AuthenticationScheme)schemesIt.next()); 59 } 60 serviceManager.release(authenticationSchemeRegistrar); 61 } 62 } 63 | Popular Tags |