Example #1
0
    def write(self, ostream):
        """
        Write the data encoding the QueryResponsePayload object to a stream.

        Args:
            ostream (Stream): A data stream in which to encode object data,
                supporting a write method; usually a BytearrayStream object.
        """
        tstream = BytearrayStream()

        for operation in self.operations:
            operation.write(tstream)

        for object_type in self.object_types:
            object_type.write(tstream)

        if self.vendor_identification is not None:
            self.vendor_identification.write(tstream)

        if self.server_information is not None:
            self.server_information.write(tstream)

        for application_namespace in self.application_namespaces:
            application_namespace.write(tstream)

        for extension_information in self.extension_information:
            extension_information.write(tstream)

        self.length = tstream.length()
        super(QueryResponsePayload, self).write(ostream)
        ostream.write(tstream.buffer)
Example #2
0
    def write(self, ostream):
        """
        Write the data encoding the QueryResponsePayload object to a stream.

        Args:
            ostream (Stream): A data stream in which to encode object data,
                supporting a write method; usually a BytearrayStream object.
        """
        tstream = BytearrayStream()

        for operation in self.operations:
            operation.write(tstream)

        for object_type in self.object_types:
            object_type.write(tstream)

        if self.vendor_identification is not None:
            self.vendor_identification.write(tstream)

        if self.server_information is not None:
            self.server_information.write(tstream)

        for application_namespace in self.application_namespaces:
            application_namespace.write(tstream)

        for extension_information in self.extension_information:
            extension_information.write(tstream)

        self.length = tstream.length()
        super(QueryResponsePayload, self).write(ostream)
        ostream.write(tstream.buffer)
    def setUp(self):
        super(TestExtensionInformation, self).setUp()

        self.extension_name_b = ExtensionName('ACME LOCATION')
        self.extension_name_c = ExtensionName('ACME LOCATION')
        self.extension_name_d = ExtensionName('ACME ZIP CODE')

        self.extension_tag_c = ExtensionTag(5548545)
        self.extension_tag_d = ExtensionTag(5548546)

        self.extension_type_c = ExtensionType(7)
        self.extension_type_d = ExtensionType(2)

        self.encoding_a = BytearrayStream(
            b'\x42\x00\xA4\x01\x00\x00\x00\x08\x42\x00\xA5\x07\x00\x00\x00'
            b'\x00')
        self.encoding_b = BytearrayStream(
            b'\x42\x00\xA4\x01\x00\x00\x00\x18\x42\x00\xA5\x07\x00\x00\x00\x0D'
            b'\x41\x43\x4D\x45\x20\x4C\x4F\x43\x41\x54\x49\x4F\x4E\x00\x00'
            b'\x00')
        self.encoding_c = BytearrayStream(
            b'\x42\x00\xA4\x01\x00\x00\x00\x38\x42\x00\xA5\x07\x00\x00\x00\x0D'
            b'\x41\x43\x4D\x45\x20\x4C\x4F\x43\x41\x54\x49\x4F\x4E\x00\x00\x00'
            b'\x42\x00\xA6\x02\x00\x00\x00\x04\x00\x54\xAA\x01\x00\x00\x00\x00'
            b'\x42\x00\xA7\x02\x00\x00\x00\x04\x00\x00\x00\x07\x00\x00\x00'
            b'\x00')
        self.encoding_d = BytearrayStream(
            b'\x42\x00\xA4\x01\x00\x00\x00\x38\x42\x00\xA5\x07\x00\x00\x00\x0D'
            b'\x41\x43\x4D\x45\x20\x5A\x49\x50\x20\x43\x4F\x44\x45\x00\x00\x00'
            b'\x42\x00\xA6\x02\x00\x00\x00\x04\x00\x54\xAA\x02\x00\x00\x00\x00'
            b'\x42\x00\xA7\x02\x00\x00\x00\x04\x00\x00\x00\x02\x00\x00\x00'
            b'\x00')
