Java Smart Client HTTP Basic Authentication - Not Possible?
I'm using the Membase Java Smart Client, which I believe accesses the REST API on port 8080 to provide memcached cluster access.
I want to turn on HTTP Basic Authentication for my Admin Console, however when doing so I get errors connecting the Smart Client. It seems that setting Authentication for the Admin Console also sets it for the REST API. However, I cannot find a way to get the Smart Client to use HTTP Basic authentication.
Setting the username and userpassword on the ClientManager doesn't work. It appears that those credentials relate to the bucket access not the REST API access.
Am I missing something, or is simply not possible to do this in the current version?
Thanks for the reply.
I have no trouble connecting to a specific bucket using the ClientManager constructor. Both the simple and bucket specific constructors work so long as the Admin Console does not have any security set. So yes the smart client uses HTTP Basic Auth for bucket access (where the username and password is same as the bucket name), that's fine.
My problem is that when a security username and password is set on the Admin Console and restart my client app Java smart client access stops working. It cannot access [url]http://localhost:8080/pools/default[/url] (regardless of the ClientManager constructor used).
The admin security is set at the url:
[url]http://localhost:8080/index.html#sec=settings[/url]
The constructor code is:
ArrayList baseList = new ArrayList();
URI base = new URI("http://localhost:8080/pools/default");
baseList.add(base);
ClientManager manager = new ClientManager(baseList, "bucket1", "bucket1");
MemcachedClient client = manager.getClient();
The error message is:
java.io.IOException: No valid base URIs have been provided.
at com.northscale.store.ClientManager.tryReadBase(ClientManager.java:624) [northscale_client-1.0.2.jar:na]
at com.northscale.store.ClientManager.getBucketMembers(ClientManager.java:266) [northscale_client-1.0.2.jar:na]
at com.northscale.store.ClientManager.getClient(ClientManager.java:458) [northscale_client-1.0.2.jar:na]
Yes, the Java smart client does use HTTP Basic Auth. If you use the appropriate constructor for the bucket you're accessing, it will automatically do HTTP Basic Auth against the cluster. The only situation where it won't is if you're using the "default" bucket, which is available without authentication.
What kind of constructor are you using with the ClientManager? What kind of errors are you getting?