0
私は2つのクラスがあります。ログインWebサイトにhttp投稿要求を送信しますか? (認証)
public class ProtectedAuthorizer extends Authenticator {
public String authorizeProtectedUrl(String requestingUrl) {
Authenticator.setDefault(new CustomAuthenticator());
StringBuffer sb = null;
try {
URL url = new URL(requestingUrl);
BufferedReader br = new BufferedReader(new InputStreamReader(
url.openStream()));
String in = "";
sb = new StringBuffer();
while ((in = br.readLine()) != null) {
sb.append(in + "\n");
}
br.close();
} catch (Exception e) {
e.printStackTrace();
}
return sb.toString();
}
}
を、これは私の第二のクラスです:
protected PasswordAuthentication getPasswordAuthentication() {
String username = "username";
String password = "password";
String promptString = getRequestingPrompt();
String hostname = getRequestingHost();
InetAddress ipaddr = getRequestingSite();
int port = getRequestingPort();
System.out.println(promptString);
System.out.println(hostname);
System.out.println(ipaddr);
System.out.println(port);
return new PasswordAuthentication(username, password.toCharArray());
}
}
私はこのウェブサイトに自分自身を承認しようとしている:私は
を呼び出すたび https://id.ogplanet.com/login.og が、authorizeProtectedUrl("https://id.ogplanet.com/login.og");
何もしません。これらの2つのクラスを使用してログインページに自分自身を認証するにはどうすればよいですか? (ログインページにHTTP投稿要求を送信する)。
ここでgetPasswordAuthentication()を呼び出していますか? – sachinrahulsourav
私は自分自身を認可したいと思っているのですか? – ZimZim