1 16 package org.outerj.daisy.authentication.impl; 17 18 import org.apache.avalon.framework.configuration.Configuration; 19 import org.apache.avalon.framework.configuration.ConfigurationException; 20 import org.apache.avalon.framework.configuration.Configurable; 21 import org.apache.avalon.framework.service.ServiceManager; 22 import org.apache.avalon.framework.service.ServiceException; 23 import org.outerj.daisy.authentication.*; 24 25 30 public class NtlmAuthenticationFactory extends AbstractAuthenticationFactory implements Configurable { 31 34 public void service(ServiceManager serviceManager) throws ServiceException { 35 super.service(serviceManager); 36 } 37 38 public void configure(Configuration configuration) throws ConfigurationException { 39 Configuration[] schemeConfs = configuration.getChildren("scheme"); 40 for (int i = 0; i < schemeConfs.length; i++) { 41 String name = schemeConfs[i].getAttribute("name"); 42 String description = schemeConfs[i].getAttribute("description"); 43 String domainControllerAddress = schemeConfs[i].getChild("domainControllerAddress").getValue(); 44 String domain = schemeConfs[i].getChild("domain").getValue(); 45 UserCreator userCreator = UserCreatorFactory.createUser(schemeConfs[i], name); 46 47 AuthenticationScheme scheme = new NtlmAuthenticationScheme(name, description, domainControllerAddress, domain, userCreator); 48 Configuration cacheConf = schemeConfs[i].getChild("cache"); 49 if (cacheConf.getAttributeAsBoolean("enabled")) { 50 int maxCacheSize = cacheConf.getAttributeAsInteger("maxCacheSize", 3000); 51 long maxCacheDuration = cacheConf.getAttributeAsLong("maxCacheDuration", 30 * 60 * 1000); scheme = new CachingAuthenticationScheme(scheme, maxCacheDuration, maxCacheSize); 53 } 54 schemes.add(scheme); 55 } 56 } 57 } 58 | Popular Tags |