src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java

Print this page

        

@@ -21,26 +21,29 @@
  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  * CA 95054 USA or visit www.sun.com if you need additional information or
  * have any questions.
  */
 
-package sun.net.www.protocol.http;
+package sun.net.www.protocol.http.ntlm;
 
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.PasswordAuthentication;
 import java.net.UnknownHostException;
 import java.net.URL;
 import sun.net.www.HeaderParser;
+import sun.net.www.protocol.http.AuthenticationInfo;
+import sun.net.www.protocol.http.AuthScheme;
+import sun.net.www.protocol.http.HttpURLConnection;
 
 /**
  * NTLMAuthentication:
  *
  * @author Michael McMahon
  */
 
-class NTLMAuthentication extends AuthenticationInfo {
+public class NTLMAuthentication extends AuthenticationInfo {
 
     private static final long serialVersionUID = 100L;
 
     private String hostname;
     private static String defaultDomain; /* Domain to use if not specified by user */

@@ -125,36 +128,27 @@
     }
 
     /**
      * @return true if this authentication supports preemptive authorization
      */
-    boolean supportsPreemptiveAuthorization() {
+    @Override
+    public boolean supportsPreemptiveAuthorization() {
         return false;
     }
 
     /**
      * @return true if NTLM supported transparently (no password needed, SSO)
      */
-    static boolean supportsTransparentAuth() {
+    public static boolean supportsTransparentAuth() {
         return true;
     }
 
     /**
-     * @return the name of the HTTP header this authentication wants set
-     */
-    String getHeaderName() {
-        if (type == SERVER_AUTHENTICATION) {
-            return "Authorization";
-        } else {
-            return "Proxy-authorization";
-        }
-    }
-
-    /**
      * Not supported. Must use the setHeaders() method
      */
-    String getHeaderValue(URL url, String method) {
+    @Override
+    public String getHeaderValue(URL url, String method) {
         throw new RuntimeException ("getHeaderValue not supported");
     }
 
     /**
      * Check if the header indicates that the current auth. parameters are stale.

@@ -162,11 +156,12 @@
      * and return true. Otherwise return false.
      * returning true means the request can be retried with the same userid/password
      * returning false means we have to go back to the user to ask for a new
      * username password.
      */
-    boolean isAuthorizationStale (String header) {
+    @Override
+    public boolean isAuthorizationStale (String header) {
         return false; /* should not be called for ntlm */
     }
 
     /**
      * Set header(s) on the given connection.

@@ -174,17 +169,18 @@
      * @param p A source of header values for this connection, not used because
      *          HeaderParser converts the fields to lower case, use raw instead
      * @param raw The raw header field.
      * @return true if all goes well, false if no headers were set.
      */
-    synchronized boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw) {
+    @Override
+    public synchronized boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw) {
 
         try {
-            NTLMAuthSequence seq = (NTLMAuthSequence)conn.authObj;
+            NTLMAuthSequence seq = (NTLMAuthSequence)conn.authObj();
             if (seq == null) {
                 seq = new NTLMAuthSequence (username, password, ntdomain);
-                conn.authObj = seq;
+                conn.authObj(seq);
             }
             String response = "NTLM " + seq.getAuthHeader (raw.length()>6?raw.substring(5):null);
             conn.setAuthenticationProperty(getHeaderName(), response);
             return true;
         } catch (IOException e) {