我试图将应用程序远程部署到Tomcat。为此,我需要执行以下GET请求:
http://localhost:8080/manager/text/deploy?path=/client-001&war=file:C:/.DS/tmp/client-001.war
我是从我的Java代码中完成的:
String url = "http://localhost:8080/manager/text/deploy?path=/client-001&war=file:C:/.DS/tmp/client-001.war";
HttpClient client = HttpClientBuilder.create().build();
HttpGet request;
try {
request = new HttpGet(url);
request.addHeader(BasicScheme.authenticate(
new UsernamePasswordCredentials("test", "test"),
"UTF-8", false));
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader(
new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
System.err.println(result.toString());
} catch (Exception e){
e.printStackTrace();
}
但是我得到了403,尽管我已经通过了我的证书。
我做错了什么?
答案 0 :(得分:0)
所以我发现了问题所在。
1)我不需要将凭据传递给标头,我只需要将网址从localhost:8080
更改为test:test@localhost:8080
2)我的用户test
有角色manager-gui
,要让GET工作,需要角色manager-script