Package com.couchbase.lite.internal.core
Class C4KeyPair
- java.lang.Object
-
- com.couchbase.lite.internal.core.C4NativePeer
-
- com.couchbase.lite.internal.core.C4KeyPair
-
- All Implemented Interfaces:
AutoCloseable
public class C4KeyPair extends C4NativePeer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
C4KeyPair.NativeImpl
-
Method Summary
-
-
-
Method Detail
-
createKeyPair
@NonNull public static C4KeyPair createKeyPair(@Nullable KeyStore keyStore, @NonNull String keyAlias, @Nullable char[] keyPassword, @NonNull KeyStoreManager.KeyAlgorithm algorithm, @NonNull KeyStoreManager.KeySize keySize) throws CouchbaseLiteException
Create a C4Key pair.- Parameters:
keyStore
- the KeyStore object containing the cert and key pairkeyAlias
- the alias by which the key is known to the keystorekeyPassword
- the password protecting the keyalgorithm
- key algorithm (must be KeyManager.KeyAlgorithm.RSA)keySize
- key size- Returns:
- a new C4KeyPair, representing the cert, public and private keys identified by the alias
- Throws:
CouchbaseLiteException
- on error
-
createKeyPair
@NonNull public static C4KeyPair createKeyPair(@Nullable KeyStore keyStore, @NonNull String keyAlias, @Nullable char[] keyPassword, @NonNull KeyStoreManager.KeyAlgorithm algorithm, @NonNull KeyStoreManager.KeySize keySize, @Nullable KeyPair keys) throws CouchbaseLiteException
Create a C4Key pair.- Parameters:
keyStore
- the KeyStore object containing the cert and key pairkeyAlias
- the alias by which the key is known to the keystorekeyPassword
- the password protecting the keyalgorithm
- key algorithm (must be KeyManager.KeyAlgorithm.RSA)keySize
- key sizekeys
- keyPair for the case that the KeyPair hasn't been saved into the KeyStore- Returns:
- a new C4KeyPair, representing the cert, public and private keys identified by the alias
- Throws:
CouchbaseLiteException
- on error
-
createKeyPair
@NonNull public static C4KeyPair createKeyPair(@NonNull String keyAlias, @NonNull KeyStoreManager.KeyAlgorithm algorithm, @NonNull KeyStoreManager.KeySize keySize) throws CouchbaseLiteException
Convenience method for Android, which has only one safe keystore and doesn't use passwords for keys.- Parameters:
keyAlias
- the alias by which the key is known to the keystorealgorithm
- key algorithm (must be KeyManager.KeyAlgorithm.RSA)keySize
- key size- Returns:
- a new C4KeyPair, representing the cert, public and private keys identified by the alias
- Throws:
CouchbaseLiteException
- on error
-
getKeyStore
@Nullable public KeyStore getKeyStore()
-
getKeyAlias
@NonNull public String getKeyAlias()
-
getKeyPassword
@Nullable public char[] getKeyPassword()
-
getKeys
@Nullable public KeyPair getKeys()
-
generateSelfSignedCertificate
@NonNull public byte[] generateSelfSignedCertificate(@NonNull KeyStoreManager.KeyAlgorithm algorithm, @NonNull KeyStoreManager.KeySize keySize, @NonNull Map<String,String> attributes, @NonNull KeyStoreManager.CertUsage usage, long expSecond) throws CouchbaseLiteException
- Throws:
CouchbaseLiteException
-
close
@CallSuper public void close()
-
toString
@NonNull public String toString()
- Overrides:
toString
in classC4NativePeer
-
-