1 |
|
/*
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
7 |
|
* the Lic
ense. You
may obtai
n a copy o
f the Lice
nse at
|
8 |
|
*
|
|
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
|
|
9 |
|
* ht
tp://www.a
pache.org/
licenses/L
ICENSE-2.0
|
10 |
|
*
|
|
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
|
|
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,
|
|
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.
|
|
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
|
|
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.
|
|
15 |
|
* limitat
ions under
the Licen
se.
|
16 |
|
*/
|
|
16 |
|
*/
|
|
16 |
|
*/
|
17 |
|
package or
g.apache.c
atalina.au
thenticato
r;
|
|
17 |
|
package or
g.apache.c
atalina.au
thenticato
r;
|
|
17 |
|
package or
g.apache.c
atalina.au
thenticato
r;
|
18 |
|
|
|
18 |
|
|
|
18 |
|
|
19 |
|
import jav
a.io.Seria
lizable;
|
|
19 |
|
import jav
a.io.Seria
lizable;
|
|
19 |
|
import jav
a.io.Seria
lizable;
|
20 |
|
|
|
20 |
|
|
|
20 |
|
|
21 |
|
import org
.apache.ca
talina.Con
text;
|
|
21 |
|
import org
.apache.ca
talina.Con
text;
|
|
21 |
|
import org
.apache.ca
talina.Con
text;
|
22 |
|
import org
.apache.ca
talina.Ses
sion;
|
|
22 |
|
import org
.apache.ca
talina.Ses
sion;
|
|
22 |
|
import org
.apache.ca
talina.Ses
sion;
|
23 |
|
|
|
23 |
|
|
|
23 |
|
|
24 |
|
/**
|
|
24 |
|
/**
|
|
24 |
|
/**
|
25 |
|
* Key use
d by SSO t
o identify
a session
. This key
is used r
ather than
the
|
|
25 |
|
* Key use
d by SSO t
o identify
a session
. This key
is used r
ather than
the
|
|
25 |
|
* Key use
d by SSO t
o identify
a session
. This key
is used r
ather than
the
|
26 |
|
* actual
session to
facilitat
e the repl
ication of
the SSO i
nformation
|
|
26 |
|
* actual
session to
facilitat
e the repl
ication of
the SSO i
nformation
|
|
26 |
|
* actual
session to
facilitat
e the repl
ication of
the SSO i
nformation
|
27 |
|
* across
a cluster
where repl
icating th
e entire s
ession wou
ld generat
e
|
|
27 |
|
* across
a cluster
where repl
icating th
e entire s
ession wou
ld generat
e
|
|
27 |
|
* across
a cluster
where repl
icating th
e entire s
ession wou
ld generat
e
|
28 |
|
* signifi
cant, unne
cessary ov
erhead.
|
|
28 |
|
* signifi
cant, unne
cessary ov
erhead.
|
|
28 |
|
* signifi
cant, unne
cessary ov
erhead.
|
29 |
|
*
|
|
29 |
|
*
|
|
29 |
|
*
|
30 |
|
*/
|
|
30 |
|
*/
|
|
30 |
|
*/
|
31 |
|
public cla
ss SingleS
ignOnSessi
onKey impl
ements Ser
ializable
{
|
|
31 |
|
public cla
ss SingleS
ignOnSessi
onKey impl
ements Ser
ializable
{
|
|
31 |
|
public cla
ss SingleS
ignOnSessi
onKey impl
ements Ser
ializable
{
|
32 |
|
|
|
32 |
|
|
|
32 |
|
|
33 |
|
privat
e static f
inal long
serialVers
ionUID = 1
L;
|
|
33 |
|
privat
e static f
inal long
serialVers
ionUID = 1
L;
|
|
33 |
|
privat
e static f
inal long
serialVers
ionUID = 1
L;
|
34 |
|
|
|
34 |
|
|
|
34 |
|
|
35 |
|
privat
e final St
ring sessi
onId;
|
|
35 |
|
privat
e final St
ring sessi
onId;
|
|
35 |
|
privat
e final St
ring sessi
onId;
|
36 |
|
privat
e final St
ring conte
xtName;
|
|
36 |
|
privat
e final St
ring conte
xtName;
|
|
36 |
|
privat
e final St
ring conte
xtName;
|
37 |
|
privat
e final St
ring hostN
ame;
|
|
37 |
|
privat
e final St
ring hostN
ame;
|
|
37 |
|
privat
e final St
ring hostN
ame;
|
38 |
|
|
|
38 |
|
|
|
38 |
|
|
39 |
|
public
SingleSig
nOnSession
Key(Sessio
n session)
{
|
|
39 |
|
public
SingleSig
nOnSession
Key(Sessio
n session)
{
|
|
39 |
|
public
SingleSig
nOnSession
Key(Sessio
n session)
{
|
40 |
|
th
is.session
Id = sessi
on.getId()
;
|
|
40 |
|
th
is.session
Id = sessi
on.getId()
;
|
|
40 |
|
th
is.session
Id = sessi
on.getId()
;
|
41 |
|
Co
ntext cont
ext = sess
ion.getMan
ager().get
Context();
|
|
41 |
|
Co
ntext cont
ext = sess
ion.getMan
ager().get
Context();
|
|
41 |
|
Co
ntext cont
ext = sess
ion.getMan
ager().get
Context();
|
42 |
|
th
is.context
Name = con
text.getNa
me();
|
|
42 |
|
th
is.context
Name = con
text.getNa
me();
|
|
42 |
|
th
is.context
Name = con
text.getNa
me();
|
43 |
|
th
is.hostNam
e = contex
t.getParen
t().getNam
e();
|
|
43 |
|
th
is.hostNam
e = contex
t.getParen
t().getNam
e();
|
|
43 |
|
th
is.hostNam
e = contex
t.getParen
t().getNam
e();
|
44 |
|
}
|
|
44 |
|
}
|
|
44 |
|
}
|
45 |
|
|
|
45 |
|
|
|
45 |
|
|
46 |
|
public
String ge
tSessionId
() {
|
|
46 |
|
public
String ge
tSessionId
() {
|
|
46 |
|
public
String ge
tSessionId
() {
|
47 |
|
re
turn sessi
onId;
|
|
47 |
|
re
turn sessi
onId;
|
|
47 |
|
re
turn sessi
onId;
|
48 |
|
}
|
|
48 |
|
}
|
|
48 |
|
}
|
49 |
|
|
|
49 |
|
|
|
49 |
|
|
50 |
|
public
String ge
tContextNa
me() {
|
|
50 |
|
public
String ge
tContextNa
me() {
|
|
50 |
|
public
String ge
tContextNa
me() {
|
51 |
|
re
turn conte
xtName;
|
|
51 |
|
re
turn conte
xtName;
|
|
51 |
|
re
turn conte
xtName;
|
52 |
|
}
|
|
52 |
|
}
|
|
52 |
|
}
|
53 |
|
|
|
53 |
|
|
|
53 |
|
|
54 |
|
public
String ge
tHostName(
) {
|
|
54 |
|
public
String ge
tHostName(
) {
|
|
54 |
|
public
String ge
tHostName(
) {
|
55 |
|
re
turn hostN
ame;
|
|
55 |
|
re
turn hostN
ame;
|
|
55 |
|
re
turn hostN
ame;
|
56 |
|
}
|
|
56 |
|
}
|
|
56 |
|
}
|
57 |
|
|
|
57 |
|
|
|
57 |
|
|
58 |
|
@Overr
ide
|
|
58 |
|
@Overr
ide
|
|
58 |
|
@Overr
ide
|
59 |
|
public
int hashC
ode() {
|
|
59 |
|
public
int hashC
ode() {
|
|
59 |
|
public
int hashC
ode() {
|
60 |
|
fi
nal int pr
ime = 31;
|
|
60 |
|
fi
nal int pr
ime = 31;
|
|
60 |
|
fi
nal int pr
ime = 31;
|
61 |
|
in
t result =
1;
|
|
61 |
|
in
t result =
1;
|
|
61 |
|
in
t result =
1;
|
62 |
|
re
sult = pri
me * resul
t +
|
|
62 |
|
re
sult = pri
me * resul
t +
|
|
62 |
|
re
sult = pri
me * resul
t +
|
63 |
|
((se
ssionId ==
null) ? 0
: session
Id.hashCod
e());
|
|
63 |
|
((se
ssionId ==
null) ? 0
: session
Id.hashCod
e());
|
|
63 |
|
((se
ssionId ==
null) ? 0
: session
Id.hashCod
e());
|
64 |
|
re
sult = pri
me * resul
t +
|
|
64 |
|
re
sult = pri
me * resul
t +
|
|
64 |
|
re
sult = pri
me * resul
t +
|
65 |
|
((co
ntextName
== null) ?
0 : conte
xtName.has
hCode());
|
|
65 |
|
((co
ntextName
== null) ?
0 : conte
xtName.has
hCode());
|
|
65 |
|
((co
ntextName
== null) ?
0 : conte
xtName.has
hCode());
|
66 |
|
re
sult = pri
me * resul
t +
|
|
66 |
|
re
sult = pri
me * resul
t +
|
|
66 |
|
re
sult = pri
me * resul
t +
|
67 |
|
((ho
stName ==
null) ? 0
: hostName
.hashCode(
));
|
|
67 |
|
((ho
stName ==
null) ? 0
: hostName
.hashCode(
));
|
|
67 |
|
((ho
stName ==
null) ? 0
: hostName
.hashCode(
));
|
68 |
|
re
turn resul
t;
|
|
68 |
|
re
turn resul
t;
|
|
68 |
|
re
turn resul
t;
|
69 |
|
}
|
|
69 |
|
}
|
|
69 |
|
}
|
70 |
|
|
|
70 |
|
|
|
70 |
|
|
71 |
|
@Overr
ide
|
|
71 |
|
@Overr
ide
|
|
71 |
|
@Overr
ide
|
72 |
|
public
boolean e
quals(Obje
ct obj) {
|
|
72 |
|
public
boolean e
quals(Obje
ct obj) {
|
|
72 |
|
public
boolean e
quals(Obje
ct obj) {
|
73 |
|
if
(this ==
obj) {
|
|
73 |
|
if
(this ==
obj) {
|
|
73 |
|
if
(this ==
obj) {
|
74 |
|
return t
rue;
|
|
74 |
|
return t
rue;
|
|
74 |
|
return t
rue;
|
75 |
|
}
|
|
75 |
|
}
|
|
75 |
|
}
|
76 |
|
if
(obj == n
ull) {
|
|
76 |
|
if
(obj == n
ull) {
|
|
76 |
|
if
(obj == n
ull) {
|
77 |
|
return f
alse;
|
|
77 |
|
return f
alse;
|
|
77 |
|
return f
alse;
|
78 |
|
}
|
|
78 |
|
}
|
|
78 |
|
}
|
79 |
|
if
(getClass
() != obj.
getClass()
) {
|
|
79 |
|
if
(getClass
() != obj.
getClass()
) {
|
|
79 |
|
if
(getClass
() != obj.
getClass()
) {
|
80 |
|
return f
alse;
|
|
80 |
|
return f
alse;
|
|
80 |
|
return f
alse;
|
81 |
|
}
|
|
81 |
|
}
|
|
81 |
|
}
|
82 |
|
Si
ngleSignOn
SessionKey
other = (
SingleSign
OnSessionK
ey) obj;
|
|
82 |
|
Si
ngleSignOn
SessionKey
other = (
SingleSign
OnSessionK
ey) obj;
|
|
82 |
|
Si
ngleSignOn
SessionKey
other = (
SingleSign
OnSessionK
ey) obj;
|
83 |
|
if
(sessionI
d == null)
{
|
|
83 |
|
if
(sessionI
d == null)
{
|
|
83 |
|
if
(sessionI
d == null)
{
|
84 |
|
if (othe
r.sessionI
d != null)
{
|
|
84 |
|
if (othe
r.sessionI
d != null)
{
|
|
84 |
|
if (othe
r.sessionI
d != null)
{
|
85 |
|
retu
rn false;
|
|
85 |
|
retu
rn false;
|
|
85 |
|
retu
rn false;
|
86 |
|
}
|
|
86 |
|
}
|
|
86 |
|
}
|
87 |
|
}
else if (!
sessionId.
equals(oth
er.session
Id)) {
|
|
87 |
|
}
else if (!
sessionId.
equals(oth
er.session
Id)) {
|
|
87 |
|
}
else if (!
sessionId.
equals(oth
er.session
Id)) {
|
88 |
|
return f
alse;
|
|
88 |
|
return f
alse;
|
|
88 |
|
return f
alse;
|
89 |
|
}
|
|
89 |
|
}
|
|
89 |
|
}
|
90 |
|
if
(contextN
ame == nul
l) {
|
|
90 |
|
if
(contextN
ame == nul
l) {
|
|
90 |
|
if
(contextN
ame == nul
l) {
|
91 |
|
if (othe
r.contextN
ame != nul
l) {
|
|
91 |
|
if (othe
r.contextN
ame != nul
l) {
|
|
91 |
|
if (othe
r.contextN
ame != nul
l) {
|
92 |
|
retu
rn false;
|
|
92 |
|
retu
rn false;
|
|
92 |
|
retu
rn false;
|
93 |
|
}
|
|
93 |
|
}
|
|
93 |
|
}
|
94 |
|
}
else if (!
contextNam
e.equals(o
ther.conte
xtName)) {
|
|
94 |
|
}
else if (!
contextNam
e.equals(o
ther.conte
xtName)) {
|
|
94 |
|
}
else if (!
contextNam
e.equals(o
ther.conte
xtName)) {
|
95 |
|
return f
alse;
|
|
95 |
|
return f
alse;
|
|
95 |
|
return f
alse;
|
96 |
|
}
|
|
96 |
|
}
|
|
96 |
|
}
|
97 |
|
if
(hostName
== null)
{
|
|
97 |
|
if
(hostName
== null)
{
|
|
97 |
|
if
(hostName
== null)
{
|
98 |
|
if (othe
r.hostName
!= null)
{
|
|
98 |
|
if (othe
r.hostName
!= null)
{
|
|
98 |
|
if (othe
r.hostName
!= null)
{
|
99 |
|
retu
rn false;
|
|
99 |
|
retu
rn false;
|
|
99 |
|
retu
rn false;
|
100 |
|
}
|
|
100 |
|
}
|
|
100 |
|
}
|
101 |
|
}
else if (!
hostName.e
quals(othe
r.hostName
)) {
|
|
101 |
|
}
else if (!
hostName.e
quals(othe
r.hostName
)) {
|
|
101 |
|
}
else if (!
hostName.e
quals(othe
r.hostName
)) {
|
102 |
|
return f
alse;
|
|
102 |
|
return f
alse;
|
|
102 |
|
return f
alse;
|
103 |
|
}
|
|
103 |
|
}
|
|
103 |
|
}
|
104 |
|
re
turn true;
|
|
104 |
|
re
turn true;
|
|
104 |
|
re
turn true;
|
105 |
|
}
|
|
105 |
|
}
|
|
105 |
|
}
|
106 |
|
|
|
106 |
|
|
|
106 |
|
|
107 |
|
@Overr
ide
|
|
107 |
|
@Overr
ide
|
|
107 |
|
@Overr
ide
|
108 |
|
public
String to
String() {
|
|
108 |
|
public
String to
String() {
|
|
108 |
|
public
String to
String() {
|
109 |
|
//
Session I
D is 32. S
tandard te
xt is 36.
Host could
easily be
20+.
|
|
109 |
|
//
Session I
D is 32. S
tandard te
xt is 36.
Host could
easily be
20+.
|
|
109 |
|
//
Session I
D is 32. S
tandard te
xt is 36.
Host could
easily be
20+.
|
110 |
|
//
Context c
ould be an
ything fro
m 0 upward
s. 128 see
ms like a
reasonable
|
|
110 |
|
//
Context c
ould be an
ything fro
m 0 upward
s. 128 see
ms like a
reasonable
|
|
110 |
|
//
Context c
ould be an
ything fro
m 0 upward
s. 128 see
ms like a
reasonable
|
111 |
|
//
size to a
ccommodate
most case
s without
being too
big.
|
|
111 |
|
//
size to a
ccommodate
most case
s without
being too
big.
|
|
111 |
|
//
size to a
ccommodate
most case
s without
being too
big.
|
112 |
|
St
ringBuilde
r sb = new
StringBui
lder(128);
|
|
112 |
|
St
ringBuilde
r sb = new
StringBui
lder(128);
|
|
112 |
|
St
ringBuilde
r sb = new
StringBui
lder(128);
|
113 |
|
sb
.append("H
ost: [");
|
|
113 |
|
sb
.append("H
ost: [");
|
|
113 |
|
sb
.append("H
ost: [");
|
114 |
|
sb
.append(ho
stName);
|
|
114 |
|
sb
.append(ho
stName);
|
|
114 |
|
sb
.append(ho
stName);
|
115 |
|
sb
.append("]
, Context:
[");
|
|
115 |
|
sb
.append("]
, Context:
[");
|
|
115 |
|
sb
.append("]
, Context:
[");
|
116 |
|
sb
.append(co
ntextName)
;
|
|
116 |
|
sb
.append(co
ntextName)
;
|
|
116 |
|
sb
.append(co
ntextName)
;
|
117 |
|
sb
.append("]
, SessionI
D: [");
|
|
117 |
|
sb
.append("]
, SessionI
D: [");
|
|
117 |
|
sb
.append("]
, SessionI
D: [");
|
118 |
|
sb
.append(se
ssionId);
|
|
118 |
|
sb
.append(se
ssionId);
|
|
118 |
|
sb
.append(se
ssionId);
|
119 |
|
sb
.append("]
");
|
|
119 |
|
sb
.append("]
");
|
|
119 |
|
sb
.append("]
");
|
120 |
|
re
turn sb.to
String();
|
|
120 |
|
re
turn sb.to
String();
|
|
120 |
|
re
turn sb.to
String();
|
121 |
|
}
|
|
121 |
|
}
|
|
121 |
|
}
|
122 |
|
}
|
|
122 |
|
}
|
|
122 |
|
}
|