kmip/core/objects.py
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_3):
        """
        Read the data encoding the ValidationInformation structure and decode
        it into its constituent parts.

        Args:
            input_buffer (stream): A data stream containing encoded object
                data, supporting a read method; usually a BytearrayStream
                object.
            kmip_version (KMIPVersion): An enumeration defining the KMIP
                version with which the object will be decoded. Optional,
                defaults to KMIP 2.0.

        Raises:
            InvalidKmipEncoding: Raised if the validation authority type,
                validation version major, validation type, and/or validation
                level are missing from the encoding.
            VersionNotSupported: Raised when a KMIP version is provided that
                does not support the ValidationInformation structure.
        """
        if kmip_version < enums.KMIPVersion.KMIP_1_3:
            raise exceptions.VersionNotSupported(
                "KMIP {} does not support the ValidationInformation "
                "object.".format(
                    kmip_version.value
                )
            )

        super(ValidationInformation, self).read(
            input_buffer,
            kmip_version=kmip_version
        )
        local_buffer = utils.BytearrayStream(input_buffer.read(self.length))

        if self.is_tag_next(
            enums.Tags.VALIDATION_AUTHORITY_TYPE,
            local_buffer
        ):
            validation_authority_type = primitives.Enumeration(
                enums.ValidationAuthorityType,
                tag=enums.Tags.VALIDATION_AUTHORITY_TYPE
            )
            validation_authority_type.read(
                local_buffer,
                kmip_version=kmip_version
            )
            self._validation_authority_type = validation_authority_type
        else:
            raise exceptions.InvalidKmipEncoding(
                "The ValidationInformation encoding is missing the "
                "validation authority type."
            )

        if self.is_tag_next(
            enums.Tags.VALIDATION_AUTHORITY_COUNTRY,
            local_buffer
        ):
            validation_authority_country = primitives.TextString(
                tag=enums.Tags.VALIDATION_AUTHORITY_COUNTRY
            )
            validation_authority_country.read(
                local_buffer,
                kmip_version=kmip_version
            )
            self._validation_authority_country = validation_authority_country

        if self.is_tag_next(enums.Tags.VALIDATION_AUTHORITY_URI, local_buffer):
            validation_authority_uri = primitives.TextString(
                tag=enums.Tags.VALIDATION_AUTHORITY_URI
                )
            validation_authority_uri.read(
                local_buffer,
                kmip_version=kmip_version
            )
            self._validation_authority_uri = validation_authority_uri

        if self.is_tag_next(
            enums.Tags.VALIDATION_VERSION_MAJOR,
            local_buffer
        ):
            validation_version_major = primitives.Integer(
                tag=enums.Tags.VALIDATION_VERSION_MAJOR
            )
            validation_version_major.read(
                local_buffer,
                kmip_version=kmip_version
            )
            self._validation_version_major = validation_version_major
        else:
            raise exceptions.InvalidKmipEncoding(
                "The ValidationInformation encoding is missing the "
                "validation version major."
            )

        if self.is_tag_next(
            enums.Tags.VALIDATION_VERSION_MINOR,
            local_buffer
        ):
            validation_version_minor = primitives.Integer(
                tag=enums.Tags.VALIDATION_VERSION_MINOR
            )
            validation_version_minor.read(
                local_buffer,
                kmip_version=kmip_version
            )
            self._validation_version_minor = validation_version_minor

        if self.is_tag_next(enums.Tags.VALIDATION_TYPE, local_buffer):
            validation_type = primitives.Enumeration(
                enums.ValidationType,
                tag=enums.Tags.VALIDATION_TYPE
            )
            validation_type.read(
                local_buffer,
                kmip_version=kmip_version
            )
            self._validation_type = validation_type
        else:
            raise exceptions.InvalidKmipEncoding(
                "The ValidationInformation encoding is missing the "
                "validation type."
            )

        if self.is_tag_next(enums.Tags.VALIDATION_LEVEL, local_buffer):
            validation_level = primitives.Integer(
                tag=enums.Tags.VALIDATION_LEVEL
            )
            validation_level.read(local_buffer, kmip_version=kmip_version)
            self._validation_level = validation_level
        else:
            raise exceptions.InvalidKmipEncoding(
                "The ValidationInformation encoding is missing the "
                "validation level."
            )

        if self.is_tag_next(
            enums.Tags.VALIDATION_CERTIFICATE_IDENTIFIER,
            local_buffer
        ):
            validation_certificate_identifier = primitives.TextString(
                tag=enums.Tags.VALIDATION_CERTIFICATE_IDENTIFIER
            )
            validation_certificate_identifier.read(
                local_buffer,
                kmip_version=kmip_version
            )
            self._validation_certificate_identifier = \
                validation_certificate_identifier

        if self.is_tag_next(
            enums.Tags.VALIDATION_CERTIFICATE_URI,
            local_buffer
        ):
            validation_certificate_uri = primitives.TextString(
                tag=enums.Tags.VALIDATION_CERTIFICATE_URI
            )
            validation_certificate_uri.read(
                local_buffer,
                kmip_version=kmip_version
            )
            self._validation_certificate_uri = validation_certificate_uri

        if self.is_tag_next(enums.Tags.VALIDATION_VENDOR_URI, local_buffer):
            validation_vendor_uri = primitives.TextString(
                tag=enums.Tags.VALIDATION_VENDOR_URI
            )
            validation_vendor_uri.read(local_buffer, kmip_version=kmip_version)
            self._validation_vendor_uri = validation_vendor_uri

        validation_profiles = []
        while self.is_tag_next(enums.Tags.VALIDATION_PROFILE, local_buffer):
            validation_profile = primitives.TextString(
                tag=enums.Tags.VALIDATION_PROFILE
            )
            validation_profile.read(local_buffer, kmip_version=kmip_version)
            validation_profiles.append(validation_profile)
        self._validation_profiles = validation_profiles

        self.is_oversized(local_buffer)
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_3):
        """
        Read the data encoding the ValidationInformation structure and decode
        it into its constituent parts.

        Args:
            input_buffer (stream): A data stream containing encoded object
                data, supporting a read method; usually a BytearrayStream
                object.
            kmip_version (KMIPVersion): An enumeration defining the KMIP
                version with which the object will be decoded. Optional,
                defaults to KMIP 2.0.

        Raises:
            InvalidKmipEncoding: Raised if the validation authority type,
                validation version major, validation type, and/or validation
                level are missing from the encoding.
            VersionNotSupported: Raised when a KMIP version is provided that
                does not support the ValidationInformation structure.
        """
        if kmip_version < enums.KMIPVersion.KMIP_1_3:
            raise exceptions.VersionNotSupported(
                "KMIP {} does not support the ValidationInformation "
                "object.".format(
                    kmip_version.value
                )
            )

        super(ValidationInformation, self).read(
            input_buffer,
            kmip_version=kmip_version
        )
        local_buffer = utils.BytearrayStream(input_buffer.read(self.length))

        if self.is_tag_next(
            enums.Tags.VALIDATION_AUTHORITY_TYPE,
            local_buffer
        ):
            validation_authority_type = primitives.Enumeration(
                enums.ValidationAuthorityType,
                tag=enums.Tags.VALIDATION_AUTHORITY_TYPE
            )
            validation_authority_type.read(
                local_buffer,
                kmip_version=kmip_version
            )
            self._validation_authority_type = validation_authority_type
        else:
            raise exceptions.InvalidKmipEncoding(
                "The ValidationInformation encoding is missing the "
                "validation authority type."
            )

        if self.is_tag_next(
            enums.Tags.VALIDATION_AUTHORITY_COUNTRY,
            local_buffer
        ):
            validation_authority_country = primitives.TextString(
                tag=enums.Tags.VALIDATION_AUTHORITY_COUNTRY
            )
            validation_authority_country.read(
                local_buffer,
                kmip_version=kmip_version
            )
            self._validation_authority_country = validation_authority_country

        if self.is_tag_next(enums.Tags.VALIDATION_AUTHORITY_URI, local_buffer):
            validation_authority_uri = primitives.TextString(
                tag=enums.Tags.VALIDATION_AUTHORITY_URI
                )
            validation_authority_uri.read(
                local_buffer,
                kmip_version=kmip_version
            )
            self._validation_authority_uri = validation_authority_uri

        if self.is_tag_next(
            enums.Tags.VALIDATION_VERSION_MAJOR,
            local_buffer
        ):
            validation_version_major = primitives.Integer(
                tag=enums.Tags.VALIDATION_VERSION_MAJOR
            )
            validation_version_major.read(
                local_buffer,
                kmip_version=kmip_version
            )
            self._validation_version_major = validation_version_major
        else:
            raise exceptions.InvalidKmipEncoding(
                "The ValidationInformation encoding is missing the "
                "validation version major."
            )

        if self.is_tag_next(
            enums.Tags.VALIDATION_VERSION_MINOR,
            local_buffer
        ):
            validation_version_minor = primitives.Integer(
                tag=enums.Tags.VALIDATION_VERSION_MINOR
            )
            validation_version_minor.read(
                local_buffer,
                kmip_version=kmip_version
            )
            self._validation_version_minor = validation_version_minor

        if self.is_tag_next(enums.Tags.VALIDATION_TYPE, local_buffer):
            validation_type = primitives.Enumeration(
                enums.ValidationType,
                tag=enums.Tags.VALIDATION_TYPE
            )
            validation_type.read(
                local_buffer,
                kmip_version=kmip_version
            )
            self._validation_type = validation_type
        else:
            raise exceptions.InvalidKmipEncoding(
                "The ValidationInformation encoding is missing the "
                "validation type."
            )

        if self.is_tag_next(enums.Tags.VALIDATION_LEVEL, local_buffer):
            validation_level = primitives.Integer(
                tag=enums.Tags.VALIDATION_LEVEL
            )
            validation_level.read(local_buffer, kmip_version=kmip_version)
            self._validation_level = validation_level
        else:
            raise exceptions.InvalidKmipEncoding(
                "The ValidationInformation encoding is missing the "
                "validation level."
            )

        if self.is_tag_next(
            enums.Tags.VALIDATION_CERTIFICATE_IDENTIFIER,
            local_buffer
        ):
            validation_certificate_identifier = primitives.TextString(
                tag=enums.Tags.VALIDATION_CERTIFICATE_IDENTIFIER
            )
            validation_certificate_identifier.read(
                local_buffer,
                kmip_version=kmip_version
            )
            self._validation_certificate_identifier = \
                validation_certificate_identifier

        if self.is_tag_next(
            enums.Tags.VALIDATION_CERTIFICATE_URI,
            local_buffer
        ):
            validation_certificate_uri = primitives.TextString(
                tag=enums.Tags.VALIDATION_CERTIFICATE_URI
            )
            validation_certificate_uri.read(
                local_buffer,
                kmip_version=kmip_version
            )
            self._validation_certificate_uri = validation_certificate_uri

        if self.is_tag_next(enums.Tags.VALIDATION_VENDOR_URI, local_buffer):
            validation_vendor_uri = primitives.TextString(
                tag=enums.Tags.VALIDATION_VENDOR_URI
            )
            validation_vendor_uri.read(local_buffer, kmip_version=kmip_version)
            self._validation_vendor_uri = validation_vendor_uri

        validation_profiles = []
        while self.is_tag_next(enums.Tags.VALIDATION_PROFILE, local_buffer):
            validation_profile = primitives.TextString(
                tag=enums.Tags.VALIDATION_PROFILE
            )
            validation_profile.read(local_buffer, kmip_version=kmip_version)
            validation_profiles.append(validation_profile)
        self._validation_profiles = validation_profiles

        self.is_oversized(local_buffer)
Read the data encoding the ValidationInformation structure and decode
        it into its constituent parts.

        Args:
            input_buffer (stream): A data stream containing encoded object
                data, supporting a read method; usually a BytearrayStream
                object.
            kmip_version (KMIPVersion): An enumeration defining the KMIP
                version with which the object will be decoded. Optional,
                defaults to KMIP 2.0.

        Raises:
            InvalidKmipEncoding: Raised if the validation authority type,
                validation version major, validation type, and/or validation
                level are missing from the encoding.
            VersionNotSupported: Raised when a KMIP version is provided that
                does not support the ValidationInformation structure.