Example #4
0
    def write(self, ostream):
        tstream = BytearrayStream()

        # Write the contents of the batch item to the stream
        if self.operation is not None:
            self.operation.write(tstream)
        if self.unique_batch_item_id is not None:
            self.unique_batch_item_id.write(tstream)

        self.result_status.write(tstream)

        if self.result_reason is not None:
            self.result_reason.write(tstream)
        if self.result_message is not None:
            self.result_message.write(tstream)
        if self.async_correlation_value is not None:
            self.async_correlation_value.write(tstream)
        if self.response_payload is not None:
            self.response_payload.write(tstream)
        if self.message_extension is not None:
            self.message_extension.write(tstream)

        # Write the length and value of the batch item
        self.length = tstream.length()
        super(self.__class__, self).write(ostream)
        ostream.write(tstream.buffer)
Example #5
0
    def write(self, ostream):
        tstream = BytearrayStream()
        tstream.write(self.data.buffer)

        self.length = tstream.length()
        super(KeyMaterialStruct, self).write(ostream)
        ostream.write(tstream.buffer)
Example #6
0
    def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        tstream = BytearrayStream()

        # Write the contents of the batch item to the stream
        self.operation.write(tstream, kmip_version=kmip_version)

        if kmip_version >= enums.KMIPVersion.KMIP_2_0:
            if self._ephemeral:
                self._ephemeral.write(tstream, kmip_version=kmip_version)

        if self.unique_batch_item_id is not None:
            self.unique_batch_item_id.write(tstream, kmip_version=kmip_version)

        self.request_payload.write(tstream, kmip_version=kmip_version)

        if self.message_extension is not None:
            self.message_extension.write(tstream, kmip_version=kmip_version)

        # Write the length and value of the batch item
        self.length = tstream.length()
        super(RequestBatchItem, self).write(
            ostream,
            kmip_version=kmip_version
        )
        ostream.write(tstream.buffer)
Example #7
0
    def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        tstream = BytearrayStream()

        # Write the contents of a request header to the stream
        self.protocol_version.write(tstream, kmip_version=kmip_version)
        if self.maximum_response_size is not None:
            self.maximum_response_size.write(
                tstream,
                kmip_version=kmip_version
            )
        if self.asynchronous_indicator is not None:
            self.asynchronous_indicator.write(
                tstream,
                kmip_version=kmip_version
            )
        if self.authentication is not None:
            self.authentication.write(tstream, kmip_version=kmip_version)
        if self.batch_error_cont_option is not None:
            self.batch_error_cont_option.write(
                tstream,
                kmip_version=kmip_version
            )
        if self.batch_order_option is not None:
            self.batch_order_option.write(tstream, kmip_version=kmip_version)
        if self.time_stamp is not None:
            self.time_stamp.write(tstream, kmip_version=kmip_version)
        self.batch_count.write(tstream, kmip_version=kmip_version)

        # Write the length and value of the request header
        self.length = tstream.length()
        super(RequestHeader, self).write(
            ostream,
            kmip_version=kmip_version
        )
        ostream.write(tstream.buffer)
Example #8
0
    def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        tstream = BytearrayStream()

        if self.private_key_uuid is not None:
            self.private_key_uuid.write(tstream, kmip_version=kmip_version)

        if self.offset is not None:
            self.offset.write(tstream, kmip_version=kmip_version)

        if self.common_template_attribute is not None:
            self.common_template_attribute.write(tstream,
                                                 kmip_version=kmip_version)

        if self.private_key_template_attribute is not None:
            self.private_key_template_attribute.write(
                tstream, kmip_version=kmip_version)

        if self.public_key_template_attribute is not None:
            self.public_key_template_attribute.write(tstream,
                                                     kmip_version=kmip_version)

        self.length = tstream.length()
        super(RekeyKeyPairRequestPayload,
              self).write(ostream, kmip_version=kmip_version)
        ostream.write(tstream.buffer)
