kmip/core/objects.py
def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        """
        Read the data encoding the Credential struct and decode it into its
        constituent parts.

        Args:
            input_stream (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 1.0.

        Raises:
            ValueError: Raised if either the credential type or value are
                missing from the encoding.
        """
        super(Credential, self).read(input_stream, kmip_version=kmip_version)
        local_stream = BytearrayStream(input_stream.read(self.length))

        if self.is_tag_next(enums.Tags.CREDENTIAL_TYPE, local_stream):
            self._credential_type = primitives.Enumeration(
                enum=enums.CredentialType,
                tag=enums.Tags.CREDENTIAL_TYPE
            )
            self._credential_type.read(local_stream, kmip_version=kmip_version)
        else:
            raise ValueError(
                "Credential encoding missing the credential type."
            )

        if self.is_tag_next(enums.Tags.CREDENTIAL_VALUE, local_stream):
            if self.credential_type == \
                    enums.CredentialType.USERNAME_AND_PASSWORD:
                self._credential_value = UsernamePasswordCredential()
            elif self.credential_type == enums.CredentialType.DEVICE:
                self._credential_value = DeviceCredential()
            elif self.credential_type == enums.CredentialType.ATTESTATION:
                self._credential_value = AttestationCredential()
            else:
                raise ValueError(
                    "Credential encoding includes unrecognized credential "
                    "type."
                )
            self._credential_value.read(
                local_stream,
                kmip_version=kmip_version
            )
        else:
            raise ValueError(
                "Credential encoding missing the credential value."
            )

        self.is_oversized(local_stream)
def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        super(Credential, self).read(input_stream, kmip_version=kmip_version)
        local_stream = BytearrayStream(input_stream.read(self.length))

        if self.is_tag_next(enums.Tags.CREDENTIAL_TYPE, local_stream):
            self._credential_type = primitives.Enumeration(
                enum=enums.CredentialType,
                tag=enums.Tags.CREDENTIAL_TYPE
            )
            self._credential_type.read(local_stream, kmip_version=kmip_version)
        else:
            raise ValueError(
                "Credential encoding missing the credential type."
            )

        if self.is_tag_next(enums.Tags.CREDENTIAL_VALUE, local_stream):
            if self.credential_type == \
                    enums.CredentialType.USERNAME_AND_PASSWORD:
                self._credential_value = UsernamePasswordCredential()
            elif self.credential_type == enums.CredentialType.DEVICE:
                self._credential_value = DeviceCredential()
            elif self.credential_type == enums.CredentialType.ATTESTATION:
                self._credential_value = AttestationCredential()
            else:
                raise ValueError(
                    "Credential encoding includes unrecognized credential "
                    "type."
                )
            self._credential_value.read(
                local_stream,
                kmip_version=kmip_version
            )
        else:
            raise ValueError(
                "Credential encoding missing the credential value."
            )

        self.is_oversized(local_stream)
def read ( self , input_stream , kmip_version = enums . KMIPVersion . KMIP_1_0 ) : super ( Credential , self ) . read ( input_stream , kmip_version = kmip_version ) local_stream = BytearrayStream ( input_stream . read ( self . length ) ) if self . is_tag_next ( enums . Tags . CREDENTIAL_TYPE , local_stream ) : self . _credential_type = primitives . Enumeration ( enum = enums . CredentialType , tag = enums . Tags . CREDENTIAL_TYPE ) self . _credential_type . read ( local_stream , kmip_version = kmip_version ) else : raise ValueError ( "Credential encoding missing the credential type." ) if self . is_tag_next ( enums . Tags . CREDENTIAL_VALUE , local_stream ) : if self . credential_type == enums . CredentialType . USERNAME_AND_PASSWORD : self . _credential_value = UsernamePasswordCredential ( ) elif self . credential_type == enums . CredentialType . DEVICE : self . _credential_value = DeviceCredential ( ) elif self . credential_type == enums . CredentialType . ATTESTATION : self . _credential_value = AttestationCredential ( ) else : raise ValueError ( "Credential encoding includes unrecognized credential " "type." ) self . _credential_value . read ( local_stream , kmip_version = kmip_version ) else : raise ValueError ( "Credential encoding missing the credential value." ) self . is_oversized ( local_stream )
Read the data encoding the Credential struct and decode it into its
        constituent parts.

        Args:
            input_stream (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 1.0.

        Raises:
            ValueError: Raised if either the credential type or value are
                missing from the encoding.
Read the data encoding the Credential struct and decode it into its constituent parts .