1 16 package org.outerj.daisy.authentication.impl; 17 18 import org.apache.avalon.framework.configuration.Configurable; 19 import org.apache.avalon.framework.configuration.Configuration; 20 import org.apache.avalon.framework.configuration.ConfigurationException; 21 import org.apache.avalon.framework.service.ServiceManager; 22 import org.apache.avalon.framework.service.ServiceException; 23 import org.outerj.daisy.authentication.*; 24 25 import java.util.*; 26 27 32 public class LdapAuthenticationFactory extends AbstractAuthenticationFactory implements Configurable { 33 36 public void service(ServiceManager serviceManager) throws ServiceException { 37 super.service(serviceManager); 38 } 39 40 public void configure(Configuration configuration) throws ConfigurationException { 41 Configuration[] schemeConfs = configuration.getChildren("scheme"); 42 for (int i = 0; i < schemeConfs.length; i++) { 43 String name = schemeConfs[i].getAttribute("name"); 44 String description = schemeConfs[i].getAttribute("description"); 45 Configuration[] properties = schemeConfs[i].getChild("environment").getChildren("property"); 46 Map templateEnvironment = new HashMap(); 47 for (int k = 0; k < properties.length; k++) { 48 templateEnvironment.put(properties[k].getAttribute("name"), properties[k].getAttribute("value")); 49 } 50 UserCreator userCreator = UserCreatorFactory.createUser(schemeConfs[i], name); 51 AuthenticationScheme scheme = new LdapAuthenticationScheme(name, description, templateEnvironment, userCreator, logger); 52 Configuration cacheConf = schemeConfs[i].getChild("cache"); 53 if (cacheConf.getAttributeAsBoolean("enabled")) { 54 int maxCacheSize = cacheConf.getAttributeAsInteger("maxCacheSize", 3000); 55 long maxCacheDuration = cacheConf.getAttributeAsLong("maxCacheDuration", 30 * 60 * 1000); scheme = new CachingAuthenticationScheme(scheme, maxCacheDuration, maxCacheSize); 57 } 58 schemes.add(scheme); 59 } 60 } 61 } 62 | Popular Tags |