Example #1
0
 def __connect( self, socketInfo, hostAddress ):
   #Connect baby!
   result = self.__socketConnect( hostAddress, socketInfo.infoDict[ 'timeout' ] )
   if not result[ 'OK' ]:
     return result
   osSocket = result[ 'Value' ]
   #SSL MAGIC
   sslSocket = GSI.SSL.Connection( socketInfo.getSSLContext(), osSocket )
   #Generate sessionId
   sessionHash = md5.md5()
   sessionHash.update( str( hostAddress ) )
   sessionHash.update( "|%s" % str( socketInfo.getLocalCredentialsLocation() ) )
   for key in ( 'proxyLocation', 'proxyString' ):
     if key in socketInfo.infoDict:
       sessionHash.update( "|%s" % str( socketInfo.infoDict[ key ] ) )
   if 'proxyChain' in socketInfo.infoDict:
     sessionHash.update( "|%s" % socketInfo.infoDict[ 'proxyChain' ].dumpAllToString()[ 'Value' ] )
   sessionId = sessionHash.hexdigest()
   socketInfo.sslContext.set_session_id( str( hash( sessionId ) ) )
   socketInfo.setSSLSocket( sslSocket )
   if gSessionManager.isValid( sessionId ):
     sslSocket.set_session( gSessionManager.get( sessionId ) )
   #Set the real timeout
   if socketInfo.infoDict[ 'timeout' ]:
     sslSocket.settimeout( socketInfo.infoDict[ 'timeout' ] )
   #Connected!
   return S_OK( sslSocket )
Example #2
0
 def __connect(self, socketInfo, hostAddress):
     #Connect baby!
     result = self.__socketConnect(hostAddress,
                                   socketInfo.infoDict['timeout'])
     if not result['OK']:
         return result
     osSocket = result['Value']
     #SSL MAGIC
     sslSocket = GSI.SSL.Connection(socketInfo.getSSLContext(), osSocket)
     #Generate sessionId
     sessionHash = md5.md5()
     sessionHash.update(str(hostAddress))
     sessionHash.update("|%s" %
                        str(socketInfo.getLocalCredentialsLocation()))
     for key in ('proxyLocation', 'proxyString'):
         if key in socketInfo.infoDict:
             sessionHash.update("|%s" % str(socketInfo.infoDict[key]))
     if 'proxyChain' in socketInfo.infoDict:
         sessionHash.update(
             "|%s" %
             socketInfo.infoDict['proxyChain'].dumpAllToString()['Value'])
     sessionId = sessionHash.hexdigest()
     socketInfo.sslContext.set_session_id(str(hash(sessionId)))
     socketInfo.setSSLSocket(sslSocket)
     if gSessionManager.isValid(sessionId):
         sslSocket.set_session(gSessionManager.get(sessionId))
     #Set the real timeout
     if socketInfo.infoDict['timeout']:
         sslSocket.settimeout(socketInfo.infoDict['timeout'])
     #Connected!
     return S_OK(sslSocket)