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:
java.lang.AutoCloseable
public class C4KeyPair extends C4NativePeer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
C4KeyPair.NativeImpl
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
static C4KeyPair
createKeyPair(java.lang.String keyAlias, KeyStoreManager.KeyAlgorithm algorithm, KeyStoreManager.KeySize keySize)
Convenience method for Android, which has only one safe keystore and doesn't use passwords for keys.static C4KeyPair
createKeyPair(java.security.KeyStore keyStore, java.lang.String keyAlias, char[] keyPassword, KeyStoreManager.KeyAlgorithm algorithm, KeyStoreManager.KeySize keySize)
Create a C4Key pair.static C4KeyPair
createKeyPair(java.security.KeyStore keyStore, java.lang.String keyAlias, char[] keyPassword, KeyStoreManager.KeyAlgorithm algorithm, KeyStoreManager.KeySize keySize, java.security.KeyPair keys)
Create a C4Key pair.byte[]
generateSelfSignedCertificate(KeyStoreManager.KeyAlgorithm algorithm, KeyStoreManager.KeySize keySize, java.util.Map<java.lang.String,java.lang.String> attributes, KeyStoreManager.CertUsage usage, long expSecond)
java.lang.String
getKeyAlias()
char[]
getKeyPassword()
java.security.KeyPair
getKeys()
java.security.KeyStore
getKeyStore()
java.lang.String
toString()
-
-
-
Method Detail
-
createKeyPair
@NonNull public static C4KeyPair createKeyPair(@Nullable java.security.KeyStore keyStore, @NonNull java.lang.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 java.security.KeyStore keyStore, @NonNull java.lang.String keyAlias, @Nullable char[] keyPassword, @NonNull KeyStoreManager.KeyAlgorithm algorithm, @NonNull KeyStoreManager.KeySize keySize, @Nullable java.security.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 java.lang.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 java.security.KeyStore getKeyStore()
-
getKeyAlias
@NonNull public java.lang.String getKeyAlias()
-
getKeyPassword
@Nullable public char[] getKeyPassword()
-
getKeys
@Nullable public java.security.KeyPair getKeys()
-
generateSelfSignedCertificate
@NonNull public byte[] generateSelfSignedCertificate(@NonNull KeyStoreManager.KeyAlgorithm algorithm, @NonNull KeyStoreManager.KeySize keySize, @NonNull java.util.Map<java.lang.String,java.lang.String> attributes, @NonNull KeyStoreManager.CertUsage usage, long expSecond) throws CouchbaseLiteException
- Throws:
CouchbaseLiteException
-
close
@CallSuper public void close()
-
toString
@NonNull public java.lang.String toString()
- Overrides:
toString
in classC4NativePeer
-
-