@@ -29,38 +29,35 @@ class HcVaultKmsClient(tink.KmsClient):
2929 """Basic HashiCorp Vault client for AEAD."""
3030
3131 def __init__ (
32- self , key_uri : Optional [ str ] , token : Optional [str ], ns : Optional [str ] = None ,
32+ self , key_uri : str , token : Optional [str ], ns : Optional [str ] = None ,
3333 role_id : Optional [str ] = None , secret_id : Optional [str ] = None
3434 ) -> None :
3535 """Creates a new HcVaultKmsClient that is bound to the key specified in 'key_uri'.
3636
3737 Uses the specified credentials when communicating with the KMS.
3838
3939 Args:
40- key_uri: The URI of the key the client should be bound to. If it is None
41- or empty, then the client is not bound to any particular key.
40+ key_uri: The URI of the key the client should be bound to.
4241 token: The Vault token.
4342 ns: The Vault namespace.
4443
4544 Raises:
4645 TinkError: If the key uri is not valid.
4746 """
4847
49- if not key_uri :
50- self ._key_uri = None
51- self ._client = None # type: ignore[assignment]
52- elif key_uri .startswith (VAULT_KEYURI_PREFIX ):
48+ if key_uri .startswith (VAULT_KEYURI_PREFIX ):
5349 self ._key_uri = key_uri
54- parsed = urlparse (key_uri [len (VAULT_KEYURI_PREFIX ):])
55- vault_url = parsed .scheme + '://' + parsed .netloc
56- self ._client = hvac .Client (
57- url = vault_url ,
58- token = token ,
59- namespace = ns ,
60- verify = False
61- )
6250 else :
6351 raise tink .TinkError ('Invalid key_uri.' )
52+
53+ parsed = urlparse (key_uri [len (VAULT_KEYURI_PREFIX ):])
54+ vault_url = parsed .scheme + '://' + parsed .netloc
55+ self ._client = hvac .Client (
56+ url = vault_url ,
57+ token = token ,
58+ namespace = ns ,
59+ verify = False
60+ )
6461 if role_id and secret_id and self ._client is not None :
6562 self ._client .auth .approle .login (role_id = role_id , secret_id = secret_id )
6663
0 commit comments