Ignore:
Timestamp:
19/11/08 12:33:21 (11 years ago)
Author:
pjkersha
Message:

Updated CredentialWallet? unit tests to include a call to a locally instantiated Attribute Authority

File:
1 edited

Legend:

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

    r4437 r4446  
    725725    def _setAttributeAuthorityURI(self, attributeAuthorityURI): 
    726726        """Set property method for Attribute Authority Web Service URI to 
    727         connect to.  This method ALSO SETS UP THE CLIENT INTERFACE 
     727        connect to.  This method ALSO RESETS attributeAuthority - a local 
     728        Attribute Authority instance - to None 
    728729         
    729730        @type attributeAuthorityURI: basestring/None 
     
    735736         
    736737        self._attributeAuthorityURI = attributeAuthorityURI 
     738         
     739        # Re-initialize local instance 
     740        self._attributeAuthority = \ 
     741                    CredentialWallet.propertyDefaults['attributeAuthority'] 
    737742             
    738743    attributeAuthorityURI = property(fget=_getAttributeAuthorityURI, 
     
    753758    def _setAttributeAuthority(self, attributeAuthority): 
    754759        """Set property method for Attribute Authority Web Service instance to 
    755         connect to. 
     760        connect to.  This method ALSO RESETS attributeAuthorityURI - the  
     761        address of a remote Attribute Authority - to None 
    756762         
    757763        @type attributeAuthority: ndg.security.server.attributeauthority.AttributeAuthority 
     
    763769             
    764770        self._attributeAuthority = attributeAuthority 
     771         
     772        # Re-initialize setting for remote service 
     773        self._attributeAuthorityURI = \ 
     774                    CredentialWallet.propertyDefaults['attributeAuthorityURI'] 
    765775             
    766776    attributeAuthority = property(fget=_getAttributeAuthority, 
     
    10101020        Attribute Authority. 
    10111021         
    1012         @type attributeAuthority: string 
     1022        @type attributeAuthority: ndg.security.server.attributeauthority.AttributeAuthority 
    10131023        @param attributeAuthority: Alternative to attributeAuthorityURI - to  
    1014         run on the local machine, specify the local Attribute Authority  
     1024        run on the local machine, specify a local Attribute Authority  
    10151025        instance. 
    10161026 
     
    10311041            userId = self.userId 
    10321042             
     1043        if attributeAuthority is not None and \ 
     1044           attributeAuthorityURI is not None: 
     1045            raise KeyError("Both attributeAuthorityURI and attributeAuthority " 
     1046                           "keywords have been set") 
     1047         
    10331048        if attributeAuthority is None: 
    10341049            attributeAuthority = self.attributeAuthority 
     
    10381053             
    10391054        # Set a client alias according to whether the Attribute Authority is 
    1040         # being called locally or asa remote service 
     1055        # being called locally or as a remote service 
    10411056        if attributeAuthorityURI is not None: 
    10421057            # Call Remote Service at given URI 
    1043             attributeAuthorityClnt = self._createAttributeAuthorityClnt( 
    1044                                                     attributeAuthorityURI)                             
     1058            aaInterface = self._createAttributeAuthorityClnt( 
     1059                                                        attributeAuthorityURI)                             
     1060            log.debug('CredentialWallet._getAttCert for remote Attribute ' 
     1061                      'Authority service: "%s" ...' % attributeAuthorityURI) 
     1062                 
    10451063        elif attributeAuthority is not None: 
    10461064            # Call local based Attribute Authority with settings from the  
    10471065            # configuration file attributeAuthority 
    1048             attributeAuthorityClnt = attributeAuthority 
     1066            aaInterface = attributeAuthority 
     1067            log.debug('CredentialWallet._getAttCert for local Attribute ' 
     1068                      'Authority: "%r" ...' % attributeAuthority) 
    10491069        else: 
    10501070            raise CredentialWalletError("Error requesting attribute: " 
     
    10561076            # Request a new attribute certificate from the Attribute 
    10571077            # Authority 
    1058             log.debug('CredentialWallet._getAttCert for service: "%s" ...' %  
    1059                       attributeAuthorityURI or attributeAuthority) 
    1060                  
    1061             attCert = attributeAuthorityClnt.getAttCert(userId=userId, 
    1062                                                         userAttCert=extAttCert) 
     1078            attCert = aaInterface.getAttCert(userId=userId, 
     1079                                             userAttCert=extAttCert) 
    10631080             
    10641081            log.info('Granted Attribute Certificate from issuer DN = "%s"'% 
     
    10671084        except (AttributeAuthorityAccessDenied, AttributeRequestDenied), e: 
    10681085            # AttributeAuthorityAccessDenied is raised if  
    1069             # attributeAuthorityClnt is a local AA instance and  
     1086            # aaInterface is a local AA instance and  
    10701087            # AttributeRequestDenied is raised for a client to a remote AA 
    10711088            # service 
     
    10731090                     
    10741091        except Exception, e: 
    1075             raise CredentialWalletError("Requesting attribute " 
    1076                                         "certificate: %s" % e) 
     1092            raise CredentialWalletError("Requesting attribute certificate: %s"% 
     1093                                        e) 
    10771094 
    10781095        # Update attribute Certificate instance with CA's certificate ready  
Note: See TracChangeset for help on using the changeset viewer.