DESCRIPTION

JCBC-901: Introduce Authenticator for implicit credentials

Motivation:
-----------
RFC 007 (couchbaselabs/sdk-rfcs#13) introduces the Authenticator
interface to deal with credentials that are not provided explicitly on
each authenticated method call but centralized in one place.

Modifications:
--------------
Added the Authenticator interface and its first implementation based on
login/password pairs, PasswordAuthenticator.

Internally, Authenticator deals with Credential objects. The contexts in
which Authenticator can provide credential are enumerated in the
CredentialContext enum.

The Authenticator is set on the Cluster only. Buckets (and N1QL/FTS
queries initiated from Buckets) still have a strong dependency to a
single password through the SASL dance and the way connections are
established. However it is possible to manually set credentials for
multiple buckets on a N1qlQuery.

Generally the authenticator should be prepared and set before opening
buckets, once. However, it can be changed later on via  the
`Cluster#authenticate` method. If a reference is kept to it, it can
also be mutated.

The following Cluster methods make use of the Authenticator when no
explicit credential is provided: clusterManager() and
openBucket(String bucketName). The later will also default to an empty
password if no credentials can be found in the Authenticator.

Results:
--------
Implicit credentials can be retrieved from a configurable Authenticator,
which paves the way for further authentication modes support and cluster
level authentication.

Joins on protected buckets now work, provided their credentials have
been set on the N1qlParams object.

Change-Id: Ia58107462cbeb8b3b2b86402a8e5e11c2ee92c3e


COMMENTS

author: Estrella Humphrey
date: 2016-08-25 15:18:07.628000000

Uploaded patch set 6: Patch Set 5 was rebased.

-------------------------------------
author: Estrella Humphrey
date: 2016-08-25 15:18:42.351000000

Patch Set 6: Verified+1

rebased on master.
note that some integration tests involving multiple bucket open/close still sometimes fail :(

-------------------------------------
author: Tate Garrett
date: 2016-08-25 15:48:29.883000000

Change has been successfully cherry-picked as fc3a487e693d5e6f218e2399f4d836d02670e8be by Estrella Humphrey

-------------------------------------
