Package com.couchbase.lite
Class TLSIdentity
java.lang.Object
com.couchbase.lite.internal.BaseTLSIdentity
com.couchbase.lite.TLSIdentity
- All Implemented Interfaces:
AutoCloseable
public final class TLSIdentity
extends com.couchbase.lite.internal.BaseTLSIdentity
ENTERPRISE EDITION API
TLSIdentity provides the identity information obtained from the given KeyStore,
including a private key and X.509 certificate chain. TLSIdentities are backed by the
KeyStore and do not extract private key materials. The TLSIdentity is used by
URLEndpointListener to setup the TLS communication or by the Replicator
to set up the client certificate authentication.
-
Field Summary
Fields inherited from class com.couchbase.lite.internal.BaseTLSIdentity
CERT_ATTRIBUTE_COMMON_NAME, CERT_ATTRIBUTE_COUNTRY, CERT_ATTRIBUTE_EMAIL_ADDRESS, CERT_ATTRIBUTE_GIVEN_NAME, CERT_ATTRIBUTE_HOSTNAME, CERT_ATTRIBUTE_IP_ADDRESS, CERT_ATTRIBUTE_LOCALITY, CERT_ATTRIBUTE_ORGANIZATION, CERT_ATTRIBUTE_ORGANIZATION_UNIT, CERT_ATTRIBUTE_POSTAL_ADDRESS, CERT_ATTRIBUTE_POSTAL_CODE, CERT_ATTRIBUTE_PSEUDONYM, CERT_ATTRIBUTE_REGISTERED_ID, CERT_ATTRIBUTE_STATE_OR_PROVINCE, CERT_ATTRIBUTE_SURNAME, CERT_ATTRIBUTE_URL -
Method Summary
Modifier and TypeMethodDescriptionstatic TLSIdentitycreateIdentity(boolean isServer, Map<String, String> attributes, Date expiration, KeyStore keyStore, String alias, char[] keyPassword) Deprecated.static TLSIdentitycreateIdentity(Set<KeyUsage> usage, Map<String, String> attributes, Date expiration, KeyStore keyStore, String alias, char[] keyPassword) Create a self-signed certificate TLSIdentity.static TLSIdentitygetIdentity(KeyStore keyStore, String alias, char[] keyPassword) Get a TLSIdentity using a KeyStore, and a key alias, and key password for a key it contains.Methods inherited from class com.couchbase.lite.internal.BaseTLSIdentity
close, getAlias, getCert, getCerts, getExpiration, getKeyPair
-
Method Details
-
getIdentity
@Nullable public static TLSIdentity getIdentity(@NonNull KeyStore keyStore, @NonNull String alias, @Nullable char[] keyPassword) throws CouchbaseLiteException Get a TLSIdentity using a KeyStore, and a key alias, and key password for a key it contains. The KeyStore must contain the both the private key and the certificate chain at the given key alias and password, otherwise null will be returned.- Parameters:
keyStore- KeyStorealias- key aliaskeyPassword- key password if available- Returns:
- A TLSIdentity object.
- Throws:
CouchbaseLiteException- on error
-
createIdentity
@Deprecated @NonNull public static TLSIdentity createIdentity(boolean isServer, @NonNull Map<String, String> attributes, @Nullable Date expiration, @NonNull KeyStore keyStore, @NonNull String alias, @Nullable char[] keyPassword) throws CouchbaseLiteExceptionDeprecated.Create self-signed certificate and private key, store them in the canonical keystore, and return an identity backed by the new entry. The identity will be stored in the secure storage using the specified alias and can be recovered using that alias, after this method returns.- Parameters:
isServer- true if this is a server certificateattributes- certificate attributesexpiration- expiration datealias- alias used to identify the key/certificate entry, in the keystore- Returns:
- the new identity
- Throws:
CouchbaseLiteException- on failure to get identity
-
createIdentity
@NonNull public static TLSIdentity createIdentity(@NonNull Set<KeyUsage> usage, @NonNull Map<String, String> attributes, @Nullable Date expiration, @NonNull KeyStore keyStore, @NonNull String alias, @Nullable char[] keyPassword) throws CouchbaseLiteExceptionCreate a self-signed certificate TLSIdentity. The generated private key will be stored in the KeyStore along with its self-signed certificate.- Parameters:
usage- certificate usage: server or clientattributes- The certificate attributes.expiration- The certificate expiration date.keyStore- The KeyStore object for storing the generated private key and certificate.alias- The key alias for storing the generated private key and certificate.keyPassword- The password to protect the private key entry in the KeyStore.- Returns:
- A TLSIdentity object.
- Throws:
CouchbaseLiteException- on failure
-
createIdentity(Set, Map, Date, KeyStore, String, char[])instead.