public final class AndroidKeystoreKmsClient extends Object implements KmsClient
KmsClient for Android Keystore.
This class requires Android M (API level 23) or newer.
| Modifier and Type | Field and Description |
|---|---|
static String |
PREFIX
The prefix of all keys stored in Android Keystore.
|
| Constructor and Description |
|---|
AndroidKeystoreKmsClient() |
AndroidKeystoreKmsClient(String uri)
Constructs an
AndroidKeystoreKmsClient that is bound to a single key identified by
uri. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
doesSupport(String uri) |
static void |
generateNewAeadKey(String keyUri)
Generates a new key in Android Keystore.
|
Aead |
getAead(String uri)
Gets an
Aead backed by keyUri. |
static Aead |
getOrGenerateNewAeadKey(String keyUri)
Generates a new key in Android Keystore, if it doesn't exist.
|
KmsClient |
withCredentials(String unused)
Initializes a
KmsClient for Android Keystore. |
KmsClient |
withDefaultCredentials()
Initializes a
KmsClient for Android Keystore. |
public static final String PREFIX
public AndroidKeystoreKmsClient()
throws GeneralSecurityException
GeneralSecurityExceptionpublic AndroidKeystoreKmsClient(String uri)
AndroidKeystoreKmsClient that is bound to a single key identified by
uri.public boolean doesSupport(String uri)
doesSupport in interface KmsClientkeyUri is not null and equal to uri, or keyUri is null and uri starts with PREFIX.public KmsClient withCredentials(String unused) throws GeneralSecurityException
KmsClient for Android Keystore.
Note that Android Keystore doesn't need credentials, thus the credential path is unused.
withCredentials in interface KmsClientGeneralSecurityExceptionpublic KmsClient withDefaultCredentials() throws GeneralSecurityException
KmsClient for Android Keystore.
Note that Android Keystore does not use credentials.
withDefaultCredentials in interface KmsClientGeneralSecurityExceptionpublic Aead getAead(String uri) throws GeneralSecurityException
KmsClientAead backed by keyUri.getAead in interface KmsClientGeneralSecurityException - if the URI is not supported or invalidpublic static Aead getOrGenerateNewAeadKey(String keyUri) throws GeneralSecurityException, IOException
At the moment it can generate only AES256-GCM keys.
GeneralSecurityExceptionIOExceptionpublic static void generateNewAeadKey(String keyUri) throws GeneralSecurityException
At the moment it can generate only AES256-GCM keys.
GeneralSecurityException