Пример #1
0
    def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        super(RequestBatchItem, self).read(
            istream,
            kmip_version=kmip_version
        )
        tstream = BytearrayStream(istream.read(self.length))

        # Read the batch item operation
        self.operation = contents.Operation()
        self.operation.read(tstream, kmip_version=kmip_version)

        if kmip_version >= enums.KMIPVersion.KMIP_2_0:
            if self.is_tag_next(enums.Tags.EPHEMERAL, tstream):
                ephemeral = primitives.Boolean(tag=enums.Tags.EPHEMERAL)
                ephemeral.read(tstream, kmip_version=kmip_version)
                self._ephemeral = ephemeral

        # Read the unique batch item ID if it is present
        if self.is_tag_next(Tags.UNIQUE_BATCH_ITEM_ID, tstream):
            self.unique_batch_item_id = contents.UniqueBatchItemID()
            self.unique_batch_item_id.read(tstream, kmip_version=kmip_version)

        # Dynamically create the response payload class that belongs to the
        # operation
        self.request_payload = self.payload_factory.create(
            self.operation.value)
        self.request_payload.read(tstream, kmip_version=kmip_version)

        # Read the message extension if it is present
        if self.is_tag_next(Tags.MESSAGE_EXTENSION, tstream):
            self.message_extension = contents.MessageExtension()
            self.message_extension.read(tstream, kmip_version=kmip_version)

        self.is_oversized(tstream)
Пример #2
0
    def read(self, istream):
        super(RequestBatchItem, self).read(istream)
        tstream = BytearrayStream(istream.read(self.length))

        # Read the batch item operation
        self.operation = contents.Operation()
        self.operation.read(tstream)

        # Read the unique batch item ID if it is present
        if self.is_tag_next(Tags.UNIQUE_BATCH_ITEM_ID, tstream):
            self.unique_batch_item_id = contents.UniqueBatchItemID()
            self.unique_batch_item_id.read(tstream)

        # Dynamically create the response payload class that belongs to the
        # operation
        self.request_payload = self.payload_factory.create(
            self.operation.value)
        self.request_payload.read(tstream)

        # Read the message extension if it is present
        if self.is_tag_next(Tags.MESSAGE_EXTENSION, tstream):
            self.message_extension = contents.MessageExtension()
            self.message_extension.read(tstream)

        self.is_oversized(tstream)
Пример #3
0
    def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        super(ResponseBatchItem, self).read(
            istream,
            kmip_version=kmip_version
        )
        tstream = BytearrayStream(istream.read(self.length))

        # Read the batch item operation if it is present
        if self.is_tag_next(Tags.OPERATION, tstream):
            self.operation = contents.Operation()
            self.operation.read(tstream, kmip_version=kmip_version)

        # Read the unique batch item ID if it is present
        if self.is_tag_next(Tags.UNIQUE_BATCH_ITEM_ID, tstream):
            self.unique_batch_item_id = contents.UniqueBatchItemID()
            self.unique_batch_item_id.read(tstream, kmip_version=kmip_version)

        # Read the batch item result status
        self.result_status = contents.ResultStatus()
        self.result_status.read(tstream, kmip_version=kmip_version)

        # Read the batch item result reason if it is present
        if self.is_tag_next(Tags.RESULT_REASON, tstream):
            self.result_reason = contents.ResultReason()
            self.result_reason.read(tstream, kmip_version=kmip_version)

        # Read the batch item result message if it is present
        if self.is_tag_next(Tags.RESULT_MESSAGE, tstream):
            self.result_message = contents.ResultMessage()
            self.result_message.read(tstream, kmip_version=kmip_version)

        # Read the batch item asynchronous correlation value if it is present
        if self.is_tag_next(Tags.ASYNCHRONOUS_CORRELATION_VALUE, tstream):
            self.async_correlation_value = AsynchronousCorrelationValue()
            self.async_correlation_value.read(
                tstream,
                kmip_version=kmip_version
            )

        if (self.operation is not None):
            # Dynamically create the response payload class that belongs to the
            # operation
            expected = self.payload_factory.create(self.operation.value)
            if self.is_tag_next(expected.tag, tstream):
                self.response_payload = expected
                self.response_payload.read(tstream, kmip_version=kmip_version)

        # Read the message extension if it is present
        if self.is_tag_next(Tags.MESSAGE_EXTENSION, tstream):
            self.message_extension = contents.MessageExtension()
            self.message_extension.read(tstream, kmip_version=kmip_version)

        self.is_oversized(tstream)
        self.validate()