Class TLSIdentity


  • 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. Please note that the private key data will be not extracted out of the KeyStore. The TLSIdentity is used by URLEndpointListener to setup the TLS communication or by the Replicator to setup 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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static TLSIdentity createIdentity​(boolean isServer, java.util.Map<java.lang.String,​java.lang.String> attributes, java.util.Date expiration, java.security.KeyStore keyStore, java.lang.String alias, char[] keyPassword)
      Create a self-signed certificate TLSIdentity object.
      static TLSIdentity getIdentity​(java.security.KeyStore keyStore, java.lang.String alias, char[] keyPassword)
      Get a TLSIdentity object from the give KeyStore, key alias, and key password.
      • Methods inherited from class com.couchbase.lite.internal.BaseTLSIdentity

        getAlias, getCert, getCerts, getExpiration, getKeyPair
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getIdentity

        @Nullable
        public static TLSIdentity getIdentity​(@NonNull
                                              java.security.KeyStore keyStore,
                                              @NonNull
                                              java.lang.String alias,
                                              @Nullable
                                              char[] keyPassword)
                                       throws CouchbaseLiteException
        Get a TLSIdentity object from the give KeyStore, key alias, and key password. The KeyStore must contain the private key along with the certificate chain at the given key alias and password, otherwise null will be returned.
        Parameters:
        keyStore - KeyStore
        alias - key alias
        keyPassword - key password if available
        Returns:
        A TLSIdentity object.
        Throws:
        CouchbaseLiteException - on error
      • createIdentity

        @NonNull
        public static TLSIdentity createIdentity​(boolean isServer,
                                                 @NonNull
                                                 java.util.Map<java.lang.String,​java.lang.String> attributes,
                                                 @Nullable
                                                 java.util.Date expiration,
                                                 @NonNull
                                                 java.security.KeyStore keyStore,
                                                 @NonNull
                                                 java.lang.String alias,
                                                 @Nullable
                                                 char[] keyPassword)
                                          throws CouchbaseLiteException
        Create a self-signed certificate TLSIdentity object. The generated private key will be stored in the KeyStore along with its self-signed certificate.
        Parameters:
        isServer - The flag indicating that the certificate is for server or client.
        attributes - 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