Changeset 4158 for TI12-security/trunk/python/ndg.security.server/ndg/security/server/AttAuthority/__init__.py
- Timestamp:
- 01/09/08 14:37:03 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/python/ndg.security.server/ndg/security/server/AttAuthority/__init__.py
r4139 r4158 41 41 42 42 from ndg.security.common.utils.ConfigFileParsers import readAndValidateProperties 43 from ndg.security.common.utils.ClassFactory import instantiateClass 43 44 44 45 #_____________________________________________________________________________ … … 130 131 read. Set this flag to False to override. 131 132 """ 132 log.info("Initialising service ... 133 log.info("Initialising service ...") 133 134 134 135 # Base class initialisation … … 182 183 self.__issuerSerialNumber = self.__cert.serialNumber 183 184 184 185 185 # Load host sites custom user roles interface to enable the AA to 186 186 # assign roles in an attribute certificate on a getAttCert request 187 self.loadUserRolesInterface() 188 187 self.__userRoles = instantiateClass(self.__prop['userRolesModName'],\ 188 self.__prop['userRolesClassName'],\ 189 moduleFilePath=self.__prop.get('userRolesModFilePath'),\ 190 objectType=AAUserRoles, \ 191 classProperties=self.__prop.get('userRolesPropFile')) 189 192 190 193 attCertFilePath = os.path.join(self.__prop['attCertDir'], … … 201 204 ''' 202 205 # Configuration file properties are held together in a dictionary 203 self.__prop = readAndValidateProperties(self.propFilePath, validKeys=AttAuthority.__validKeys) 206 self.__prop = readAndValidateProperties(self.propFilePath, \ 207 validKeys=AttAuthority.__validKeys) 204 208 205 209 # add the WS-security properties to the main properties … … 220 224 'Invalid directory path Attribute Certificates store "%s": %s' % \ 221 225 (self.__prop['attCertDir'], osError.strerror) 222 223 #_________________________________________________________________________224 def loadUserRolesInterface(self):225 """Set-up user roles interface - load host sites custom AAUserRoles226 derived class. This class interfaces with the sites mechanism for227 mapping user ID to the roles to which they are entitled. This228 could be via a user database"""229 230 log.debug("Loading User roles interface ...")231 try:232 try:233 # Module file path may be None if the new module to be loaded234 # can be found in the existing system path235 if self.__prop['userRolesModFilePath'] is not None:236 if not os.path.exists(\237 self.__prop['userRolesModFilePath']):238 raise Exception, "File path '%s' doesn't exist" % \239 self.__prop['userRolesModFilePath']240 241 # Temporarily extend system path ready for import242 sysPathBak = sys.path[:]243 244 sys.path.append(self.__prop['userRolesModFilePath'])245 246 # Import module name specified in properties file247 userRolesMod = __import__(self.__prop['userRolesModName'],248 globals(),249 locals(),250 [self.__prop['userRolesClassName']])251 252 userRolesClass = eval('userRolesMod.' + \253 self.__prop['userRolesClassName'])254 finally:255 try:256 sys.path[:] = sysPathBak257 except NameError:258 # sysPathBak may not have been defined259 pass260 261 except Exception, e:262 raise AttAuthorityError,'Importing User Roles module: %s' % str(e)263 264 # Check class inherits from AAUserRoles abstract base class265 if not issubclass(userRolesClass, AAUserRoles):266 raise AttAuthorityError, \267 "User Roles class %s must be derived from AAUserRoles" % \268 self.__prop['userRolesClassName']269 270 271 # Instantiate custom class272 try:273 self.__userRoles=userRolesClass(self.__prop['userRolesPropFile'])274 275 except Exception, e:276 raise AttAuthorityError, \277 "Error instantiating User Roles interface: " + str(e)278 279 log.info(\280 'Instantiated "%s" class from user roles module: "%s" in "%s"' %\281 (self.__prop['userRolesClassName'],282 self.__prop['userRolesModName'],283 self.__prop['userRolesModFilePath']))284 226 285 227
Note: See TracChangeset
for help on using the changeset viewer.