Changeset 541


Ignore:
Timestamp:
31/01/06 17:12:19 (14 years ago)
Author:
pjkersha
Message:
  • Working version using XML encrypted WSDL method args. *

Session.py: SessionMgr? addUser and connect methods - added functionality so
that input XML may be accepted as encrypted or plain text.

sessionMgr_services_server.py: adjustments taking into account the changes
mentioned above.

SessionClient?.py: changes for tests.

Location:
security/trunk/python/NDG
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • security/trunk/python/NDG/Session.py

    r539 r541  
    386386                caConfigFilePath=None, 
    387387                caPassPhrase=None, 
    388                 encrAddUserReqTxt=None,  
     388                reqXMLtxt=None,  
    389389                **addUserReqKeys):         
    390390        """Register a new user with NDG data centre 
    391391         
    392         addUser([caConfigFilePath, ]|[, caPassPhrase][, encrAddUserReqTxt] 
     392        addUser([caConfigFilePath, ]|[, caPassPhrase][, reqXMLtxt] 
    393393                |[, userName=u, pPhrase=p]) 
    394394 
     
    406406                                        passphrase is required. 
    407407                                         
    408         encrAddUserReqTxt:              encrypted XML containing credentials  
     408        reqXMLtxt:                      XML containing credentials - may be  
     409                                        encrypted or plain text 
    409410                                        for new user: username, pass-phrase 
    410411        addUserReqKeys:                 use as alternative to  
    411                                         encrAddUserReqTxt keyword - pass in  
     412                                        reqXMLtxt keyword - pass in  
    412413                                        username and pass-phrase for new user  
    413414                                        unencrypted as keywords username 
     
    415416         
    416417 
    417         if encrAddUserReqTxt is not None: 
    418             if not isinstance(encrAddUserReqTxt, basestring): 
     418        if reqXMLtxt is not None: 
     419            if not isinstance(reqXMLtxt, basestring): 
    419420                raise SessionMgrError(\ 
    420                     "Encrypted new user credentials must be a string") 
     421                    "New user credentials must be a string") 
    421422                                        
    422             # Decrypt and parse 
    423423            try: 
     424                # Assume text was input encrypted 
     425                # 
    424426                # UserReq object returned behaves like a dictionary 
    425                 addUserReqKeys = AddUserReq(encrXMLtxt=encrAddUserReqTxt, 
     427                addUserReqKeys = AddUserReq(encrXMLtxt=reqXMLtxt, 
    426428                                    encrPriKeyFilePath=self.__prop['keyFile'], 
    427429                                    encrPriKeyPwd=self.__prop['keyPPhrase']) 
    428             except Exception, e: 
    429                 raise SessionMgrError(\ 
    430                     "Error decrypting user credentials: %s" % e) 
     430            except: 
     431                try: 
     432                    # Check for plain text input 
     433                    addUserReqKeys = AddUserReq(xmlTxt=reqXMLtxt) 
     434                                     
     435                except Exception, e: 
     436                    raise SessionMgrError(\ 
     437                        "Error parsing user credentials: %s" % e) 
    431438         
    432439        try: 
     
    449456     
    450457    #_________________________________________________________________________         
    451     def connect(self, encrConnectReqTxt=None, **connectReqKeys):         
     458    def connect(self, reqXMLtxt=None, **connectReqKeys):         
    452459        """Create and return a new user session or connect to an existing 
    453460        one: 
    454461 
    455         connect([webClnt=True/False][, encrConnectReqTxt] 
     462        connect([webClnt=True/False][, reqXMLtxt] 
    456463                |[, userName=u, pPhrase=p]|[, proxyCert=px]|[, sessID=id]) 
    457464 
     
    462469                                certificate only.  The client is then  
    463470                                responsible for Credential Wallet management. 
    464         encrConnectReqTxt:      encrypted XML containing user credentials - 
     471        reqXMLtxt:              encrypted XML containing user credentials - 
    465472                                user name, pass-phrase or proxy cert etc 
    466473        connectReqKeys:         username and pass-phrase or the proxy  
     
    469476         
    470477 
    471         if encrConnectReqTxt is not None: 
    472             if not isinstance(encrConnectReqTxt, basestring): 
     478        if reqXMLtxt is not None: 
     479            if not isinstance(reqXMLtxt, basestring): 
    473480                raise SessionMgrError(\ 
    474481                    "Encrypted user credentials must be a string") 
     
    477484            try: 
    478485                # Connect request object returned behaves like a dictionary 
    479                 connectReqKeys = ConnectReq(encrXMLtxt=encrConnectReqTxt, 
     486                connectReqKeys = ConnectReq(encrXMLtxt=reqXMLtxt, 
    480487                                    encrPriKeyFilePath=self.__prop['keyFile'], 
    481488                                    encrPriKeyPwd=self.__prop['keyPPhrase']) 
    482             except Exception, e: 
    483                 raise SessionMgrError(\ 
    484                     "Error decrypting user credentials: %s" % e) 
     489            except: 
     490                try: 
     491                    connectReqKeys = ConnectReq(xmlTxt=reqXMLtxt) 
     492                     
     493                except Exception, e: 
     494                    raise SessionMgrError(\ 
     495                        "Error parsing user credentials: %s" % e) 
    485496 
    486497         
  • security/trunk/python/NDG/SessionClient.py

    r539 r541  
    286286        smEncrPubKeyFilePath = '../certs/badc-sm-cert.pem' 
    287287         
    288         userName = 'pjkersha' 
     288        userName = 'selatham'#'pjkersha' 
    289289 
    290290        sessClnt = SessionClient(smWSDL=smWSDL, 
  • security/trunk/python/NDG/sessionMgr_services_server.py

    r535 r541  
    6565        # Request a connection from the Session Manager 
    6666        try: 
    67             resp._addUserResp = self.__srv.addUser(encrAddUserReqTxt=reqTxt) 
     67            resp._addUserResp = self.__srv.addUser(reqXMLtxt=reqTxt) 
    6868                
    6969        except Exception, e: 
     
    9191        # Request a connection from the Session Manager 
    9292        try: 
    93             resp._connectResp = self.__srv.connect(encrConnectReqTxt=reqTxt)  
     93            resp._connectResp = self.__srv.connect(reqXMLtxt=reqTxt)  
    9494               
    9595        except Exception, e: 
Note: See TracChangeset for help on using the changeset viewer.