1
Windows 서버 2012에 인증서 서비스를 연결하려고합니다. 서버를 통한 기본 인증을 사용할 수 있으며 사용자 이름과 암호를 제공하는 브라우저에서 서비스에 액세스 할 수 있습니다. Java에서 HttpURLConnection
을 사용하여 연결을 여는 중입니다. 다음 코드를 사용하여 연결에 성공했습니다.Windows 서버 2012 기본 인증 실패 Java 사용
static class MyAuthenticator extends Authenticator {
public PasswordAuthentication getPasswordAuthentication() {
System.out.println("trying to authenticate");
return new PasswordAuthentication("user", "password".toCharArray());
}
}
Authenticator.setDefault(new MyAuthenticator())
는 그러나 나는 다음과 같은 코드를 사용하여 연결해야하고 그것은 나에게 401 오류를 제공합니다 :
String encoding = Base64.encode("user:password".getBytes());
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setDoOutput(true);
connection.setRequestProperty ("Authorization", "Basic " + encoding);
나는 401
감사를 받고있는 이유 어떤 생각,