Example #9
0
    def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        tstream = BytearrayStream()

        # Write the contents of the batch item to the stream
        if self.operation is not None:
            self.operation.write(tstream, kmip_version=kmip_version)
        if self.unique_batch_item_id is not None:
            self.unique_batch_item_id.write(tstream, kmip_version=kmip_version)

        self.result_status.write(tstream, kmip_version=kmip_version)

        if self.result_reason is not None:
            self.result_reason.write(tstream, kmip_version=kmip_version)
        if self.result_message is not None:
            self.result_message.write(tstream, kmip_version=kmip_version)
        if self.async_correlation_value is not None:
            self.async_correlation_value.write(
                tstream,
                kmip_version=kmip_version
            )
        if self.response_payload is not None:
            self.response_payload.write(tstream, kmip_version=kmip_version)
        if self.message_extension is not None:
            self.message_extension.write(tstream, kmip_version=kmip_version)

        # Write the length and value of the batch item
        self.length = tstream.length()
        super(ResponseBatchItem, self).write(
            ostream,
            kmip_version=kmip_version
        )
        ostream.write(tstream.buffer)
Example #10
0
    def write(self, ostream):
        tstream = BytearrayStream()
        tstream.write(self.data.buffer)

        self.length = tstream.length()
        super(KeyMaterialStruct, self).write(ostream)
        ostream.write(tstream.buffer)
Example #11
0
    def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        """
        Write the data encoding the RevokeRequestPayload object to a stream.
        Args:
            ostream (Stream): A data stream in which to encode object data,
                supporting a write method; usually a BytearrayStream object.
            kmip_version (KMIPVersion): An enumeration defining the KMIP
                version with which the object will be encoded. Optional,
                defaults to KMIP 1.0.
        """
        tstream = BytearrayStream()

        # Write the contents of the request payload
        if self.unique_identifier is not None:
            self.unique_identifier.write(tstream, kmip_version=kmip_version)

        self.revocation_reason.write(tstream, kmip_version=kmip_version)

        if self.compromise_occurrence_date is not None:
            self.compromise_occurrence_date.write(tstream,
                                                  kmip_version=kmip_version)

        # Write the length and value of the request payload
        self.length = tstream.length()
        super(RevokeRequestPayload, self).write(ostream,
                                                kmip_version=kmip_version)
        ostream.write(tstream.buffer)
Example #12
0
    def setUp(self):
        super(TestServerInformation, self).setUp()

        self.data = BytearrayStream(b'\x00\x01\x02\x03')

        self.encoding_a = BytearrayStream(b'\x42\x00\x88\x01\x00\x00\x00\x00')
        self.encoding_b = BytearrayStream(
            b'\x42\x00\x88\x01\x00\x00\x00\x04\x00\x01\x02\x03')
Example #13
0
    def read(self, istream):
        super(KeyMaterialStruct, self).read(istream)
        tstream = BytearrayStream(istream.read(self.length))

        self.data = BytearrayStream(tstream.read())

        self.is_oversized(tstream)
        self.validate()
Example #14
0
    def read(self, istream):
        super(KeyMaterialStruct, self).read(istream)
        tstream = BytearrayStream(istream.read(self.length))

        self.data = BytearrayStream(tstream.read())

        self.is_oversized(tstream)
        self.validate()
Example #15
0
    def write(self, ostream):
        tstream = BytearrayStream()

        for protocol_version in self.protocol_versions:
            protocol_version.write(tstream)

        self.length = tstream.length()
        super(DiscoverVersionsRequestPayload, self).write(ostream)
        ostream.write(tstream.buffer)
Example #16
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.unique_identifier.write(tstream)

        # Write the length and value of the request payload
        self.length = tstream.length()
        super(DestroyResponsePayload, self).write(ostream)
        ostream.write(tstream.buffer)
Example #17
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.key_block.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(KeyBlockKey, self).write(ostream)
        ostream.write(tstream.buffer)
Example #18
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.unique_identifier.write(tstream)

        # Write the length and value of the request payload
        self.length = tstream.length()
        super(self.__class__, self).write(ostream)
        ostream.write(tstream.buffer)
