MB-5307 Properly validate usernames and passwords.

Change-Id: Id46f42f20cde19a1733fece9de27d16316302013
Reviewed-on: http://review.couchbase.org/24998
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>