00001
00027 package org.objectweb.jonas.security.realm.factory;
00028
00029
00030 import java.util.Hashtable;
00031
00032
00033 import javax.naming.Context;
00034 import javax.naming.Name;
00035 import javax.naming.Reference;
00036
00037
00038 import org.objectweb.util.monolog.api.BasicLevel;
00039
00045 public class JResourceLDAPFactory extends JResourceFactory {
00046
00050 private static final String FACTORY_TYPE = "org.objectweb.jonas.security.realm.factory.JResourceLDAP";
00051
00070 public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception {
00071
00072
00073 Reference ref = (Reference) obj;
00074
00075
00076 String clname = ref.getClassName();
00077
00078
00079 if (!ref.getClassName().equals(FACTORY_TYPE)) {
00080 getLogger().log(BasicLevel.ERROR, "Cannot create object : required type is '" + FACTORY_TYPE
00081 + "', but found type is '" + clname + "'.");
00082 return (null);
00083 }
00084
00085 String jResName = (String) ref.get("name").getContent();
00086 String initialContextFactory = (String) ref.get("initialContextFactory").getContent();
00087 String providerUrl = (String) ref.get("providerUrl").getContent();
00088 String securityAuthentication = (String) ref.get("securityAuthentication").getContent();
00089 String securityPrincipal = (String) ref.get("securityPrincipal").getContent();
00090 String securityCredentials = (String) ref.get("securityCredentials").getContent();
00091 String securityProtocol = (String) ref.get("securityProtocol").getContent();
00092 String language = (String) ref.get("language").getContent();
00093 String referral = (String) ref.get("referral").getContent();
00094 String stateFactories = (String) ref.get("stateFactories").getContent();
00095 String authenticationMode = (String) ref.get("authenticationMode").getContent();
00096 String userPasswordAttribute = (String) ref.get("userPasswordAttribute").getContent();
00097 String userRolesAttribute = (String) ref.get("userRolesAttribute").getContent();
00098 String roleNameAttribute = (String) ref.get("roleNameAttribute").getContent();
00099 String baseDN = (String) ref.get("baseDN").getContent();
00100 String userDN = (String) ref.get("userDN").getContent();
00101 String userSearchFilter = (String) ref.get("userSearchFilter").getContent();
00102 String roleDN = (String) ref.get("roleDN").getContent();
00103 String roleSearchFilter = (String) ref.get("roleSearchFilter").getContent();
00104 String algorithm = (String) ref.get("algorithm").getContent();
00105
00106
00107 JResourceLDAP jResourceLDAP = new JResourceLDAP();
00108 jResourceLDAP.setName(jResName);
00109 jResourceLDAP.setInitialContextFactory(initialContextFactory);
00110 jResourceLDAP.setProviderUrl(providerUrl);
00111 jResourceLDAP.setSecurityAuthentication(securityAuthentication);
00112 jResourceLDAP.setSecurityPrincipal(securityPrincipal);
00113 jResourceLDAP.setSecurityCredentials(securityCredentials);
00114 jResourceLDAP.setSecurityProtocol(securityProtocol);
00115 jResourceLDAP.setLanguage(language);
00116 jResourceLDAP.setReferral(referral);
00117 jResourceLDAP.setStateFactories(stateFactories);
00118 jResourceLDAP.setAuthenticationMode(authenticationMode);
00119 jResourceLDAP.setUserPasswordAttribute(userPasswordAttribute);
00120 jResourceLDAP.setUserRolesAttribute(userRolesAttribute);
00121 jResourceLDAP.setRoleNameAttribute(roleNameAttribute);
00122 jResourceLDAP.setBaseDN(baseDN);
00123 jResourceLDAP.setUserDN(userDN);
00124 jResourceLDAP.setUserSearchFilter(userSearchFilter);
00125 jResourceLDAP.setRoleDN(roleDN);
00126 jResourceLDAP.setRoleSearchFilter(roleSearchFilter);
00127 jResourceLDAP.setAlgorithm(algorithm);
00128
00129 return jResourceLDAP;
00130 }
00131
00132 }