Ignore:
Timestamp:
22/05/09 10:11:16 (11 years ago)
Author:
pjkersha
Message:

Completed AuthorizationMiddleware? unit tests ndg.security.test.unit.wsgi.authz:

  • Test 8, 'test08AccessDeniedForAdminQueryArg' tries out the use case for a URI which can display additional content for users with admin privileges. The caller needs to be able to display the correct content according to whether the user has admin rights or not:
    1. the caller invokes /securedURI?admin=1
    2. if the user has admin, rights the PDP will grant access and the PEP will deliver this URI.
    3. if the user doesn't have admin rights, a special overloaded PEP result handler class detects that access was denied for the admin URI and redirects the user to a modified URI subtracting the admin flag. The application code can then deliver the appropriate content minus admin privileges.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/ndg.security.common/ndg/security/common/utils/classfactory.py

    r5322 r5330  
    1919        Exception.__init__(self, msg) 
    2020 
    21 def importClass(moduleName, className=None): 
     21def importClass(moduleName, className=None, objectType=None): 
    2222    '''Import a class from a string module name and class name. 
    2323     
     
    4141 
    4242    importedClass = getattr(module, className) 
     43 
     44    # Check class inherits from a base class 
     45    if objectType and not issubclass(importedClass, objectType): 
     46        raise TypeError("Specified class %s must be derived from %s; got %s" % 
     47                        (className, objectType, importedClass)) 
    4348     
    4449    log.info('Imported "%s" class from module, "%s"', className, moduleName) 
     
    9297             
    9398            # Import module name specified in properties file 
    94             importedClass = importClass(moduleName, className=className) 
     99            importedClass = importClass(moduleName,  
     100                                        className=className, 
     101                                        objectType=objectType) 
    95102        finally: 
    96103            # revert back to original sys path, if necessary 
     
    104111                  (moduleName, e.__class__, e)) 
    105112        raise  
    106  
    107     # Check class inherits from a base class 
    108     if objectType and not issubclass(importedClass, objectType): 
    109         raise ClassFactoryError("Specified class %s must be derived from %s" % 
    110                                 (className, objectType)) 
    111113 
    112114    # Instantiate class 
Note: See TracChangeset for help on using the changeset viewer.