1 26 27 package org.objectweb.jonas.security.realm.factory; 28 29 import java.util.Hashtable ; 31 32 import javax.naming.Context ; 34 import javax.naming.Name ; 35 import javax.naming.Reference ; 36 37 import org.objectweb.util.monolog.api.BasicLevel; 39 40 45 public class JResourceLDAPFactory extends JResourceFactory { 46 47 50 private static final String FACTORY_TYPE = "org.objectweb.jonas.security.realm.factory.JResourceLDAP"; 51 52 70 public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { 71 72 Reference ref = (Reference ) obj; 74 75 String clname = ref.getClassName(); 77 78 if (!ref.getClassName().equals(FACTORY_TYPE)) { 80 getLogger().log(BasicLevel.ERROR, "Cannot create object : required type is '" + FACTORY_TYPE 81 + "', but found type is '" + clname + "'."); 82 return (null); 83 } 84 85 String jResName = (String ) ref.get("name").getContent(); 86 String initialContextFactory = (String ) ref.get("initialContextFactory").getContent(); 87 String providerUrl = (String ) ref.get("providerUrl").getContent(); 88 String securityAuthentication = (String ) ref.get("securityAuthentication").getContent(); 89 String securityPrincipal = (String ) ref.get("securityPrincipal").getContent(); 90 String securityCredentials = (String ) ref.get("securityCredentials").getContent(); 91 String securityProtocol = (String ) ref.get("securityProtocol").getContent(); 92 String language = (String ) ref.get("language").getContent(); 93 String referral = (String ) ref.get("referral").getContent(); 94 String stateFactories = (String ) ref.get("stateFactories").getContent(); 95 String authenticationMode = (String ) ref.get("authenticationMode").getContent(); 96 String userPasswordAttribute = (String ) ref.get("userPasswordAttribute").getContent(); 97 String userRolesAttribute = (String ) ref.get("userRolesAttribute").getContent(); 98 String roleNameAttribute = (String ) ref.get("roleNameAttribute").getContent(); 99 String baseDN = (String ) ref.get("baseDN").getContent(); 100 String userDN = (String ) ref.get("userDN").getContent(); 101 String userSearchFilter = (String ) ref.get("userSearchFilter").getContent(); 102 String roleDN = (String ) ref.get("roleDN").getContent(); 103 String roleSearchFilter = (String ) ref.get("roleSearchFilter").getContent(); 104 String algorithm = (String ) ref.get("algorithm").getContent(); 105 106 JResourceLDAP jResourceLDAP = new JResourceLDAP(); 108 jResourceLDAP.setName(jResName); 109 jResourceLDAP.setInitialContextFactory(initialContextFactory); 110 jResourceLDAP.setProviderUrl(providerUrl); 111 jResourceLDAP.setSecurityAuthentication(securityAuthentication); 112 jResourceLDAP.setSecurityPrincipal(securityPrincipal); 113 jResourceLDAP.setSecurityCredentials(securityCredentials); 114 jResourceLDAP.setSecurityProtocol(securityProtocol); 115 jResourceLDAP.setLanguage(language); 116 jResourceLDAP.setReferral(referral); 117 jResourceLDAP.setStateFactories(stateFactories); 118 jResourceLDAP.setAuthenticationMode(authenticationMode); 119 jResourceLDAP.setUserPasswordAttribute(userPasswordAttribute); 120 jResourceLDAP.setUserRolesAttribute(userRolesAttribute); 121 jResourceLDAP.setRoleNameAttribute(roleNameAttribute); 122 jResourceLDAP.setBaseDN(baseDN); 123 jResourceLDAP.setUserDN(userDN); 124 jResourceLDAP.setUserSearchFilter(userSearchFilter); 125 jResourceLDAP.setRoleDN(roleDN); 126 jResourceLDAP.setRoleSearchFilter(roleSearchFilter); 127 jResourceLDAP.setAlgorithm(algorithm); 128 129 return jResourceLDAP; 130 } 131 132 } | Popular Tags |