Ejemplo n.º 1
0
    def listen(self):
        while 1:
            msgs = self._receiveOne(multiple=1)
            for msg in msgs:
                dec = self._decryptSession(msg)

                from messagewrapper import getGenericWrapper

                metadata, datas = getGenericWrapper().unwrapArgsAndDatas("servicemetadata", dec)
                msg = datas["message"]
                self._callback(msg, metadata)
Ejemplo n.º 2
0
    def disconnect(self):
        """
        Closes down the connection of this client to the service.
        """
        from messagewrapper import getGenericWrapper

        args = {}
        datas = {}
        args["serviceid"] = self._serviceId
        args["disconnect"] = "1"
        msg = getGenericWrapper().wrapArgsAndDatas("servicemessage", args, datas)
        ciphered = self._encryptSession(msg)
        self._sendOne(ciphered)
Ejemplo n.º 3
0
    def _rendevous(self, number):
        """
        Authenticates at the server process using the service fifo.
        """
        self._name_pipe_in = FIFO_PATH_IN + "." + str(number)
        self._name_pipe_out = FIFO_PATH_OUT + "." + str(number)

        from messagewrapper import getGenericWrapper

        plain, signature = self._createAuthenticationToken()
        args = {}
        args["action"] = "authenticate"
        args["serviceid"] = self._serviceId
        datas = {}
        datas["plain"] = plain
        datas["signature"] = signature
        xmlRendevous = getGenericWrapper().wrapArgsAndDatas("rendevous", args, datas)

        self._sendOne(xmlRendevous)

        reply = self._receiveOne()

        args, datas = getGenericWrapper().unwrapArgsAndDatas("rendevous", reply)
        # print args
        if not int(args["sucess"]):
            if args.has_key("errormessage"):
                error = args["errormessage"]
            else:
                error = "The provided key might have not been accepted."
            from errorhandling import G4dsDependencyException

            raise G4dsDependencyException("Connecting against Service not sucessful. %s" % (error))

        sessionkey = datas["sessionkey"]
        self._sessionkey = self._decryptWithMyPrivateKey(sessionkey)

        import thread

        thread.start_new_thread(self.listen, ())
Ejemplo n.º 4
0
    def sendMessage(self, destinationMember, destinationCommunity, message, actionstring=None):
        from messagewrapper import getGenericWrapper

        if not actionstring:
            actionstring = "g4ds.service." + self._serviceId
        args = {}
        datas = {}
        args["serviceid"] = self._serviceId
        args["destinationmember"] = destinationMember
        args["destinationcommunity"] = destinationCommunity
        args["actionstring"] = actionstring
        datas["message"] = message
        msg = getGenericWrapper().wrapArgsAndDatas("servicemessage", args, datas)
        ##        print "Sending before cipher:\n%s" %(msg)
        ciphered = self._encryptSession(msg)
        self._sendOne(ciphered)