Identify yourself using HTTP Authentification : Authenticator « Network Protocol « Java






Identify yourself using HTTP Authentification

 

import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

public class Main {
  public static void main(String[] argv) throws Exception {
    
    URLConnection conn = new URL("http://www.yourserver.com").openConnection();
    conn.setDoInput(true);
    conn.setRequestProperty("Authorization", "asdfasdf");
    conn.connect();

    InputStream in = conn.getInputStream();
  }
}

   
  








Related examples in the same category

1.String java.net.Authenticator.getRequestingPrompt()
2.Authenticator.setDefault(new Authenticator());
3.String java.net.Authenticator.getRequestingHost()
4.InetAddress java.net.Authenticator.getRequestingSite()
5.int java.net.Authenticator.getRequestingPort()
6.java.net.PasswordAuthentication.PasswordAuthentication(String userName, char[] password)