Exemple #1
0
    def __init__(self, key: "Union[KeyVaultKey, str]",
                 credential: "TokenCredential", **kwargs: "Any") -> None:
        if isinstance(key, KeyVaultKey):
            self._key = key
            self._key_id = parse_vault_id(key.id)
            self._allowed_ops = frozenset(self._key.key_operations)
        elif isinstance(key, str):
            self._key = None
            self._key_id = parse_vault_id(key)
            self._keys_get_forbidden = None  # type: Optional[bool]

            # will be replaced with actual permissions before any local operations are attempted, if we can get the key
            self._allowed_ops = frozenset()
        else:
            raise ValueError(
                "'key' must be a KeyVaultKey instance or a key ID string including a version"
            )

        if not self._key_id.version:
            raise ValueError("'key' must include a version")

        self._internal_key = None  # type: Optional[_Key]

        super(CryptographyClient,
              self).__init__(vault_url=self._key_id.vault_url,
                             credential=credential,
                             **kwargs)
    def __init__(self, key: "Union[Key, str]", credential: "TokenCredential",
                 **kwargs: "**Any") -> None:
        if isinstance(key, Key):
            self._key = key
            self._key_id = parse_vault_id(key.id)
        elif isinstance(key, str):
            self._key = None
            self._key_id = parse_vault_id(key)
            self._get_key_forbidden = None  # type: Optional[bool]
        else:
            raise ValueError(
                "'key' must be a Key instance or a key ID string including a version"
            )

        if not self._key_id.version:
            raise ValueError("'key' must include a version")

        super(CryptographyClient,
              self).__init__(vault_url=self._key_id.vault_url,
                             credential=credential,
                             **kwargs)