@@ -20,7 +20,7 @@ import com.couchbase.client.core.annotation.Stability
2020import com .couchbase .client .core .annotation .Stability .Uncommitted
2121import com .couchbase .client .core .api .CoreCouchbaseOps
2222import com .couchbase .client .core .diagnostics ._
23- import com .couchbase .client .core .env .Authenticator
23+ import com .couchbase .client .core .env .{ Authenticator , DelegatingAuthenticator }
2424import com .couchbase .client .core .protostellar .CoreProtostellarUtil
2525import com .couchbase .client .core .service .ServiceType
2626import com .couchbase .client .core .transaction .CoreTransactionsReactive
@@ -67,12 +67,14 @@ import scala.util.{Failure, Success, Try}
6767 */
6868trait AsyncClusterBase { this : AsyncCluster =>
6969 private [scala] implicit lazy val ec : ExecutionContext = environment.ec
70+ private [scala] val delegatingAuthenticator =
71+ DelegatingAuthenticator .create(environment.coreEnv.securityConfig().tlsEnabled(), authenticator)
7072
7173 /** The environment used to create this cluster */
7274 val env : ClusterEnvironment = environment
7375
7476 private [scala] val couchbaseOps =
75- CoreCouchbaseOps .create(environment.coreEnv, authenticator , connectionString)
77+ CoreCouchbaseOps .create(environment.coreEnv, delegatingAuthenticator , connectionString)
7678
7779 // Only used by tests now
7880 private [couchbase] def core : Core = couchbaseOps match {
@@ -106,6 +108,16 @@ trait AsyncClusterBase { this: AsyncCluster =>
106108 new AsyncBucket (bucketName, couchbaseOps, environment)
107109 }
108110
111+ /** Sets a new authenticator, that will be used for any future connections created to Couchbase services.
112+ *
113+ * Note that existing connections will not be terminated.
114+ *
115+ * This method is thread-safe.
116+ */
117+ def authenticator (authenticator : Authenticator ): Try [Unit ] = {
118+ Try (delegatingAuthenticator.setDelegate(authenticator))
119+ }
120+
109121 private [scala] def performGlobalConnect (): Unit = {
110122 couchbaseOps match {
111123 case core : Core => core.initGlobalConfig()
0 commit comments