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

Print this page

        

*** 21,46 **** * 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; 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; /** * NTLMAuthentication: * * @author Michael McMahon */ ! 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 */ --- 21,49 ---- * 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.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 */ ! 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,160 **** } /** * @return true if this authentication supports preemptive authorization */ ! boolean supportsPreemptiveAuthorization() { return false; } /** * @return true if NTLM supported transparently (no password needed, SSO) */ ! 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) { throw new RuntimeException ("getHeaderValue not supported"); } /** * Check if the header indicates that the current auth. parameters are stale. --- 128,154 ---- } /** * @return true if this authentication supports preemptive authorization */ ! @Override ! public boolean supportsPreemptiveAuthorization() { return false; } /** * @return true if NTLM supported transparently (no password needed, SSO) */ ! public static boolean supportsTransparentAuth() { return true; } /** * Not supported. Must use the setHeaders() 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,172 **** * 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) { return false; /* should not be called for ntlm */ } /** * Set header(s) on the given connection. --- 156,167 ---- * 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. */ ! @Override ! public boolean isAuthorizationStale (String header) { return false; /* should not be called for ntlm */ } /** * Set header(s) on the given connection.
*** 174,190 **** * @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) { try { ! NTLMAuthSequence seq = (NTLMAuthSequence)conn.authObj; if (seq == null) { seq = new NTLMAuthSequence (username, password, ntdomain); ! conn.authObj = seq; } String response = "NTLM " + seq.getAuthHeader (raw.length()>6?raw.substring(5):null); conn.setAuthenticationProperty(getHeaderName(), response); return true; } catch (IOException e) { --- 169,186 ---- * @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. */ ! @Override ! public synchronized boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw) { try { ! NTLMAuthSequence seq = (NTLMAuthSequence)conn.authObj(); if (seq == null) { seq = new NTLMAuthSequence (username, password, ntdomain); ! conn.authObj(seq); } String response = "NTLM " + seq.getAuthHeader (raw.length()>6?raw.substring(5):null); conn.setAuthenticationProperty(getHeaderName(), response); return true; } catch (IOException e) {