KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > authenticator > SavedRequest


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18
19 package org.apache.catalina.authenticator;
20
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.HashMap JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import java.util.Locale JavaDoc;
26
27 import javax.servlet.http.Cookie JavaDoc;
28
29 import org.apache.tomcat.util.buf.ByteChunk;
30
31
32 /**
33  * Object that saves the critical information from a request so that
34  * form-based authentication can reproduce it once the user has been
35  * authenticated.
36  * <p>
37  * <b>IMPLEMENTATION NOTE</b> - It is assumed that this object is accessed
38  * only from the context of a single thread, so no synchronization around
39  * internal collection classes is performed.
40  *
41  * @author Craig R. McClanahan
42  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
43  */

44
45 public final class SavedRequest {
46
47
48     /**
49      * The set of Cookies associated with this Request.
50      */

51     private ArrayList JavaDoc cookies = new ArrayList JavaDoc();
52
53     public void addCookie(Cookie JavaDoc cookie) {
54         cookies.add(cookie);
55     }
56
57     public Iterator JavaDoc getCookies() {
58         return (cookies.iterator());
59     }
60
61
62     /**
63      * The set of Headers associated with this Request. Each key is a header
64      * name, while the value is a ArrayList containing one or more actual
65      * values for this header. The values are returned as an Iterator when
66      * you ask for them.
67      */

68     private HashMap JavaDoc headers = new HashMap JavaDoc();
69
70     public void addHeader(String JavaDoc name, String JavaDoc value) {
71         ArrayList JavaDoc values = (ArrayList JavaDoc) headers.get(name);
72         if (values == null) {
73             values = new ArrayList JavaDoc();
74             headers.put(name, values);
75         }
76         values.add(value);
77     }
78
79     public Iterator JavaDoc getHeaderNames() {
80         return (headers.keySet().iterator());
81     }
82
83     public Iterator JavaDoc getHeaderValues(String JavaDoc name) {
84         ArrayList JavaDoc values = (ArrayList JavaDoc) headers.get(name);
85         if (values == null)
86             return ((new ArrayList JavaDoc()).iterator());
87         else
88             return (values.iterator());
89     }
90
91
92     /**
93      * The set of Locales associated with this Request.
94      */

95     private ArrayList JavaDoc locales = new ArrayList JavaDoc();
96
97     public void addLocale(Locale JavaDoc locale) {
98         locales.add(locale);
99     }
100
101     public Iterator JavaDoc getLocales() {
102         return (locales.iterator());
103     }
104
105
106     /**
107      * The request method used on this Request.
108      */

109     private String JavaDoc method = null;
110
111     public String JavaDoc getMethod() {
112         return (this.method);
113     }
114
115     public void setMethod(String JavaDoc method) {
116         this.method = method;
117     }
118
119
120
121     /**
122      * The set of request parameters associated with this Request. Each
123      * entry is keyed by the parameter name, pointing at a String array of
124      * the corresponding values.
125      */

126     private HashMap JavaDoc parameters = new HashMap JavaDoc();
127
128     public void addParameter(String JavaDoc name, String JavaDoc values[]) {
129         parameters.put(name, values);
130     }
131
132     public Iterator JavaDoc getParameterNames() {
133         return (parameters.keySet().iterator());
134     }
135
136     public String JavaDoc[] getParameterValues(String JavaDoc name) {
137         return ((String JavaDoc[]) parameters.get(name));
138     }
139
140
141     /**
142      * The query string associated with this Request.
143      */

144     private String JavaDoc queryString = null;
145
146     public String JavaDoc getQueryString() {
147         return (this.queryString);
148     }
149
150     public void setQueryString(String JavaDoc queryString) {
151         this.queryString = queryString;
152     }
153
154
155     /**
156      * The request URI associated with this Request.
157      */

158     private String JavaDoc requestURI = null;
159
160     public String JavaDoc getRequestURI() {
161         return (this.requestURI);
162     }
163
164     public void setRequestURI(String JavaDoc requestURI) {
165         this.requestURI = requestURI;
166     }
167
168     
169     /**
170      * The body of this request.
171      */

172     private ByteChunk body = null;
173     
174     public ByteChunk getBody() {
175         return (this.body);
176     }
177
178     public void setBody(ByteChunk body) {
179         this.body = body;
180     }
181 }
182
Popular Tags