Example #19
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.key.write(tstream)

        # Write the length and value of the key wrapping data
        self.length = tstream.length()
        super(TransparentSymmetricKey, self).write(ostream)
        ostream.write(tstream.buffer)
Example #20
0
    def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        tstream = BytearrayStream()

        self.key_block.write(tstream, kmip_version=kmip_version)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(KeyBlockKey, self).write(ostream, kmip_version=kmip_version)
        ostream.write(tstream.buffer)
Example #21
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.key.write(tstream)

        # Write the length and value of the key wrapping data
        self.length = tstream.length()
        super(self.__class__, self).write(ostream)
        ostream.write(tstream.buffer)
Example #22
0
    def write(self, ostream):
        tstream = BytearrayStream()

        for protocol_version in self.protocol_versions:
            protocol_version.write(tstream)

        self.length = tstream.length()
        super(DiscoverVersionsRequestPayload, self).write(ostream)
        ostream.write(tstream.buffer)
Example #23
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.key_block.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(KeyBlockKey, self).write(ostream)
        ostream.write(tstream.buffer)
Example #24
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.secret_data_type.write(tstream)
        self.key_block.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(SecretData, self).write(ostream)
        ostream.write(tstream.buffer)
Example #25
0
    def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        tstream = BytearrayStream()

        for protocol_version in self.protocol_versions:
            protocol_version.write(tstream, kmip_version=kmip_version)

        self.length = tstream.length()
        super(DiscoverVersionsRequestPayload,
              self).write(ostream, kmip_version=kmip_version)
        ostream.write(tstream.buffer)
Example #26
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.opaque_data_type.write(tstream)
        self.opaque_data_value.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(OpaqueObject, self).write(ostream)
        ostream.write(tstream.buffer)
Example #27
0
    def write(self, ostream):
        tstream = BytearrayStream()

        for ui in self.unique_identifiers:
            ui.write(tstream)

        # Write the length and value of the request payload
        self.length = tstream.length()
        super(LocateResponsePayload, self).write(ostream)
        ostream.write(tstream.buffer)
Example #28
0
    def write(self, ostream):
        tstream = BytearrayStream()

        for attribute in self.attributes:
            attribute.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(Template, self).write(ostream)
        ostream.write(tstream.buffer)
Example #29
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.credential_type.write(tstream)
        self.credential_value.write(tstream)

        # Write the length and value of the credential
        self.length = tstream.length()
        super(Credential, self).write(ostream)
        ostream.write(tstream.buffer)
Example #30
0
    def write(self, ostream):
        tstream = BytearrayStream()

        if self.unique_identifier is not None:
            self.unique_identifier.write(tstream)

        # Write the length and value of the request payload
        self.length = tstream.length()
        super(DestroyRequestPayload, self).write(ostream)
        ostream.write(tstream.buffer)
Example #31
0
    def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        tstream = BytearrayStream()

        self.unique_identifier.write(tstream, kmip_version=kmip_version)

        # Write the length and value of the request payload
        self.length = tstream.length()
        super(DestroyResponsePayload, self).write(ostream,
                                                  kmip_version=kmip_version)
        ostream.write(tstream.buffer)
Example #32
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.application_namespace.write(tstream)
        self.application_data.write(tstream)

        # Write the length and value of the request payload
        self.length = tstream.length()
        super(self.__class__, self).write(ostream)
        ostream.write(tstream.buffer)
Example #33
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.secret_data_type.write(tstream)
        self.key_block.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(SecretData, self).write(ostream)
        ostream.write(tstream.buffer)
Example #34
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.opaque_data_type.write(tstream)
        self.opaque_data_value.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(OpaqueObject, self).write(ostream)
        ostream.write(tstream.buffer)
Example #35
0
    def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        tstream = BytearrayStream()

        self.opaque_data_type.write(tstream, kmip_version=kmip_version)
        self.opaque_data_value.write(tstream, kmip_version=kmip_version)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(OpaqueObject, self).write(ostream, kmip_version=kmip_version)
        ostream.write(tstream.buffer)
