Example #1
0
    def respond_to_obj_req(self, obj_id: Union[str, int]):
        """Returns the deregistered object from registry.

        Args:
            obj_id: A string or integer id of an object to look up.
        """

        obj = self.get_obj(obj_id)
        if obj.allowed_to_get():
            self.de_register_obj(obj)
            return obj
        return GetNotPermittedError()
Example #2
0
def _detail_GetNotPermittedError(worker: AbstractWorker,
                                 error_tuple: tuple) -> GetNotPermittedError:
    """Details and raises a GetNotPermittedError

    Args:
        worker: the worker doing the deserialization
        error_tuple: a tuple holding the message of the GetNotPermittedError
    Raises:
        GetNotPermittedError: the error thrown when get is not permitted
    """

    raise GetNotPermittedError(error_tuple[0])
Example #3
0
    def respond_to_obj_req(self, request_msg: tuple):
        """Returns the deregistered object from registry.

        Args:
            request_msg (tuple): Tuple containing object id, user credentials and reason.
        """
        obj_id, user, reason = request_msg
        obj = self.get_obj(obj_id)
        if hasattr(obj, "allow") and not obj.allow(user):
            raise GetNotPermittedError()
        else:
            self.de_register_obj(obj)
            return obj
Example #4
0
    def respond_to_obj_req(self, msg: ObjectRequestMessage):
        """Returns the deregistered object from registry.

        Args:
            request_msg (tuple): Tuple containing object id, user credentials and reason.
        """
        obj_id = msg.object_id
        user = msg.user
        reason = msg.reason

        obj = self.get_obj(obj_id)

        permitted = all(map_chain_call(obj, "allow", user=user))
        if not permitted:
            raise GetNotPermittedError()
        else:
            self.object_store.de_register_obj(obj)
            return obj