Package com.couchbase.lite.internal
Class KeyStoreManager
- java.lang.Object
-
- com.couchbase.lite.internal.KeyStoreManager
-
- Direct Known Subclasses:
KeyStoreManagerDelegate
public abstract class KeyStoreManager extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
KeyStoreManager.CertUsage
static class
KeyStoreManager.KeyAlgorithm
static class
KeyStoreManager.KeySize
-
Field Summary
Fields Modifier and Type Field Description static String
ANON_COMMON_NAME
static int
ANON_EXPIRATION_YEARS
static String
ANON_IDENTITY_ALIAS
-
Constructor Summary
Constructors Constructor Description KeyStoreManager()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static void
checkAlias(String alias)
abstract void
createSelfSignedCertEntry(KeyStore keyStore, String alias, char[] keyPassword, boolean isServer, Map<String,String> attributes, Date expiration)
abstract byte[]
decrypt(C4KeyPair keyPair, byte[] data)
Decrypts data using the private key.abstract int
deleteEntries(KeyStore keyStore, Fn.Predicate<String> filter)
abstract boolean
findAlias(KeyStore keyStore, String targetAlias)
abstract void
free(C4KeyPair keyPair)
Called when the C4KeyPair is released and the externalKey is no longer needed and when associated resources may be freedabstract List<Certificate>
getCertificateChain(KeyStore keyStore, String keyAlias)
static KeyStoreManager
getInstance()
abstract PrivateKey
getKey(KeyStore keyStore, String keyAlias, char[] keyPassword)
abstract byte[]
getKeyData(C4KeyPair keyPair)
Provides the _public_ key's raw data, as an ASN.1 DER sequence of [modulus, exponent].static void
setInstance(KeyStoreManager mgr)
abstract byte[]
sign(C4KeyPair keyPair, Signature.SignatureDigestAlgorithm digestAlgorithm, byte[] data)
Uses the private key to generate a signature of input data.
-
-
-
Field Detail
-
ANON_IDENTITY_ALIAS
public static final String ANON_IDENTITY_ALIAS
- See Also:
- Constant Field Values
-
ANON_COMMON_NAME
public static final String ANON_COMMON_NAME
- See Also:
- Constant Field Values
-
ANON_EXPIRATION_YEARS
public static final int ANON_EXPIRATION_YEARS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
@NonNull public static KeyStoreManager getInstance()
-
checkAlias
public static void checkAlias(@NonNull String alias) throws CouchbaseLiteException
- Throws:
CouchbaseLiteException
-
setInstance
public static void setInstance(KeyStoreManager mgr)
-
getKeyData
@Nullable public abstract byte[] getKeyData(@NonNull C4KeyPair keyPair)
Provides the _public_ key's raw data, as an ASN.1 DER sequence of [modulus, exponent].- Parameters:
keyPair
- The key pair- Returns:
- the raw key data or null failure.
-
sign
@Nullable public abstract byte[] sign(@NonNull C4KeyPair keyPair, @NonNull Signature.SignatureDigestAlgorithm digestAlgorithm, @NonNull byte[] data)
Uses the private key to generate a signature of input data.- Parameters:
keyPair
- The key pairdigestAlgorithm
- Indicates what type of digest to create the signature from.data
- The data to be signed.- Returns:
- the signature (length must be equal to the key size) or null on failure.
-
decrypt
@Nullable public abstract byte[] decrypt(@NonNull C4KeyPair keyPair, @NonNull byte[] data)
Decrypts data using the private key.- Parameters:
keyPair
- The key pairdata
- The data to be encrypted.- Returns:
- the raw key data or null failure.
-
free
public abstract void free(@NonNull C4KeyPair keyPair)
Called when the C4KeyPair is released and the externalKey is no longer needed and when associated resources may be freed- Parameters:
keyPair
- The key pair
-
findAlias
public abstract boolean findAlias(@Nullable KeyStore keyStore, @NonNull String targetAlias) throws CouchbaseLiteException
- Throws:
CouchbaseLiteException
-
getKey
@Nullable public abstract PrivateKey getKey(@Nullable KeyStore keyStore, @NonNull String keyAlias, @Nullable char[] keyPassword)
-
getCertificateChain
@Nullable public abstract List<Certificate> getCertificateChain(@Nullable KeyStore keyStore, @NonNull String keyAlias)
-
createSelfSignedCertEntry
public abstract void createSelfSignedCertEntry(@Nullable KeyStore keyStore, @NonNull String alias, @Nullable char[] keyPassword, boolean isServer, @NonNull Map<String,String> attributes, @Nullable Date expiration) throws CouchbaseLiteException
- Throws:
CouchbaseLiteException
-
deleteEntries
public abstract int deleteEntries(@Nullable KeyStore keyStore, Fn.Predicate<String> filter) throws CouchbaseLiteException
- Throws:
CouchbaseLiteException
-
-