Example #36
0
    def write(self, ostream):
        tstream = BytearrayStream()

        for attribute in self.attributes:
            attribute.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(Template, self).write(ostream)
        ostream.write(tstream.buffer)
Example #37
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.credential_type.write(tstream)
        self.credential_value.write(tstream)

        # Write the length and value of the credential
        self.length = tstream.length()
        super(self.__class__, self).write(ostream)
        ostream.write(tstream.buffer)
Example #38
0
    def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        tstream = BytearrayStream()

        for attribute in self.attributes:
            attribute.write(tstream, kmip_version=kmip_version)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(Template, self).write(ostream, kmip_version=kmip_version)
        ostream.write(tstream.buffer)
Example #39
0
        def write(self, ostream):
            tstream = BytearrayStream()

            self.username.write(tstream)
            if self.password is not None:
                self.password.write(tstream)

            # Write the length and value of the credential
            self.length = tstream.length()
            super(self.__class__, self).write(ostream)
            ostream.write(tstream.buffer)
Example #40
0
        def write(self, ostream):
            tstream = BytearrayStream()

            self.username.write(tstream)
            if self.password is not None:
                self.password.write(tstream)

            # Write the length and value of the credential
            self.length = tstream.length()
            super(Credential.UsernamePasswordCredential, self).write(ostream)
            ostream.write(tstream.buffer)
Example #41
0
    def write(self, ostream):
        tstream = BytearrayStream()

        # Write the object type and template attribute of the request payload
        self.object_type.write(tstream)
        self.template_attribute.write(tstream)

        # Write the length and value of the request payload
        self.length = tstream.length()
        super(CreateRequestPayload, self).write(ostream)
        ostream.write(tstream.buffer)
Example #42
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.key_material.write(tstream)

        for attribute in self.attributes:
            attribute.write(tstream)

        self.length = tstream.length()
        super(self.__class__, self).write(ostream)
        ostream.write(tstream.buffer)
Example #43
0
    def write(self, ostream):
        tstream = BytearrayStream()

        # Write the value and type of the name
        self.name_value.write(tstream)
        self.name_type.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(Name, self).write(ostream)
        ostream.write(tstream.buffer)
Example #44
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.object_type.write(tstream)
        self.unique_identifier.write(tstream)
        self.secret.write(tstream)

        # Write the length and value of the request payload
        self.length = tstream.length()
        super(GetResponsePayload, self).write(ostream)
        ostream.write(tstream.buffer)
Example #45
0
    def write(self, ostream):
        tstream = BytearrayStream()

        # Write the value and type of the name
        self.name_value.write(tstream)
        self.name_type.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(self.__class__, self).write(ostream)
        ostream.write(tstream.buffer)
Example #46
0
    def write(self, ostream):
        tstream = BytearrayStream()

        # Write the details of the certificate
        self.certificate_type.write(tstream)
        self.certificate_value.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(self.__class__, self).write(ostream)
        ostream.write(tstream.buffer)
Example #47
0
    def setUp(self):
        super(TestApplicationSpecificInformation, self).setUp()

        self.encoding_default = BytearrayStream((
            b'\x42\x00\x04\x01\x00\x00\x00\x10\x42\x00\x03\x07\x00\x00\x00\x00'
            b'\x42\x00\x02\x07\x00\x00\x00\x00'))
        self.encoding = BytearrayStream((
            b'\x42\x00\x04\x01\x00\x00\x00\x28\x42\x00\x03\x07\x00\x00\x00\x03'
            b'\x73\x73\x6C\x00\x00\x00\x00\x00\x42\x00\x02\x07\x00\x00\x00\x0F'
            b'\x77\x77\x77\x2E\x65\x78\x61\x6D\x70\x6C\x65\x2E\x63\x6F\x6D'
            b'\x00'))
