Changeset 1303
- Timestamp:
- 14/07/06 17:32:01 (15 years ago)
- Location:
- TI12-security/trunk/python
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/python/NDG/CredWallet.py
r1301 r1303 538 538 539 539 540 if authzResp['statCode'] == auth orisationResp.accessDenied:540 if authzResp['statCode'] == authzResp.accessDenied: 541 541 raise CredWalletAuthorisationDenied,\ 542 542 "Authorisation denied: %s" % authzResp['errMsg'] 543 543 544 elif authzResp['statCode'] == auth orisationResp.accessGranted:544 elif authzResp['statCode'] == authzResp.accessGranted: 545 545 attCert = authzResp['credential'] 546 546 -
TI12-security/trunk/python/NDG/Session.py
r1302 r1303 107 107 108 108 109 #_________________________________________________________________________ 109 110 def __init__(self, *credWalletArgs, **credWalletKeys): 110 111 """Initialise UserSession with args and keywords to CredWallet""" … … 118 119 # it. These are stored in a list 119 120 self.__sessIDlist = [] 120 self. __createSessID()121 self.addNewSessID() 121 122 self.__credWallet = CredWallet(*credWalletArgs, **credWalletKeys) 122 123 123 124 # def __repr__(self): 125 # "Represent User Session" 126 # return "<UserSession instance>" 127 124 125 #_________________________________________________________________________ 128 126 def __setCookieDomain(self, cookieDomain): 129 127 """Set domain for cookie - set to None to assume domain of web server … … 137 135 self.__cookieDomain = cookieDomain 138 136 139 cookieDomain = property(fset=__setCookieDomain, 140 doc="Set cookie domain") 137 cookieDomain = property(fset=__setCookieDomain, doc="Set cookie domain") 141 138 142 139 … … 173 170 174 171 #_________________________________________________________________________ 175 def __createSessID(self):172 def addNewSessID(self): 176 173 """Add a new session ID to be associated with this UserSession 177 174 instance""" … … 769 766 try: 770 767 # Check for an existing session for the same user 771 userDN = proxyCert.dn 768 try: 769 userDN = str(X509CertParse(proxyCert).dn) 770 771 except Exception, e: 772 raise SessionMgrError, \ 773 "Parsing input proxy certificate DN for session create: %s"%\ 774 str(e) 775 772 776 if userDN in self.__dnDict: 773 raise SessionMgrError, \ 774 "Session already exists for user \"%s\"" % dn 775 776 # Create a new user session using the new proxy certificate 777 # and session ID 778 # 779 # Nb. Client pub/pri key info to allow message level 780 # encryption for responses from Attribute Authority WS 781 userSess = UserSession(proxyCert, 777 # Update existing session with proxy cert and add a new 778 # session ID to access it - a single session can be accessed 779 # via multiple session IDs e.g. a user may wish to access the 780 # same session from the their desktop PC and their laptop. 781 # Different session IDs are allocated in each case. 782 userSess = self.__dnDict[userDN] 783 userSess.addNewSessID() 784 785 else: 786 # Create a new user session using the new proxy certificate 787 # and session ID 788 # 789 # Nb. Client pub/pri key info to allow message level 790 # encryption for responses from Attribute Authority WS 791 userSess = UserSession(proxyCert, 782 792 caPubKeyFilePath=self.__prop['caCertFile'], 783 793 clntPubKeyFilePath=self.__prop['certFile'], 784 794 clntPriKeyFilePath=self.__prop['keyFile'], 785 795 clntPriKeyPwd=self.__prop['keyPPhrase'], 786 credRepos=self.__credRepos) 796 credRepos=self.__credRepos) 797 798 # Also allow access by user DN 799 self.__dnDict[userDN] = userSess 800 801 787 802 newSessID = userSess.latestSessID 788 803 … … 794 809 # Add new session to list 795 810 self.__sessDict[newSessID] = userSess 796 797 # Also allow access by user DN798 self.__dnDict[userDN] = userSess799 811 800 812 # Return new session … … 812 824 __connect2UserSession([proxyCert]|[sessID]) 813 825 814 proxyCert: proxy certificate corresponding to an existing826 proxyCert: proxy certificate string corresponding to an existing 815 827 session to connect to. 816 828 sessID: similiarly, a web browser session ID linking to an … … 840 852 elif 'proxyCert' in idKeys: 841 853 try: 842 userDN = X509Cert(idKeys['proxyCert']).dn854 userDN = str(X509CertParse(idKeys['proxyCert']).dn) 843 855 844 856 except Exception, e: … … 868 880 869 881 #_________________________________________________________________________ 870 def deleteUserSession(self, sessID= sessID, proxyCert=proxyCert):882 def deleteUserSession(self, sessID=None, proxyCert=None): 871 883 """Delete an existing session by providing a valid session ID or 872 884 proxy certificate - use for user logout … … 894 906 elif proxyCert: 895 907 try: 896 userDN = X509Cert(idKeys['proxyCert']).dn908 userDN = str(X509CertParse(idKeys['proxyCert']).dn) 897 909 898 910 except Exception, e: -
TI12-security/trunk/python/Tests/SecurityClientTest.py
r1302 r1303 147 147 # NDG.SessionMgrIO.AuthorisationResp 148 148 if 'errMsg' in authResp: 149 print "Authorisation failed for user %s" % authResp['errMsg']149 print "Authorisation failed for user: %s" % authResp['errMsg'] 150 150 else: 151 151 print "User authorised"
Note: See TracChangeset
for help on using the changeset viewer.