Changeset 3024


Ignore:
Timestamp:
21/11/07 13:25:24 (12 years ago)
Author:
pjkersha
Message:

Adding getSessionStatus to enable SM clients to check a session is still valid.

python/ndg.security.server/ndg/security/server/SessionMgr/init.py:

  • new method getSessionStatus checks for a session's existence with given input sessID.

python/www/html/sessionMgr.wsdl,
python/ndg.security.server/ndg/security/server/SessionMgr/SessionMgr_services_server.py,
python/ndg.security.common/ndg/security/common/SessionMgr/SessionMgr_services.py:

  • added getSessionStatus operation to WSDL and regenerated the stubs

python/ndg.security.test/ndg/security/test/MyProxy/myProxyProperties.xml: replace refs to GLOBUS_LOCATION with NDGSEC_DIR for MyProxy? unit tests OpenSSL config file.

python/ndg.security.test/ndg/security/test/SessionMgr/SessionMgrTest.py: new unit test to test out ndg.security.server.SessionMgr?.SessionMgr? class. Previously, this required use of the SessionMgrClient? unit tests. ie. running over SOAP interface.

python/ndg.security.test/ndg/security/test/SessionMgr/sessionMgrProperties.xml,
python/ndg.security.test/ndg/security/test/SessionMgr/sessionMgrClientTest.cfg:

  • expt with settings to try twisted over http but run through proxy on 443 with Apache.
Location:
TI12-security/trunk/python
Files:
1 added
8 edited

