Elasticsearch 6.0.0 Base64 not found

(ajit) #1

I am using elasticsearch 6.0.0. I want to encode username and password using Base64. But there is no Base64 class present in jar. Please reply.

client.threadPool().getThreadContext().putHeader("Authorization", "Basic "+encodeBase64("username:password"));

Above code I have to use in elasticsearch 6.0.0

(David Pilato) #2

You can probably use JDK standard classes like https://docs.oracle.com/javase/8/docs/api/java/util/Base64.Encoder.html#encodeToString-byte:A-

BTW why using a 6.0.0 instead of 6.1.3?

(ajit) #3

Transport client configuration is like below.

I am using searchguard 6. And from java side I have implemented below configuration.
Settings settings = Settings.builder()
.put("cluster.name", "searchguard_demo")
.put(SSLConfigConstants.SEARCHGUARD_SSL_TRANSPORT_PEMKEY_FILEPATH, "C:\Users\c-ajitb\Desktop\SearchguardFiles\esnode-key.pem")
.put(SSLConfigConstants.SEARCHGUARD_SSL_TRANSPORT_PEMTRUSTEDCAS_FILEPATH, "C:\Users\c-ajitb\Desktop\SearchguardFiles\root-ca.pem")
.put(SSLConfigConstants.SEARCHGUARD_SSL_HTTP_ENABLED, "true")
.put(SSLConfigConstants.SEARCHGUARD_SSL_HTTP_PEMCERT_FILEPATH, "C:\Users\c-ajitb\Desktop\SearchguardFiles\esnode.pem")
.put(SSLConfigConstants.SEARCHGUARD_SSL_HTTP_PEMKEY_FILEPATH, "C:\Users\c-ajitb\Desktop\SearchguardFiles\esnode-key.pem")
.put(SSLConfigConstants.SEARCHGUARD_SSL_HTTP_PEMTRUSTEDCAS_FILEPATH, "C:\Users\c-ajitb\Desktop\SearchguardFiles\root-ca.pem")

TransportClient transclient = new PreBuiltTransportClient(settings,SearchGuardSSLPlugin.class).addTransportAddress(new TransportAddress(InetAddress.getByName(""), 9300));
transclient.threadPool().getThreadContext().putHeader("Authorization", "Basic "+Base64.getEncoder().encodeToString("admin:admin".getBytes()));
GetResponse getResponse = transclient.prepareGet("testindex", "testtype", "1").get();

But I am getting below exception.
ElasticsearchSecurityException[No user found for indices:data/read/get]

I have given admin credentials.
Please reply and provide solution.


(David Pilato) #4

Please format your code using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:


Please edit your post.

This new question is not related to the first one and I think you already asked for this in another threads.

Please don't do this and keep the discussion where you opened it.
If you don't get answers about a non official and not supported plugin, that might be better to ask the authors directly on their website about this IMHO.

(ajit) #5

Ok Thanks

(system) closed #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.