title: Sending an http post request to a login website? (Authorization)
body: <p>I have two classes: </p>
  
  <pre><code>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();
  }
  }
  </code></pre>
  
  <p>And this is my second class: </p>
  
  <pre><code>    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());
  }
  
  }
  </code></pre>
  
  <p>I'm trying to authorize myself to this website: <a href="https://id.ogplanet.com/login.og" rel="nofollow">https://id.ogplanet.com/login.og</a>
  but whenever I call </p>
  
  <pre><code>authorizeProtectedUrl("https://id.ogplanet.com/login.og"); 
  </code></pre>
  
  <p>it doesn't do anything. How do I use these 2 classes to authorize myself to a login page? (Send an HTTP Post Request to the login page). </p>