Beispiel #1
0
 def __init__(self, ip, port, key_file, cert_file, api=None):
     threading.Thread.__init__(self)
     self.key = Keypair(filename=key_file)
     self.cert = Certificate(filename=cert_file)
     self.server = ThreadedServer((ip, port), SecureXMLRpcRequestHandler, key_file, cert_file)
     self.trusted_cert_list = None
     self.register_functions()
Beispiel #2
0
class ComponentServer(threading.Thread):

    ##
    # Create a new SfaServer object.
    #
    # @param ip the ip address to listen on
    # @param port the port to listen on
    # @param key_file private key filename of registry
    # @param cert_file certificate filename containing public key
    #   (could be a GID file)

    def __init__(self, ip, port, key_file, cert_file, api=None):
        threading.Thread.__init__(self)
        self.key = Keypair(filename=key_file)
        self.cert = Certificate(filename=cert_file)
        self.server = ThreadedServer((ip, port), SecureXMLRpcRequestHandler, key_file, cert_file)
        self.trusted_cert_list = None
        self.register_functions()

    ##
    # Register functions that will be served by the XMLRPC server. This
    # function should be overrided by each descendant class.

    def register_functions(self):
        self.server.register_function(self.noop)

    ##
    # Sample no-op server function. The no-op function decodes the credential
    # that was passed to it.

    def noop(self, cred, anything):
        self.decode_authentication(cred)

        return anything

    ##
    # Execute the server, serving requests forever.

    def run(self):
        self.server.serve_forever()