Example #48
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.key_material.write(tstream)

        for attribute in self.attributes:
            attribute.write(tstream)

        self.length = tstream.length()
        super(KeyValue, self).write(ostream)
        ostream.write(tstream.buffer)
Example #49
0
    def write(self, ostream):
        tstream = BytearrayStream()

        # Write the request header and all batch items
        self.response_header.write(tstream)
        for batch_item in self.batch_items:
            batch_item.write(tstream)

        # Write the TTLV encoding of the request message
        self.length = tstream.length()
        super(self.__class__, self).write(ostream)
        ostream.write(tstream.buffer)
Example #50
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.attribute_name.write(tstream)
        if self.attribute_index is not None:
            self.attribute_index.write(tstream)
        self.attribute_value.write(tstream)

        # Write the length and value of the attribute
        self.length = tstream.length()
        super(self.__class__, self).write(ostream)
        ostream.write(tstream.buffer)
Example #51
0
    def write(self, ostream):
        tstream = BytearrayStream()

        # Write the contents of a response header to the stream
        self.protocol_version.write(tstream)
        self.time_stamp.write(tstream)
        self.batch_count.write(tstream)

        # Write the length and value of the request header
        self.length = tstream.length()
        super(self.__class__, self).write(ostream)
        ostream.write(tstream.buffer)
Example #52
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.unique_identifier.write(tstream)

        if self.cryptographic_parameters is not None:
            self.cryptographic_parameters.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(self.__class__, self).write(ostream)
        ostream.write(tstream.buffer)
Example #53
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.unique_identifier.write(tstream)

        if self.cryptographic_parameters is not None:
            self.cryptographic_parameters.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(KeyInformation, self).write(ostream)
        ostream.write(tstream.buffer)
Example #54
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.attribute_name.write(tstream)
        if self.attribute_index is not None:
            self.attribute_index.write(tstream)
        self.attribute_value.write(tstream)

        # Write the length and value of the attribute
        self.length = tstream.length()
        super(Attribute, self).write(ostream)
        ostream.write(tstream.buffer)
Example #55
0
    def write(self, ostream):
        tstream = BytearrayStream()

        # Write the contents of the request payload
        self.unique_identifier.write(tstream)

        if self.template_attribute is not None:
            self.template_attribute.write(tstream)

        # Write the length and value of the request payload
        self.length = tstream.length()
        super(self.__class__, self).write(ostream)
        ostream.write(tstream.buffer)
Example #56
0
    def test_write_false(self):
        """
        Test that a Boolean object representing the value False can be written
        to a byte stream.
        """
        encoding = (b'\x42\x00\x00\x06\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00'
                    b'\x00\x00')
        stream = BytearrayStream()
        boolean = Boolean(False)

        boolean.write(stream)

        self.assertEqual(encoding, stream.read())
Example #57
0
    def write(self, ostream):
        tstream = BytearrayStream()

        self.key_material.write(tstream)

        if self.attributes is not None:
            for attribute in self.attributes:
                attribute.write(tstream)

        # Write the length and value of the credential
        self.length = tstream.length()
        super(self.__class__, self).write(ostream)
        ostream.write(tstream.buffer)
Example #58
0
    def write(self, ostream):
        tstream = BytearrayStream()
        if self.maximum_items is not None:
            self.maximum_items.write(tstream)
        if self.storage_status_mask is not None:
            self.storage_status_mask.write(tstream)
        if self.attributes is not None:
            for a in self.attributes:
                a.write(tstream)

        # Write the length and value of the request payload
        self.length = tstream.length()
        super(LocateRequestPayload, self).write(ostream)
        ostream.write(tstream.buffer)
Example #59
0
    def write(self, ostream):
        """
        Write the data encoding the ServerInformation object to a stream.

        Args:
            ostream (Stream): A data stream in which to encode object data,
                supporting a write method; usually a BytearrayStream object.
        """
        tstream = BytearrayStream()
        tstream.write(self.data.buffer)

        self.length = tstream.length()
        super(ServerInformation, self).write(ostream)
        ostream.write(tstream.buffer)