def __attrs_post_init__()

in src/dynamodb_encryption_sdk/delegated_keys/jce.py [0:0]


    def __attrs_post_init__(self):
        # () -> None
        """Identify the correct key handler class for the requested algorithm and load the provided key."""
        # First try for encryption ciphers
        # https://docs.oracle.com/javase/8/docs/api/javax/crypto/Cipher.html
        try:
            key_transformer = primitives.JAVA_ENCRYPTION_ALGORITHM[self.algorithm]
        except KeyError:
            pass
        else:
            self.__key = key_transformer.load_key(  # attrs confuses pylint: disable=attribute-defined-outside-init
                self.key, self._key_type, self._key_encoding
            )
            self._enable_encryption()
            self._enable_wrap()
            return

        # Now try for authenticators
        # https://docs.oracle.com/javase/8/docs/api/javax/crypto/Mac.html
        # https://docs.oracle.com/javase/8/docs/api/java/security/Signature.html
        try:
            key_transformer = authentication.JAVA_AUTHENTICATOR[self.algorithm]
        except KeyError:
            pass
        else:
            self.__key = key_transformer.load_key(  # attrs confuses pylint: disable=attribute-defined-outside-init
                self.key, self._key_type, self._key_encoding
            )
            self._enable_authentication()
            return

        raise JceTransformationError('Unknown algorithm: "{}"'.format(self.algorithm))