通过Java为ActiveMQ / Jolokia / HawtIO提供的凭据

问题描述 投票:0回答:1

我知道5.9.0的HawtIO / Jolokia的默认密码是在\ conf \文件夹中设置的

管理员/管理员系统/经理等

但是,在尝试通过Java执行restful命令时,这些密码都不起作用:

CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope(null, -80), new UsernamePasswordCredentials("admin", "admin"));
CloseableHttpClient httpclient0 = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
URI uri0 = URI.create("http://localhost:8161/hawtio/auth/login/");
HttpGet httpget = new HttpGet(uri0);
HttpResponse r0 = httpclient0.execute(httpget);
System.out.println("Login form get: " + r0.getStatusLine());
for (Header h : r0.getAllHeaders())
  System.out.println(h.getName() + "/" + h.getValue());
HttpEntity entity = r0.getEntity();

InputStream is0 = entity.getContent();
String resp = IOUtils.toString(is0);
System.out.println("Response0: " + resp);

以下代码只是吐出403 Forbidden回复!我尝试了很多用户名和密码的组合。

Login form get: HTTP/1.1 403 Forbidden
Access-Control-Allow-Origin/*
Content-Length/0
Server/Jetty(7.6.9.v20130131)

什么在这里有用?

我记得在运行5.8.0时“admin / admin”有效,但我想用5.9.0代替。仅仅因为用户名和密码改变而退出此版本将是蹩脚的。

此外,哪个\ conf文件决定了这个密码......?

java apache activemq hawtio jolokia
1个回答
5
投票

你几乎得到它,你只需要POST到该URL而不是做GET。您只需在Authorization标头中设置您的用户名/密码即可。 hawtio中的身份验证过滤器避免发送回401,因为这会导致浏览器身份验证提示出现,因此您不会看到401返回。

© www.soinside.com 2019 - 2024. All rights reserved.