2
안녕하세요, URL 연결을 으로 만들고 데이터를 가져 오는 다음과 같은 것을 가지고 있습니다. 문제는 입니다. 인증을 먼저 요구하는 페이지를 클릭하면 로그인 페이지가 표시됩니다. URLConnection에 사용자 이름과 비밀번호를 전달하는 방법이 확실하지 않습니다. JAAS 인증을 사용하는 사이트를 방문하고 있습니다.JAAS 보안에서 사용자 이름과 암호를 전달할 수있는 URLConnection을 생성하십시오.
import java.net.URL;
import java.net.URLConnection;
.....
URL location = new URL("www.sampleURL.com");
URLConnection yc = location.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
data += inputLine + "\n";
in.close();
나는 이런 식으로 뭔가를 시도했지만 작동하지 않았다가 ...
대신 "프록시 인증"의URL url = new URL("www.myURL.com");
URLConnection connection = url.openConnection();
String login = "username:password";
String encodedLogin = new BASE64Encoder().encodeBuffer(login.getBytes());
connection.setRequestProperty("Proxy-Authorization", "Basic " + encodedLogin);
100 %. 고마워요! – Moisei