Legend:

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

    r2909 r3024  
    2929        # no ws-addressing 
    3030 
    31     # op: <ZSI.wstools.WSDLTools.Message instance at 0x406d74cc> 
    32     def addUser(self, username,passphrase): 
     31    # op: <ZSI.wstools.WSDLTools.Message instance at 0x4077376c> 
     32    def getSessionStatus(self, userDN,sessID): 
    3333 
    34         request = addUserInputMsg() 
    35         request._username = username 
    36         request._passphrase = passphrase 
     34        request = getSessionStatusInputMsg() 
     35        request._userDN = userDN 
     36        request._sessID = sessID 
    3737 
    3838        kw = {} 
    3939        # no input wsaction 
    40         self.binding.Send(None, None, request, soapaction="addUser", **kw) 
     40        self.binding.Send(None, None, request, soapaction="getSessionStatus", **kw) 
    4141        # no output wsaction 
    42         response = self.binding.Receive(addUserOutputMsg.typecode) 
     42        response = self.binding.Receive(getSessionStatusOutputMsg.typecode) 
    4343        return  
    4444 
    45     # op: <ZSI.wstools.WSDLTools.Message instance at 0x406d77cc> 
     45    # op: <ZSI.wstools.WSDLTools.Message instance at 0x40773bcc> 
    4646    def connect(self, username,passphrase,createServerSess): 
    4747 
     
    6262        return proxyCert,proxyPriKey,userCert,sessID 
    6363 
    64     # op: <ZSI.wstools.WSDLTools.Message instance at 0x406d544c> 
     64    # op: <ZSI.wstools.WSDLTools.Message instance at 0x4077898c> 
    6565    def disconnect(self, userCert,sessID): 
    6666 
     
    7676        return  
    7777 
    78     # op: <ZSI.wstools.WSDLTools.Message instance at 0x406d55ec> 
     78    # op: <ZSI.wstools.WSDLTools.Message instance at 0x40778b2c> 
    7979    def getAttCert(self, userCert,sessID,attAuthorityURI,attAuthorityCert,reqRole,mapFromTrustedHosts,rtnExtAttCertList,extAttCert,extTrustedHost): 
    8080 
     
    100100        return attCert,msg,extAttCertOut 
    101101 
    102     # op: <ZSI.wstools.WSDLTools.Message instance at 0x406d576c> 
     102    # op: <ZSI.wstools.WSDLTools.Message instance at 0x40778cac> 
    103103    def getX509Cert(self): 
    104104 
     
    113113        return x509Cert 
    114114 
    115 addUserInputMsg = ns0.addUser_Dec().pyclass 
     115getSessionStatusInputMsg = ns0.getSessionStatus_Dec().pyclass 
    116116 
    117 addUserOutputMsg = ns0.addUserResponse_Dec().pyclass 
     117getSessionStatusOutputMsg = ns0.getSessionStatusResponse_Dec().pyclass 
    118118 
    119119connectInputMsg = ns0.connect_Dec().pyclass 
  • TI12-security/trunk/python/ndg.security.common/ndg/security/common/SessionMgr/SessionMgr_services_types.py

    r2909 r3024  
    1818    targetNamespace = "urn:ndg:security:sessionMgr" 
    1919 
    20     class addUser_Dec(ZSI.TCcompound.ComplexType, ElementDeclaration): 
    21         literal = "addUser" 
    22         schema = "urn:ndg:security:sessionMgr" 
    23         def __init__(self, **kw): 
    24             ns = ns0.addUser_Dec.schema 
    25             TClist = [ZSI.TC.String(pname="username", aname="_username", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname="passphrase", aname="_passphrase", minOccurs=1, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded"))] 
    26             kw["pname"] = ("urn:ndg:security:sessionMgr","addUser") 
    27             kw["aname"] = "_addUser" 
    28             self.attribute_typecode_dict = {} 
    29             ZSI.TCcompound.ComplexType.__init__(self,None,TClist,inorder=0,**kw) 
    30             class Holder: 
    31                 __metaclass__ = pyclass_type 
    32                 typecode = self 
    33                 def __init__(self): 
    34                     # pyclass 
    35                     self._username = None 
    36                     self._passphrase = None 
    37                     return 
    38             Holder.__name__ = "addUser_Holder" 
    39             self.pyclass = Holder 
    40  
    41     class addUserResponse_Dec(ZSI.TCcompound.ComplexType, ElementDeclaration): 
    42         literal = "addUserResponse" 
    43         schema = "urn:ndg:security:sessionMgr" 
    44         def __init__(self, **kw): 
    45             ns = ns0.addUserResponse_Dec.schema 
     20    class getSessionStatus_Dec(ZSI.TCcompound.ComplexType, ElementDeclaration): 
     21        literal = "getSessionStatus" 
     22        schema = "urn:ndg:security:sessionMgr" 
     23        def __init__(self, **kw): 
     24            ns = ns0.getSessionStatus_Dec.schema 
     25            TClist = [ZSI.TC.String(pname="userDN", aname="_userDN", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded")), ZSI.TC.String(pname="sessID", aname="_sessID", minOccurs=0, maxOccurs=1, nillable=False, typed=False, encoded=kw.get("encoded"))] 
     26            kw["pname"] = ("urn:ndg:security:sessionMgr","getSessionStatus") 
     27            kw["aname"] = "_getSessionStatus" 
     28            self.attribute_typecode_dict = {} 
     29            ZSI.TCcompound.ComplexType.__init__(self,None,TClist,inorder=0,**kw) 
     30            class Holder: 
     31                __metaclass__ = pyclass_type 
     32                typecode = self 
     33                def __init__(self): 
     34                    # pyclass 
     35                    self._userDN = None 
     36                    self._sessID = None 
     37                    return 
     38            Holder.__name__ = "getSessionStatus_Holder" 
     39            self.pyclass = Holder 
     40 
     41    class getSessionStatusResponse_Dec(ZSI.TCcompound.ComplexType, ElementDeclaration): 
     42        literal = "getSessionStatusResponse" 
     43        schema = "urn:ndg:security:sessionMgr" 
     44        def __init__(self, **kw): 
     45            ns = ns0.getSessionStatusResponse_Dec.schema 
    4646            TClist = [] 
    47             kw["pname"] = ("urn:ndg:security:sessionMgr","addUserResponse") 
    48             kw["aname"] = "_addUserResponse" 
    49             self.attribute_typecode_dict = {} 
    50             ZSI.TCcompound.ComplexType.__init__(self,None,TClist,inorder=0,**kw) 
    51             class Holder: 
    52                 __metaclass__ = pyclass_type 
    53                 typecode = self 
    54                 def __init__(self): 
    55                     # pyclass 
    56                     return 
    57             Holder.__name__ = "addUserResponse_Holder" 
     47            kw["pname"] = ("urn:ndg:security:sessionMgr","getSessionStatusResponse") 
     48            kw["aname"] = "_getSessionStatusResponse" 
     49            self.attribute_typecode_dict = {} 
     50            ZSI.TCcompound.ComplexType.__init__(self,None,TClist,inorder=0,**kw) 
     51            class Holder: 
     52                __metaclass__ = pyclass_type 
     53                typecode = self 
     54                def __init__(self): 
     55                    # pyclass 
     56                    return 
     57            Holder.__name__ = "getSessionStatusResponse_Holder" 
    5858            self.pyclass = Holder 
    5959 
  • TI12-security/trunk/python/ndg.security.server/ndg/security/server/SessionMgr/SessionMgr_services_server.py

    r2909 r3024  
    1616  <wsdl:types> 
    1717    <xsd:schema targetNamespace=\"urn:ndg:security:sessionMgr\"> 
    18       <xsd:element name=\"addUser\"> 
     18      <xsd:element name=\"getSessionStatus\"> 
    1919        <xsd:complexType> 
    2020          <xsd:sequence> 
    21             <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"username\" type=\"xsd:string\"/> 
    22             <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"passphrase\" type=\"xsd:string\"/> 
     21            <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"userDN\" type=\"xsd:string\"/> 
     22            <xsd:element maxOccurs=\"1\" minOccurs=\"0\" name=\"sessID\" type=\"xsd:string\"/> 
    2323          </xsd:sequence> 
    2424        </xsd:complexType> 
    2525      </xsd:element> 
    2626       
    27       <xsd:element name=\"addUserResponse\"> 
    28         <xsd:complexType/> 
     27      <xsd:element name=\"getSessionStatusResponse\"> 
     28        <xsd:complexType> 
     29                    <xsd:element maxOccurs=\"1\" minOccurs=\"1\" name=\"isAlive\" type=\"xsd:boolean\"/> 
     30        </xsd:complexType> 
    2931      </xsd:element> 
    3032 
     
    104106  </wsdl:types> 
    105107  
    106   <wsdl:message name=\"addUserInputMsg\"> 
    107     <wsdl:part element=\"tns:addUser\" name=\"parameters\"/> 
    108   </wsdl:message> 
    109  
    110   <wsdl:message name=\"addUserOutputMsg\"> 
    111     <wsdl:part element=\"tns:addUserResponse\" name=\"parameters\"/> 
     108  <wsdl:message name=\"getSessionStatusInputMsg\"> 
     109    <wsdl:part element=\"tns:getSessionStatus\" name=\"parameters\"/> 
     110  </wsdl:message> 
     111 
     112  <wsdl:message name=\"getSessionStatusOutputMsg\"> 
     113    <wsdl:part element=\"tns:getSessionStatusResponse\" name=\"parameters\"/> 
    112114  </wsdl:message> 
    113115  
     
    145147 
    146148  <wsdl:portType name=\"SessionMgr\"> 
    147     <wsdl:operation name=\"addUser\"> 
    148       <wsdl:input message=\"tns:addUserInputMsg\"/> 
    149       <wsdl:output message=\"tns:addUserOutputMsg\"/> 
     149    <wsdl:operation name=\"getSessionStatus\"> 
     150      <wsdl:input message=\"tns:getSessionStatusInputMsg\"/> 
     151      <wsdl:output message=\"tns:getSessionStatusOutputMsg\"/> 
    150152    </wsdl:operation> 
    151153 
     
    174176    <soap:binding style=\"document\" transport=\"http://schemas.xmlsoap.org/soap/http\"/> 
    175177 
    176     <wsdl:operation name=\"addUser\"> 
    177       <soap:operation soapAction=\"addUser\"/> 
     178    <wsdl:operation name=\"getSessionStatus\"> 
     179      <soap:operation soapAction=\"getSessionStatus\"/> 
    178180      <wsdl:input> 
    179181        <soap:body use=\"literal\"/> 
     
    247249            return 1 
    248250 
    249     def soap_addUser(self, ps): 
    250         self.request = ps.Parse(addUserInputMsg.typecode) 
    251         parameters = (self.request._username, self.request._passphrase) 
    252  
    253         # If we have an implementation object use it 
    254         if hasattr(self,'impl'): 
    255             parameters = self.impl.addUser(parameters[0],parameters[1]) 
    256  
    257         result = addUserOutputMsg() 
    258         return self.request, result 
    259  
    260     soapAction['addUser'] = 'soap_addUser' 
    261     root[(addUserInputMsg.typecode.nspname,addUserInputMsg.typecode.pname)] = 'soap_addUser' 
     251    def soap_getSessionStatus(self, ps): 
     252        self.request = ps.Parse(getSessionStatusInputMsg.typecode) 
     253        parameters = (self.request._userDN, self.request._sessID) 
     254 
     255        # If we have an implementation object use it 
     256        if hasattr(self,'impl'): 
     257            parameters = self.impl.getSessionStatus(parameters[0],parameters[1]) 
     258 
     259        result = getSessionStatusOutputMsg() 
     260        return self.request, result 
     261 
     262    soapAction['getSessionStatus'] = 'soap_getSessionStatus' 
     263    root[(getSessionStatusInputMsg.typecode.nspname,getSessionStatusInputMsg.typecode.pname)] = 'soap_getSessionStatus' 
    262264 
    263265    def soap_connect(self, ps): 
  • TI12-security/trunk/python/ndg.security.server/ndg/security/server/SessionMgr/__init__.py

    r2961 r3024  
    4141    CredWalletError, CredWalletAttributeRequestDenied 
    4242 
    43 from ndg.security.common.X509 import X509Cert, X509CertParse, \ 
     43from ndg.security.common.X509 import X500DN, X509Cert, X509CertParse, \ 
    4444                                X509CertExpired, X509CertInvalidNotBeforeTime  
    4545 
     
    761761     
    762762    #_________________________________________________________________________         
     763    def getSessionStatus(self, sessID=None, userDN=None): 
     764        """Check the status of a given session identified by sessID or  
     765        user Distinguished Name 
     766         
     767        @type sessID: string 
     768        @param sessID: session identifier as returned from a call to connect() 
     769        @type userDN: string 
     770        @param userDN: user Distinguished Name of session to check 
     771        @rtype: bool 
     772        @return: True if session is active, False if no session found""" 
     773 
     774        log.debug("Calling SessionMgr.getSessionStatus ...") 
     775         
     776        # Look for a session corresponding to this ID 
     777        if sessID and userDN: 
     778            raise SessionMgrError, \ 
     779                            'Only "SessID" or "userDN" keywords may be set' 
     780        elif sessID: 
     781            if sessID in self.__sessDict:                
     782                log.info("Session found with ID = %s" % sessID) 
     783                return True 
     784            else: 
     785                # User session not found with given ID 
     786                log.info("No user session found matching input ID = %s" % \ 
     787                         sessID) 
     788                return False 
     789                           
     790        elif userDN: 
     791            try: 
     792                # Enables re-ordering of DN fields for following dict search 
     793                userDN = str(X509DN(userDN)) 
     794                 
     795            except Exception, e: 
     796                raise SessionMgrError, \ 
     797                "Parsing input user certificate DN for getSessionStatus: %s"%e 
     798 
     799            if userDN in self.__dnDict: 
     800                log.info("Session found with DN = %s" % userDN) 
     801                return True                         
     802            else: 
     803                # User session not found with given proxy cert 
     804                log.info("No user session found matching input userDN = %s" %\ 
     805                         userDN) 
     806                return False 
     807 
     808     
     809    #_________________________________________________________________________         
    763810    def connect(self,  
    764811                createServerSess=True, 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/MyProxy/myProxyProperties.xml

    r2827 r3024  
    3030        but the settings can be independent of any Globus installation 
    3131        --> 
    32         <openSSLConfFilePath>$GLOBUS_LOCATION/etc/globus-user-ssl.conf</openSSLConfFilePath> 
     32        <openSSLConfFilePath>$NDGSEC_DIR/conf/openssl.conf</openSSLConfFilePath> 
    3333        <tmpDir>/tmp</tmpDir> 
    3434        <!--  
     
    4646        <proxyCertLifetime></proxyCertLifetime> 
    4747        --> 
    48         <caCertFile>cacert.pem</caCertFile> 
     48        <caCertFile>$NDGSEC_DIR/conf/certs/cacert.pem</caCertFile> 
    4949</myProxyProp> 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/SessionMgr/sessionMgrClientTest.cfg

    r2902 r3024  
    1010# $Id:$ 
    1111[setUp] 
    12 smuri = https://localhost:5700/SessionManager 
     12smuri = https://localhost/SessionManager 
     13#smuri = https://localhost:5700/SessionManager 
    1314#smuri = https://glue.badc.rl.ac.uk:50000/SessionManager 
    1415 
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/SessionMgr/sessionMgrProperties.xml

    r2893 r3024  
    22<sessMgrProp> 
    33    <portNum>5700</portNum> 
    4     <useSSL>Yes</useSSL> <!-- leave blank to use http --> 
     4    <useSSL></useSSL> <!-- leave blank to use http --> 
     5    <!--<useSSL>Yes</useSSL>  leave blank to use http --> 
    56    <sslCertFile>$NDGSEC_SM_UNITTEST_DIR/sm-cert.pem</sslCertFile> 
    67    <sslKeyFile>$NDGSEC_SM_UNITTEST_DIR/sm-key.pem</sslKeyFile> 
  • TI12-security/trunk/python/www/html/sessionMgr.wsdl

    r2620 r3024  
    1212  <wsdl:types> 
    1313    <xsd:schema targetNamespace="urn:ndg:security:sessionMgr"> 
    14       <xsd:element name="addUser"> 
     14      <xsd:element name="getSessionStatus"> 
    1515        <xsd:complexType> 
    1616          <xsd:sequence> 
    17             <xsd:element name="username" type="xsd:string" minOccurs="1" maxOccurs="1"/> 
    18             <xsd:element name="passphrase" type="xsd:string" minOccurs="1" maxOccurs="1"/> 
     17            <xsd:element name="userDN" type="xsd:string" minOccurs="0" maxOccurs="1"/> 
     18            <xsd:element name="sessID" type="xsd:string" minOccurs="0" maxOccurs="1"/> 
    1919          </xsd:sequence> 
    2020        </xsd:complexType> 
    2121      </xsd:element> 
    2222       
    23       <xsd:element name="addUserResponse"> 
    24         <xsd:complexType/> 
     23      <xsd:element name="getSessionStatusResponse"> 
     24        <xsd:complexType> 
     25                    <xsd:element name="isAlive" type="xsd:boolean" minOccurs="1" maxOccurs="1"/> 
     26        </xsd:complexType> 
    2527      </xsd:element> 
    2628 
     
    100102  </wsdl:types> 
    101103  
    102   <wsdl:message name="addUserInputMsg"> 
    103     <wsdl:part name="parameters" element="tns:addUser"/> 
    104   </wsdl:message> 
    105  
    106   <wsdl:message name="addUserOutputMsg"> 
    107     <wsdl:part name="parameters" element="tns:addUserResponse"/> 
     104  <wsdl:message name="getSessionStatusInputMsg"> 
     105    <wsdl:part name="parameters" element="tns:getSessionStatus"/> 
     106  </wsdl:message> 
     107 
     108  <wsdl:message name="getSessionStatusOutputMsg"> 
     109    <wsdl:part name="parameters" element="tns:getSessionStatusResponse"/> 
    108110  </wsdl:message> 
    109111  
     
    141143 
    142144  <wsdl:portType name="SessionMgr"> 
    143     <wsdl:operation name="addUser"> 
    144       <wsdl:input message="tns:addUserInputMsg"/> 
    145       <wsdl:output message="tns:addUserOutputMsg"/> 
     145    <wsdl:operation name="getSessionStatus"> 
     146      <wsdl:input message="tns:getSessionStatusInputMsg"/> 
     147      <wsdl:output message="tns:getSessionStatusOutputMsg"/> 
    146148    </wsdl:operation> 
    147149 
     
    172174     transport="http://schemas.xmlsoap.org/soap/http"/> 
    173175 
    174     <wsdl:operation name="addUser"> 
    175       <soap:operation soapAction="addUser"/> 
     176    <wsdl:operation name="getSessionStatus"> 
     177      <soap:operation soapAction="getSessionStatus"/> 
    176178      <wsdl:input> 
    177179        <soap:body use="literal"/> 
Note: See TracChangeset for help on using the changeset viewer.