01: /*
02: * @(#)HttpAuthenticator.java 1.17 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: *
26: */
27:
28: package sun.net.www.protocol.http;
29:
30: import java.net.URL;
31:
32: /**
33: * An interface for all objects that implement HTTP authentication.
34: * See the HTTP spec for details on how this works in general.
35: * A single class or object can implement an arbitrary number of
36: * authentication schemes.
37: *
38: * @author David Brown
39: *
40: * @deprecated -- use java.net.Authenticator instead
41: * @see java.net.Authenticator
42: */
43: //
44: // NOTE: Unless compatibility with sun.* API's from 1.2 to 2.0 is
45: // a goal, there's no reason to carry this forward into JDK 2.0.
46: public interface HttpAuthenticator {
47:
48: /**
49: * Indicate whether the specified authentication scheme is
50: * supported. In accordance with HTTP specifications, the
51: * scheme name should be checked in a case-insensitive fashion.
52: */
53:
54: boolean schemeSupported(String scheme);
55:
56: /**
57: * Returns the String that should be included in the HTTP
58: * <B>Authorization</B> field. Return null if no info was
59: * supplied or could be found.
60: * <P>
61: * Example:
62: * --> GET http://www.authorization-required.com/ HTTP/1.0
63: * <-- HTTP/1.0 403 Unauthorized
64: * <-- WWW-Authenticate: Basic realm="WallyWorld"
65: * call schemeSupported("Basic"); (return true)
66: * call authString(u, "Basic", "WallyWorld", null);
67: * return "QWadhgWERghghWERfdfQ=="
68: * --> GET http://www.authorization-required.com/ HTTP/1.0
69: * --> Authorization: Basic QWadhgWERghghWERfdfQ==
70: * <-- HTTP/1.0 200 OK
71: * <B> YAY!!!</B>
72: */
73:
74: public String authString(URL u, String scheme, String realm);
75:
76: }
|