Mercurial Hosting > luan
annotate src/org/eclipse/jetty/server/Authentication.java @ 814:95cbe23a96fb
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 09 Sep 2016 10:37:37 -0600 |
parents | f8f7cb485c25 |
children |
rev | line source |
---|---|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
2 // ======================================================================== |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
4 // ------------------------------------------------------------------------ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
5 // All rights reserved. This program and the accompanying materials |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
6 // are made available under the terms of the Eclipse Public License v1.0 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
7 // and Apache License v2.0 which accompanies this distribution. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
8 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
9 // The Eclipse Public License is available at |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
10 // http://www.eclipse.org/legal/epl-v10.html |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
11 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
12 // The Apache License v2.0 is available at |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
13 // http://www.opensource.org/licenses/apache2.0.php |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
14 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
15 // You may elect to redistribute this code under either of these licenses. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
16 // ======================================================================== |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
17 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
18 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
19 package org.eclipse.jetty.server; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
20 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
21 import javax.servlet.ServletRequest; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
22 import javax.servlet.ServletResponse; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
23 import javax.servlet.http.HttpServletRequest; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
24 import javax.servlet.http.HttpServletResponse; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
25 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
26 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
27 /* ------------------------------------------------------------ */ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
28 /** The Authentication state of a request. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
29 * <p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
30 * The Authentication state can be one of several sub-types that |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
31 * reflects where the request is in the many different authentication |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
32 * cycles. Authentication might not yet be checked or it might be checked |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
33 * and failed, checked and deferred or succeeded. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
34 * |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
35 */ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
36 public interface Authentication |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
37 { |
813 | 38 /* ------------------------------------------------------------ */ |
39 /** A successful Authentication with User information. | |
40 */ | |
41 public interface User extends Authentication | |
42 { | |
43 String getAuthMethod(); | |
44 void logout(); | |
45 } | |
46 | |
47 /* ------------------------------------------------------------ */ | |
48 /** A wrapped authentication with methods provide the | |
49 * wrapped request/response for use by the application | |
50 */ | |
51 public interface Wrapped extends Authentication | |
52 { | |
53 HttpServletRequest getHttpServletRequest(); | |
54 HttpServletResponse getHttpServletResponse(); | |
55 } | |
56 | |
57 /* ------------------------------------------------------------ */ | |
58 /** A deferred authentication with methods to progress | |
59 * the authentication process. | |
60 */ | |
61 public interface Deferred extends Authentication | |
62 { | |
63 /* ------------------------------------------------------------ */ | |
64 /** Authenticate if possible without sending a challenge. | |
65 * This is used to check credentials that have been sent for | |
66 * non-manditory authentication. | |
67 * @return The new Authentication state. | |
68 */ | |
69 Authentication authenticate(ServletRequest request); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
70 |
813 | 71 /* ------------------------------------------------------------ */ |
72 /** Authenticate and possibly send a challenge. | |
73 * This is used to initiate authentication for previously | |
74 * non-manditory authentication. | |
75 * @return The new Authentication state. | |
76 */ | |
77 Authentication authenticate(ServletRequest request,ServletResponse response); | |
78 | |
79 | |
80 /* ------------------------------------------------------------ */ | |
81 /** Login with the LOGIN authenticator | |
82 * @param username | |
83 * @param password | |
84 * @return The new Authentication state | |
85 */ | |
86 Authentication login(String username,Object password,ServletRequest request); | |
87 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
88 |
813 | 89 |
90 /* ------------------------------------------------------------ */ | |
91 /** Authentication Response sent state. | |
92 * Responses are sent by authenticators either to issue an | |
93 * authentication challenge or on successful authentication in | |
94 * order to redirect the user to the original URL. | |
95 */ | |
96 public interface ResponseSent extends Authentication | |
97 { | |
98 } | |
99 | |
100 /* ------------------------------------------------------------ */ | |
101 /** An Authentication Challenge has been sent. | |
102 */ | |
103 public interface Challenge extends ResponseSent | |
104 { | |
105 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
106 |
813 | 107 /* ------------------------------------------------------------ */ |
108 /** An Authentication Failure has been sent. | |
109 */ | |
110 public interface Failure extends ResponseSent | |
111 { | |
112 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
113 |
813 | 114 public interface SendSuccess extends ResponseSent |
115 { | |
116 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
117 |
813 | 118 /* ------------------------------------------------------------ */ |
119 /** Unauthenticated state. | |
120 * <p> | |
121 * This convenience instance is for non mandatory authentication where credentials | |
122 * have been presented and checked, but failed authentication. | |
123 */ | |
124 public final static Authentication UNAUTHENTICATED = new Authentication(){@Override | |
125 public String toString(){return "UNAUTHENTICATED";}}; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
126 |
813 | 127 /* ------------------------------------------------------------ */ |
128 /** Authentication not checked | |
129 * <p> | |
130 * This convenience instance us for non mandatory authentication when no | |
131 * credentials are present to be checked. | |
132 */ | |
133 public final static Authentication NOT_CHECKED = new Authentication(){@Override | |
134 public String toString(){return "NOT CHECKED";}}; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
135 |
813 | 136 /* ------------------------------------------------------------ */ |
137 /** Authentication challenge sent. | |
138 * <p> | |
139 * This convenience instance is for when an authentication challenge has been sent. | |
140 */ | |
141 public final static Authentication SEND_CONTINUE = new Authentication.Challenge(){@Override | |
142 public String toString(){return "CHALLENGE";}}; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
143 |
813 | 144 /* ------------------------------------------------------------ */ |
145 /** Authentication failure sent. | |
146 * <p> | |
147 * This convenience instance is for when an authentication failure has been sent. | |
148 */ | |
149 public final static Authentication SEND_FAILURE = new Authentication.Failure(){@Override | |
150 public String toString(){return "FAILURE";}}; | |
151 public final static Authentication SEND_SUCCESS = new SendSuccess(){@Override | |
152 public String toString(){return "SEND_SUCCESS";}}; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
153 } |