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 JResourceDSFactory extends JResourceFactory { 46 47 50 private static final String FACTORY_TYPE = "org.objectweb.jonas.security.realm.factory.JResourceDS"; 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 dsName = (String ) ref.get("dsName").getContent(); 87 String userTable = (String ) ref.get("userTable").getContent(); 88 String userTableUsernameCol = (String ) ref.get("userTableUsernameCol").getContent(); 89 String userTablePasswordCol = (String ) ref.get("userTablePasswordCol").getContent(); 90 String roleTable = (String ) ref.get("roleTable").getContent(); 91 String roleTableUsernameCol = (String ) ref.get("roleTableUsernameCol").getContent(); 92 String roleTableRolenameCol = (String ) ref.get("roleTableRolenameCol").getContent(); 93 String userPrincipalsQuery = (String ) ref.get("userPrincipalsQuery").getContent(); 94 String userRolesQuery = (String ) ref.get("userRolesQuery").getContent(); 95 String algorithm = (String ) ref.get("algorithm").getContent(); 96 97 JResourceDS jResourceDS = new JResourceDS(); 99 jResourceDS.setName(jResName); 100 jResourceDS.setDsName(dsName); 101 jResourceDS.setUserTable(userTable); 102 jResourceDS.setUserTableUsernameCol(userTableUsernameCol); 103 jResourceDS.setUserTablePasswordCol(userTablePasswordCol); 104 jResourceDS.setRoleTable(roleTable); 105 jResourceDS.setRoleTableUsernameCol(roleTableUsernameCol); 106 jResourceDS.setRoleTableRolenameCol(roleTableRolenameCol); 107 jResourceDS.setUserPrincipalsQuery(userPrincipalsQuery); 108 jResourceDS.setUserRolesQuery(userRolesQuery); 109 jResourceDS.setAlgorithm(algorithm); 110 111 return jResourceDS; 112 } 113 114 } | Popular Tags |