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.exolab.castor.jdo.Database; 32 import org.infoglue.cms.entities.kernel.BaseEntityVO; 33 import org.infoglue.cms.entities.management.RoleVO; 34 import org.infoglue.cms.exception.ConstraintException; 35 import org.infoglue.cms.exception.SystemException; 36 import org.infoglue.cms.security.AuthorizationModule; 37 import org.infoglue.cms.security.InfoGlueAuthenticationFilter; 38 import org.infoglue.cms.security.InfoGlueRole; 39 import org.infoglue.cms.util.sorters.ReflectionComparator; 40 41 46 47 public class RoleControllerProxy extends BaseController 48 { 49 private AuthorizationModule authorizationModule = null; 50 private Database transactionObject = null; 51 52 public RoleControllerProxy(Database transactionObject) 53 { 54 this.transactionObject = transactionObject; 55 } 56 57 public static RoleControllerProxy getController() 58 { 59 return new RoleControllerProxy(null); 60 } 61 62 public static RoleControllerProxy getController(Database transactionObject) 63 { 64 return new RoleControllerProxy(transactionObject); 65 } 66 67 70 71 private AuthorizationModule getAuthorizationModule() 72 { 73 try 76 { 77 authorizationModule = (AuthorizationModule)Class.forName(InfoGlueAuthenticationFilter.authorizerClass).newInstance(); 78 authorizationModule.setExtraProperties(InfoGlueAuthenticationFilter.extraProperties); 79 authorizationModule.setTransactionObject(this.transactionObject); 80 } 81 catch(Exception e) 82 { 83 e.printStackTrace(); 84 } 85 87 return authorizationModule; 88 } 89 90 93 94 public boolean getSupportUpdate() throws ConstraintException, SystemException, Exception 95 { 96 return getAuthorizationModule().getSupportUpdate(); 97 } 98 99 102 103 public boolean getSupportDelete() throws ConstraintException, SystemException, Exception 104 { 105 return getAuthorizationModule().getSupportDelete(); 106 } 107 108 111 112 public boolean getSupportCreate() throws ConstraintException, SystemException, Exception 113 { 114 return getAuthorizationModule().getSupportCreate(); 115 } 116 117 120 121 public List getAllRoles() throws ConstraintException, SystemException, Exception 122 { 123 List roles = new ArrayList (); 124 125 roles = getAuthorizationModule().getRoles(); 126 Collections.sort(roles, new ReflectionComparator("name")); 127 128 return roles; 129 } 130 131 134 135 public InfoGlueRole getRole(String roleName) throws ConstraintException, SystemException, Exception 136 { 137 InfoGlueRole infoGlueRole = null; 138 139 infoGlueRole = getAuthorizationModule().getAuthorizedInfoGlueRole(roleName); 140 141 return infoGlueRole; 142 } 143 144 147 148 public List getInfoGluePrincipals(String roleName) throws ConstraintException, SystemException, Exception 149 { 150 List infoGluePrincipals = new ArrayList (); 151 152 infoGluePrincipals = getAuthorizationModule().getUsers(roleName); 153 Collections.sort(infoGluePrincipals, new ReflectionComparator("name")); 154 155 return infoGluePrincipals; 156 } 157 158 159 162 163 public InfoGlueRole createRole(RoleVO roleVO) throws ConstraintException, SystemException, Exception 164 { 165 InfoGlueRole infoGlueRole = null; 166 167 getAuthorizationModule().createInfoGlueRole(roleVO); 168 169 return getRole(roleVO.getRoleName()); 170 } 171 172 175 176 public void updateRole(RoleVO roleVO, String [] userNames) throws ConstraintException, SystemException, Exception 177 { 178 getAuthorizationModule().updateInfoGlueRole(roleVO, userNames); 179 } 180 181 184 185 public void deleteRole(String roleName) throws ConstraintException, SystemException, Exception 186 { 187 getAuthorizationModule().deleteInfoGlueRole(roleName); 188 AccessRightController.getController().delete(roleName); 189 } 190 191 public BaseEntityVO getNewVO() 192 { 193 return null; 194 } 195 196 } 197 | Popular Tags |