src/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java

Print this page

        

*** 23,43 **** * have any questions. */ package sun.net.www.protocol.http; import java.util.HashMap; - import sun.net.www.HeaderParser; import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; - import sun.util.logging.PlatformLogger; - - import java.net.URL; - import java.io.IOException; - import java.net.Authenticator.RequestorType; - import java.lang.reflect.Constructor; import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE; import static sun.net.www.protocol.http.AuthScheme.KERBEROS; /** * NegotiateAuthentication: --- 23,39 ---- * have any questions. */ package sun.net.www.protocol.http; + import java.net.URL; + import java.io.IOException; + import java.net.Authenticator.RequestorType; import java.util.HashMap; import sun.net.www.HeaderParser; import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE; import static sun.net.www.protocol.http.AuthScheme.KERBEROS; /** * NegotiateAuthentication:
*** 76,86 **** } /** * @return true if this authentication supports preemptive authorization */ ! boolean supportsPreemptiveAuthorization() { return false; } /** * Find out if the HttpCallerInfo supports Negotiate protocol. In order to --- 72,83 ---- } /** * @return true if this authentication supports preemptive authorization */ ! @Override ! public boolean supportsPreemptiveAuthorization() { return false; } /** * Find out if the HttpCallerInfo supports Negotiate protocol. In order to
*** 116,139 **** return false; } } /** - * @return the name of the HTTP header this authentication wants to 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. --- 113,126 ---- return false; } } /** * 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.
*** 141,151 **** * 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 Negotiate */ } /** * Set header(s) on the given connection. --- 128,139 ---- * 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 Negotiate */ } /** * Set header(s) on the given connection.
*** 153,163 **** * @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 { String response; byte[] incoming = null; String[] parts = raw.split("\\s+"); --- 141,152 ---- * @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 { String response; byte[] incoming = null; String[] parts = raw.split("\\s+");
*** 225,282 **** // if the server can be trusted. This is not the same concept as Digest's // Authentication-Info header. // // Currently we ignore this header. - } - - /** - * This abstract class is a bridge to connect NegotiteAuthentication and - * NegotiatorImpl, so that JAAS and JGSS calls can be made - */ - abstract class Negotiator { - static Negotiator getSupported(HttpCallerInfo hci) - throws Exception { - - // These lines are equivalent to - // return new NegotiatorImpl(hci); - // The current implementation will make sure NegotiatorImpl is not - // directly referenced when compiling, thus smooth the way of building - // the J2SE platform where HttpURLConnection is a bootstrap class. - // - // Makes NegotiatorImpl, and the security classes it references, a - // runtime dependency rather than a static one. - - Class clazz; - Constructor c; - try { - clazz = Class.forName("sun.net.www.protocol.http.NegotiatorImpl", true, null); - c = clazz.getConstructor(HttpCallerInfo.class); - } catch (ClassNotFoundException cnfe) { - finest(cnfe); - throw cnfe; - } catch (ReflectiveOperationException roe) { - // if the class is there then something seriously wrong if - // the constructor is not. - throw new AssertionError(roe); - } - - try { - return (Negotiator) (c.newInstance(hci)); - } catch (ReflectiveOperationException roe) { - finest(roe); - Throwable t = roe.getCause(); - if (t != null && t instanceof Exception) - finest((Exception)t); - throw roe; - } - } - - abstract byte[] firstToken() throws IOException; - - abstract byte[] nextToken(byte[] in) throws IOException; - - static void finest(Exception e) { - PlatformLogger logger = HttpURLConnection.getHttpLogger(); - logger.finest("NegotiateAuthentication: " + e); - } } --- 214,219 ----