コード例 #1
0
ファイル: models.py プロジェクト: pentikousis/C-BAS-framework
 def _reset_proxy(self):
     parsed = urlparse(self.url.lower())
     self.transport = None
     # This scheme is used for debugging and looping back
     if parsed.scheme == "test":
         self.proxy = BasicAuthServerProxy(
             test_to_http(self.url),
             username=self.username,
             password=self.password,
             transport=TestClientTransport())
     elif parsed.scheme == "https":
         from M2Crypto.m2xmlrpclib import SSL_Transport
         from M2Crypto.SSL import Context
         self.transport = SSL_Transport(Context(protocol='tlsv1'))
         self.proxy = BasicAuthServerProxy(self.url,
                                           username=self.username,
                                           password=self.password,
                                           transport=self.transport,
                                           #verbose=getattr(settings, "DEBUG", False))
                                           verbose=False)
         self.set_verify_certs()
     else:
         self.proxy = BasicAuthServerProxy(self.url,
                                           username=self.username,
                                           password=self.password)
コード例 #2
0
ファイル: models.py プロジェクト: fp7-alien/C-BAS
 def _get_client(self, cert_fname, key_fname):
     try:
         u = self.url
     except AttributeError:
         raise self.URLNotDefined("URL not set.")
     if not u:
         raise self.URLNotDefined("URL not set.")
     
     parsed = urlparse(u.lower())
     if parsed.scheme == "test":
         user_cert = GID(filename=cert_fname).save_to_string()
         transport = TestClientTransport(defaults={
             "REMOTE_USER": user_cert, "SSL_CLIENT_CERT": user_cert})
         proxy = xmlrpclib.ServerProxy(
             test_to_http(u),
             transport=transport,
         )
     else:
         transport = certtransport.SafeTransportWithCert(
             keyfile=key_fname,
             certfile=cert_fname)
         proxy = xmlrpclib.ServerProxy(u, transport=transport)
     return proxy
コード例 #3
0
    def _get_client(self, cert_fname, key_fname):
        try:
            u = self.url
        except AttributeError:
            raise self.URLNotDefined("URL not set.")
        if not u:
            raise self.URLNotDefined("URL not set.")

        parsed = urlparse(u.lower())
        if parsed.scheme == "test":
            user_cert = GID(filename=cert_fname).save_to_string()
            transport = TestClientTransport(defaults={
                "REMOTE_USER": user_cert,
                "SSL_CLIENT_CERT": user_cert
            })
            proxy = xmlrpclib.ServerProxy(
                test_to_http(u),
                transport=transport,
            )
        else:
            transport = certtransport.SafeTransportWithCert(
                keyfile=key_fname, certfile=cert_fname)
            proxy = xmlrpclib.ServerProxy(u, transport=transport)
        return proxy