1 23 24 25 package org.infoglue.cms.controllers.kernel.impl.simple; 26 27 import java.util.ArrayList ; 28 import java.util.Collections ; 29 import java.util.List ; 30 31 import org.apache.log4j.Logger; 32 import org.exolab.castor.jdo.Database; 33 import org.infoglue.cms.entities.kernel.BaseEntityVO; 34 import org.infoglue.cms.entities.management.SystemUserVO; 35 import org.infoglue.cms.exception.ConstraintException; 36 import org.infoglue.cms.exception.SystemException; 37 import org.infoglue.cms.security.AuthorizationModule; 38 import org.infoglue.cms.security.InfoGlueAuthenticationFilter; 39 import org.infoglue.cms.security.InfoGluePrincipal; 40 import org.infoglue.cms.util.sorters.ReflectionComparator; 41 import org.infoglue.deliver.util.CacheController; 42 43 44 49 50 public class UserControllerProxy extends BaseController 51 { 52 private final static Logger logger = Logger.getLogger(UserControllerProxy.class.getName()); 53 54 private AuthorizationModule authorizationModule = null; 55 private Database transactionObject = null; 56 57 public UserControllerProxy(Database transactionObject) 58 { 59 this.transactionObject = transactionObject; 60 } 61 62 public static UserControllerProxy getController() 63 { 64 return new UserControllerProxy(null); 65 } 66 67 public static UserControllerProxy getController(Database transactionObject) 68 { 69 return new UserControllerProxy(transactionObject); 70 } 71 72 75 76 private AuthorizationModule getAuthorizationModule() throws SystemException 77 { 78 try 81 { 82 logger.info("InfoGlueAuthenticationFilter.authorizerClass:" + InfoGlueAuthenticationFilter.authorizerClass); 83 authorizationModule = (AuthorizationModule)Class.forName(InfoGlueAuthenticationFilter.authorizerClass).newInstance(); 84 logger.info("authorizationModule:" + authorizationModule); 85 authorizationModule.setExtraProperties(InfoGlueAuthenticationFilter.extraProperties); 86 authorizationModule.setTransactionObject(this.transactionObject); 87 logger.info("InfoGlueAuthenticationFilter.extraProperties:" + InfoGlueAuthenticationFilter.extraProperties); 88 } 89 catch(Exception e) 90 { 91 logger.error("There was an error initializing the authorizerClass:" + e.getMessage(), e); 93 throw new SystemException("There was an error initializing the authorizerClass:" + e.getMessage(), e); 94 } 95 97 return authorizationModule; 98 } 99 100 103 104 public boolean getSupportUpdate() throws ConstraintException, SystemException, Exception 105 { 106 return getAuthorizationModule().getSupportUpdate(); 107 } 108 109 112 113 public boolean getSupportDelete() throws ConstraintException, SystemException, Exception 114 { 115 return getAuthorizationModule().getSupportDelete(); 116 } 117 118 121 122 public boolean getSupportCreate() throws ConstraintException, SystemException, Exception 123 { 124 return getAuthorizationModule().getSupportCreate(); 125 } 126 127 130 131 public List getAllUsers() throws ConstraintException, SystemException, Exception 132 { 133 List users = new ArrayList (); 134 135 users = getAuthorizationModule().getUsers(); 136 137 Collections.sort(users, new ReflectionComparator("name")); 138 139 return users; 140 } 141 142 145 146 public List getFilteredUsers(String firstName, String lastName, String userName, String email, String [] roleNames) throws Exception 147 { 148 List users = new ArrayList (); 149 150 users = getAuthorizationModule().getFilteredUsers(firstName, lastName, userName, email, roleNames); 151 152 return users; 153 } 154 155 158 159 public InfoGluePrincipal getUser(String userName) throws ConstraintException, SystemException, Exception 160 { 161 163 InfoGluePrincipal infoGluePrincipal = (InfoGluePrincipal)CacheController.getCachedObjectFromAdvancedCache("principalCache", userName, 300); 164 if(infoGluePrincipal == null) 165 { 166 infoGluePrincipal = getAuthorizationModule().getAuthorizedInfoGluePrincipal(userName); 167 168 if(infoGluePrincipal != null) 169 CacheController.cacheObjectInAdvancedCache("principalCache", userName, infoGluePrincipal, new String []{}, false); 170 } 172 173 175 return infoGluePrincipal; 176 } 177 178 179 182 183 public InfoGluePrincipal createUser(SystemUserVO systemUserVO) throws ConstraintException, SystemException, Exception 184 { 185 InfoGluePrincipal infoGluePrincipal = null; 186 187 getAuthorizationModule().createInfoGluePrincipal(systemUserVO); 188 189 return getUser(systemUserVO.getUserName()); 190 } 191 192 195 196 public void updateUser(SystemUserVO systemUserVO, String [] roleNames, String [] groupNames) throws ConstraintException, SystemException, Exception 197 { 198 getAuthorizationModule().updateInfoGluePrincipal(systemUserVO, roleNames, groupNames); 199 } 200 201 204 205 public void updateUserPassword(String userName) throws ConstraintException, SystemException, Exception 206 { 207 getAuthorizationModule().updateInfoGluePrincipalPassword(userName); 208 } 209 210 213 214 public void updateUserPassword(String userName, String oldPassword, String newPassword) throws ConstraintException, SystemException, Exception 215 { 216 getAuthorizationModule().updateInfoGluePrincipalPassword(userName, oldPassword, newPassword); 217 } 218 219 222 223 public void deleteUser(String userName) throws ConstraintException, SystemException, Exception 224 { 225 getAuthorizationModule().deleteInfoGluePrincipal(userName); 226 } 227 228 public BaseEntityVO getNewVO() 229 { 230 return null; 231 } 232 233 } 234 | Popular Tags |