1 |
|
/*
|
|
1 |
|
/*
|
2 |
|
* License
d to the A
pache Soft
ware Found
ation (ASF
) under on
e or more
|
|
2 |
|
* License
d to the A
pache Soft
ware Found
ation (ASF
) under on
e or more
|
3 |
|
* contrib
utor licen
se agreeme
nts. See
the NOTICE
file dist
ributed wi
th
|
|
3 |
|
* contrib
utor licen
se agreeme
nts. See
the NOTICE
file dist
ributed wi
th
|
4 |
|
* this wo
rk for add
itional in
formation
regarding
copyright
ownership.
|
|
4 |
|
* this wo
rk for add
itional in
formation
regarding
copyright
ownership.
|
5 |
|
* The ASF
licenses
this file
to You und
er the Apa
che Licens
e, Version
2.0
|
|
5 |
|
* The ASF
licenses
this file
to You und
er the Apa
che Licens
e, Version
2.0
|
6 |
|
* (the "L
icense");
you may no
t use this
file exce
pt in comp
liance wit
h
|
|
6 |
|
* (the "L
icense");
you may no
t use this
file exce
pt in comp
liance wit
h
|
7 |
|
* the Lic
ense. You
may obtai
n a copy o
f the Lice
nse at
|
|
7 |
|
* the Lic
ense. You
may obtai
n a copy o
f the Lice
nse at
|
8 |
|
*
|
|
8 |
|
*
|
9 |
|
* ht
tp://www.a
pache.org/
licenses/L
ICENSE-2.0
|
|
9 |
|
* ht
tp://www.a
pache.org/
licenses/L
ICENSE-2.0
|
10 |
|
*
|
|
10 |
|
*
|
11 |
|
* Unless
required b
y applicab
le law or
agreed to
in writing
, software
|
|
11 |
|
* Unless
required b
y applicab
le law or
agreed to
in writing
, software
|
12 |
|
* distrib
uted under
the Licen
se is dist
ributed on
an "AS IS
" BASIS,
|
|
12 |
|
* distrib
uted under
the Licen
se is dist
ributed on
an "AS IS
" BASIS,
|
13 |
|
* WITHOUT
WARRANTIE
S OR CONDI
TIONS OF A
NY KIND, e
ither expr
ess or imp
lied.
|
|
13 |
|
* WITHOUT
WARRANTIE
S OR CONDI
TIONS OF A
NY KIND, e
ither expr
ess or imp
lied.
|
14 |
|
* See the
License f
or the spe
cific lang
uage gover
ning permi
ssions and
|
|
14 |
|
* See the
License f
or the spe
cific lang
uage gover
ning permi
ssions and
|
15 |
|
* limitat
ions under
the Licen
se.
|
|
15 |
|
* limitat
ions under
the Licen
se.
|
16 |
|
*/
|
|
16 |
|
*/
|
17 |
|
|
|
17 |
|
|
18 |
|
|
|
18 |
|
|
19 |
|
package or
g.apache.c
atalina.au
thenticato
r;
|
|
19 |
|
package or
g.apache.c
atalina.au
thenticato
r;
|
20 |
|
|
|
20 |
|
|
21 |
|
|
|
21 |
|
|
22 |
|
import jav
a.util.Arr
ayList;
|
|
22 |
|
import jav
a.util.Arr
ayList;
|
23 |
|
import jav
a.util.Has
hMap;
|
|
23 |
|
import jav
a.util.Has
hMap;
|
24 |
|
import jav
a.util.Ite
rator;
|
|
24 |
|
import jav
a.util.Ite
rator;
|
25 |
|
import jav
a.util.Loc
ale;
|
|
25 |
|
import jav
a.util.Loc
ale;
|
26 |
|
|
|
26 |
|
|
27 |
|
import jav
ax.servlet
.http.Cook
ie;
|
|
27 |
|
import jav
ax.servlet
.http.Cook
ie;
|
28 |
|
|
|
28 |
|
|
29 |
|
import org
.apache.to
mcat.util.
buf.ByteCh
unk;
|
|
29 |
|
import org
.apache.to
mcat.util.
buf.ByteCh
unk;
|
30 |
|
|
|
30 |
|
|
31 |
|
|
|
31 |
|
|
32 |
|
/**
|
|
32 |
|
/**
|
33 |
|
* Object
that saves
the criti
cal inform
ation from
a request
so that
|
|
33 |
|
* Object
that saves
the criti
cal inform
ation from
a request
so that
|
34 |
|
* form-ba
sed authen
tication c
an reprodu
ce it once
the user
has been
|
|
34 |
|
* form-ba
sed authen
tication c
an reprodu
ce it once
the user
has been
|
35 |
|
* authent
icated.
|
|
35 |
|
* authent
icated.
|
36 |
|
* <p>
|
|
36 |
|
* <p>
|
37 |
|
* <b>IMPL
EMENTATION
NOTE</b>
- It is as
sumed that
this obje
ct is acce
ssed
|
|
37 |
|
* <b>IMPL
EMENTATION
NOTE</b>
- It is as
sumed that
this obje
ct is acce
ssed
|
38 |
|
* only fr
om the con
text of a
single thr
ead, so no
synchroni
zation aro
und
|
|
38 |
|
* only fr
om the con
text of a
single thr
ead, so no
synchroni
zation aro
und
|
39 |
|
* interna
l collecti
on classes
is perfor
med.
|
|
39 |
|
* interna
l collecti
on classes
is perfor
med.
|
40 |
|
*
|
|
40 |
|
*
|
41 |
|
* @author
Craig R.
McClanahan
|
|
41 |
|
* @author
Craig R.
McClanahan
|
42 |
|
*/
|
|
42 |
|
*/
|
43 |
|
public fin
al class S
avedReques
t {
|
|
43 |
|
public fin
al class S
avedReques
t {
|
44 |
|
|
|
44 |
|
|
45 |
|
|
|
45 |
|
|
46 |
|
/**
|
|
46 |
|
/**
|
47 |
|
* The
set of Co
okies asso
ciated wit
h this Req
uest.
|
|
47 |
|
* The
set of Co
okies asso
ciated wit
h this Req
uest.
|
48 |
|
*/
|
|
48 |
|
*/
|
49 |
|
privat
e final Ar
rayList<Co
okie> cook
ies = new
ArrayList<
>();
|
|
49 |
|
privat
e final Ar
rayList<Co
okie> cook
ies = new
ArrayList<
>();
|
50 |
|
|
|
50 |
|
|
51 |
|
public
void addC
ookie(Cook
ie cookie)
{
|
|
51 |
|
public
void addC
ookie(Cook
ie cookie)
{
|
52 |
|
co
okies.add(
cookie);
|
|
52 |
|
co
okies.add(
cookie);
|
53 |
|
}
|
|
53 |
|
}
|
54 |
|
|
|
54 |
|
|
55 |
|
public
Iterator<
Cookie> ge
tCookies()
{
|
|
55 |
|
public
Iterator<
Cookie> ge
tCookies()
{
|
56 |
|
re
turn (cook
ies.iterat
or());
|
|
56 |
|
re
turn (cook
ies.iterat
or());
|
57 |
|
}
|
|
57 |
|
}
|
58 |
|
|
|
58 |
|
|
59 |
|
|
|
59 |
|
|
60 |
|
/**
|
|
60 |
|
/**
|
61 |
|
* The
set of He
aders asso
ciated wit
h this Req
uest. Eac
h key is a
header
|
|
61 |
|
* The
set of He
aders asso
ciated wit
h this Req
uest. Eac
h key is a
header
|
62 |
|
* nam
e, while t
he value i
s a ArrayL
ist contai
ning one o
r more act
ual
|
|
62 |
|
* nam
e, while t
he value i
s a ArrayL
ist contai
ning one o
r more act
ual
|
63 |
|
* val
ues for th
is header.
The valu
es are ret
urned as a
n Iterator
when
|
|
63 |
|
* val
ues for th
is header.
The valu
es are ret
urned as a
n Iterator
when
|
64 |
|
* you
ask for t
hem.
|
|
64 |
|
* you
ask for t
hem.
|
65 |
|
*/
|
|
65 |
|
*/
|
66 |
|
privat
e final Ha
shMap<Stri
ng,ArrayLi
st<String>
> headers
= new Hash
Map<>();
|
|
66 |
|
privat
e final Ha
shMap<Stri
ng,ArrayLi
st<String>
> headers
= new Hash
Map<>();
|
67 |
|
|
|
67 |
|
|
68 |
|
public
void addH
eader(Stri
ng name, S
tring valu
e) {
|
|
68 |
|
public
void addH
eader(Stri
ng name, S
tring valu
e) {
|
69 |
|
Ar
rayList<St
ring> valu
es = heade
rs.get(nam
e);
|
|
69 |
|
Ar
rayList<St
ring> valu
es = heade
rs.get(nam
e);
|
70 |
|
if
(values =
= null) {
|
|
70 |
|
if
(values =
= null) {
|
71 |
|
values =
new Array
List<>();
|
|
71 |
|
values =
new Array
List<>();
|
72 |
|
headers.
put(name,
values);
|
|
72 |
|
headers.
put(name,
values);
|
73 |
|
}
|
|
73 |
|
}
|
74 |
|
va
lues.add(v
alue);
|
|
74 |
|
va
lues.add(v
alue);
|
75 |
|
}
|
|
75 |
|
}
|
76 |
|
|
|
76 |
|
|
77 |
|
public
Iterator<
String> ge
tHeaderNam
es() {
|
|
77 |
|
public
Iterator<
String> ge
tHeaderNam
es() {
|
78 |
|
re
turn (head
ers.keySet
().iterato
r());
|
|
78 |
|
re
turn (head
ers.keySet
().iterato
r());
|
79 |
|
}
|
|
79 |
|
}
|
80 |
|
|
|
80 |
|
|
81 |
|
public
Iterator<
String> ge
tHeaderVal
ues(String
name) {
|
|
81 |
|
public
Iterator<
String> ge
tHeaderVal
ues(String
name) {
|
82 |
|
Ar
rayList<St
ring> valu
es = heade
rs.get(nam
e);
|
|
82 |
|
Ar
rayList<St
ring> valu
es = heade
rs.get(nam
e);
|
83 |
|
if
(values =
= null)
|
|
83 |
|
if
(values =
= null)
|
84 |
|
return (
(new Array
List<Strin
g>()).iter
ator());
|
|
84 |
|
return (
(new Array
List<Strin
g>()).iter
ator());
|
85 |
|
el
se
|
|
85 |
|
el
se
|
86 |
|
return (
values.ite
rator());
|
|
86 |
|
return (
values.ite
rator());
|
87 |
|
}
|
|
87 |
|
}
|
88 |
|
|
|
88 |
|
|
89 |
|
|
|
89 |
|
|
90 |
|
/**
|
|
90 |
|
/**
|
91 |
|
* The
set of Lo
cales asso
ciated wit
h this Req
uest.
|
|
91 |
|
* The
set of Lo
cales asso
ciated wit
h this Req
uest.
|
92 |
|
*/
|
|
92 |
|
*/
|
93 |
|
privat
e final Ar
rayList<Lo
cale> loca
les = new
ArrayList<
>();
|
|
93 |
|
privat
e final Ar
rayList<Lo
cale> loca
les = new
ArrayList<
>();
|
94 |
|
|
|
94 |
|
|
95 |
|
public
void addL
ocale(Loca
le locale)
{
|
|
95 |
|
public
void addL
ocale(Loca
le locale)
{
|
96 |
|
lo
cales.add(
locale);
|
|
96 |
|
lo
cales.add(
locale);
|
97 |
|
}
|
|
97 |
|
}
|
98 |
|
|
|
98 |
|
|
99 |
|
public
Iterator<
Locale> ge
tLocales()
{
|
|
99 |
|
public
Iterator<
Locale> ge
tLocales()
{
|
100 |
|
re
turn (loca
les.iterat
or());
|
|
100 |
|
re
turn (loca
les.iterat
or());
|
101 |
|
}
|
|
101 |
|
}
|
102 |
|
|
|
102 |
|
|
103 |
|
|
|
103 |
|
|
104 |
|
/**
|
|
104 |
|
/**
|
105 |
|
* The
request m
ethod used
on this R
equest.
|
|
105 |
|
* The
request m
ethod used
on this R
equest.
|
106 |
|
*/
|
|
106 |
|
*/
|
107 |
|
privat
e String m
ethod = nu
ll;
|
|
107 |
|
privat
e String m
ethod = nu
ll;
|
108 |
|
|
|
108 |
|
|
109 |
|
public
String ge
tMethod()
{
|
|
109 |
|
public
String ge
tMethod()
{
|
110 |
|
re
turn (this
.method);
|
|
110 |
|
re
turn (this
.method);
|
111 |
|
}
|
|
111 |
|
}
|
112 |
|
|
|
112 |
|
|
113 |
|
public
void setM
ethod(Stri
ng method)
{
|
|
113 |
|
public
void setM
ethod(Stri
ng method)
{
|
114 |
|
th
is.method
= method;
|
|
114 |
|
th
is.method
= method;
|
115 |
|
}
|
|
115 |
|
}
|
116 |
|
|
|
116 |
|
|
117 |
|
|
|
117 |
|
|
118 |
|
/**
|
|
118 |
|
/**
|
119 |
|
* The
query str
ing associ
ated with
this Reque
st.
|
|
119 |
|
* The
query str
ing associ
ated with
this Reque
st.
|
120 |
|
*/
|
|
120 |
|
*/
|
121 |
|
privat
e String q
ueryString
= null;
|
|
121 |
|
privat
e String q
ueryString
= null;
|
122 |
|
|
|
122 |
|
|
123 |
|
public
String ge
tQueryStri
ng() {
|
|
123 |
|
public
String ge
tQueryStri
ng() {
|
124 |
|
re
turn (this
.queryStri
ng);
|
|
124 |
|
re
turn (this
.queryStri
ng);
|
125 |
|
}
|
|
125 |
|
}
|
126 |
|
|
|
126 |
|
|
127 |
|
public
void setQ
ueryString
(String qu
eryString)
{
|
|
127 |
|
public
void setQ
ueryString
(String qu
eryString)
{
|
128 |
|
th
is.querySt
ring = que
ryString;
|
|
128 |
|
th
is.querySt
ring = que
ryString;
|
129 |
|
}
|
|
129 |
|
}
|
130 |
|
|
|
130 |
|
|
131 |
|
|
|
131 |
|
|
132 |
|
/**
|
|
132 |
|
/**
|
133 |
|
* The
request U
RI associa
ted with t
his Reques
t.
|
|
133 |
|
* The
request U
RI associa
ted with t
his Reques
t.
|
134 |
|
*/
|
|
134 |
|
*/
|
135 |
|
privat
e String r
equestURI
= null;
|
|
135 |
|
privat
e String r
equestURI
= null;
|
136 |
|
|
|
136 |
|
|
137 |
|
public
String ge
tRequestUR
I() {
|
|
137 |
|
public
String ge
tRequestUR
I() {
|
138 |
|
re
turn (this
.requestUR
I);
|
|
138 |
|
re
turn (this
.requestUR
I);
|
139 |
|
}
|
|
139 |
|
}
|
140 |
|
|
|
140 |
|
|
141 |
|
public
void setR
equestURI(
String req
uestURI) {
|
|
141 |
|
public
void setR
equestURI(
String req
uestURI) {
|
142 |
|
th
is.request
URI = requ
estURI;
|
|
142 |
|
th
is.request
URI = requ
estURI;
|
143 |
|
}
|
|
143 |
|
}
|
144 |
|
|
|
144 |
|
|
145 |
|
|
|
145 |
|
|
146 |
|
/**
|
|
146 |
|
/**
|
147 |
|
* The
decode re
quest URI
associated
with this
Request.
Path param
eters are
|
|
147 |
|
* The
decode re
quest URI
associated
with this
Request.
Path param
eters are
|
148 |
|
* als
o excluded
|
|
148 |
|
* als
o excluded
|
149 |
|
*/
|
|
149 |
|
*/
|
150 |
|
privat
e String d
ecodedRequ
estURI = n
ull;
|
|
150 |
|
privat
e String d
ecodedRequ
estURI = n
ull;
|
151 |
|
|
|
151 |
|
|
152 |
|
public
String ge
tDecodedRe
questURI()
{
|
|
152 |
|
public
String ge
tDecodedRe
questURI()
{
|
153 |
|
re
turn (this
.decodedRe
questURI);
|
|
153 |
|
re
turn (this
.decodedRe
questURI);
|
154 |
|
}
|
|
154 |
|
}
|
155 |
|
|
|
155 |
|
|
156 |
|
public
void setD
ecodedRequ
estURI(Str
ing decode
dRequestUR
I) {
|
|
156 |
|
public
void setD
ecodedRequ
estURI(Str
ing decode
dRequestUR
I) {
|
157 |
|
th
is.decoded
RequestURI
= decoded
RequestURI
;
|
|
157 |
|
th
is.decoded
RequestURI
= decoded
RequestURI
;
|
158 |
|
}
|
|
158 |
|
}
|
159 |
|
|
|
159 |
|
|
160 |
|
|
|
160 |
|
|
161 |
|
/**
|
|
161 |
|
/**
|
162 |
|
* The
body of t
his reques
t.
|
|
162 |
|
* The
body of t
his reques
t.
|
163 |
|
*/
|
|
163 |
|
*/
|
164 |
|
privat
e ByteChun
k body = n
ull;
|
|
164 |
|
privat
e ByteChun
k body = n
ull;
|
165 |
|
|
|
165 |
|
|
166 |
|
public
ByteChunk
getBody()
{
|
|
166 |
|
public
ByteChunk
getBody()
{
|
167 |
|
re
turn (this
.body);
|
|
167 |
|
re
turn (this
.body);
|
168 |
|
}
|
|
168 |
|
}
|
169 |
|
|
|
169 |
|
|
170 |
|
public
void setB
ody(ByteCh
unk body)
{
|
|
170 |
|
public
void setB
ody(ByteCh
unk body)
{
|
171 |
|
th
is.body =
body;
|
|
171 |
|
th
is.body =
body;
|
172 |
|
}
|
|
172 |
|
}
|
173 |
|
|
|
173 |
|
|
174 |
|
/**
|
|
174 |
|
/**
|
175 |
|
* The
content t
ype of the
request,
used if th
is is a PO
ST.
|
|
175 |
|
* The
content t
ype of the
request,
used if th
is is a PO
ST.
|
176 |
|
*/
|
|
176 |
|
*/
|
177 |
|
privat
e String c
ontentType
= null;
|
|
177 |
|
privat
e String c
ontentType
= null;
|
178 |
|
|
|
178 |
|
|
179 |
|
public
String ge
tContentTy
pe() {
|
|
179 |
|
public
String ge
tContentTy
pe() {
|
180 |
|
re
turn (this
.contentTy
pe);
|
|
180 |
|
re
turn (this
.contentTy
pe);
|
181 |
|
}
|
|
181 |
|
}
|
182 |
|
|
|
182 |
|
|
183 |
|
public
void setC
ontentType
(String co
ntentType)
{
|
|
183 |
|
public
void setC
ontentType
(String co
ntentType)
{
|
184 |
|
th
is.content
Type = con
tentType;
|
|
184 |
|
th
is.content
Type = con
tentType;
|
185 |
|
}
|
|
185 |
|
}
|
186 |
|
}
|
|
186 |
|
}
|