Produced by Araxis Merge on 11/20/2017 2:16:16 PM GMT Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | Mon Nov 20 14:16:16 2017 UTC | ||
2 | C:\Merge Test Files\8.5.23\java\org\apache\catalina\authenticator\jaspic | CallbackHandlerImpl.java | Thu Sep 28 11:32:16 2017 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 0 | 0 |
Changed | 0 | 0 |
Inserted | 1 | 119 |
Removed | 0 | 0 |
Whitespace | Consecutive whitespace is treated as a single space |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | /* | |||||
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 | |||||
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 | |||||
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 | |||||
8 | * | |||||
9 | * ht tp://www.a pache.org/ licenses/L ICENSE-2.0 | |||||
10 | * | |||||
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, | |||||
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 | |||||
15 | * limitat ions under the Licen se. | |||||
16 | */ | |||||
17 | package or g.apache.c atalina.au thenticato r.jaspic; | |||||
18 | ||||||
19 | import jav a.io.IOExc eption; | |||||
20 | import jav a.security .Principal ; | |||||
21 | import jav a.util.Arr ays; | |||||
22 | import jav a.util.Col lections; | |||||
23 | import jav a.util.Lis t; | |||||
24 | ||||||
25 | import jav ax.securit y.auth.Sub ject; | |||||
26 | import jav ax.securit y.auth.cal lback.Call back; | |||||
27 | import jav ax.securit y.auth.cal lback.Call backHandle r; | |||||
28 | import jav ax.securit y.auth.cal lback.Unsu pportedCal lbackExcep tion; | |||||
29 | import jav ax.securit y.auth.mes sage.callb ack.Caller PrincipalC allback; | |||||
30 | import jav ax.securit y.auth.mes sage.callb ack.GroupP rincipalCa llback; | |||||
31 | ||||||
32 | import org .apache.ca talina.rea lm.Generic Principal; | |||||
33 | import org .apache.ju li.logging .Log; | |||||
34 | import org .apache.ju li.logging .LogFactor y; | |||||
35 | import org .apache.to mcat.util. res.String Manager; | |||||
36 | ||||||
37 | /** | |||||
38 | * Impleme nted as a singleton since the class is s tateless. | |||||
39 | */ | |||||
40 | public cla ss Callbac kHandlerIm pl impleme nts Callba ckHandler { | |||||
41 | ||||||
42 | privat e static f inal Log l og = LogFa ctory.getL og(Callbac kHandlerIm pl.class); | |||||
43 | privat e static f inal Strin gManager s m = String Manager.ge tManager(C allbackHan dlerImpl.c lass); | |||||
44 | ||||||
45 | privat e static C allbackHan dler insta nce; | |||||
46 | ||||||
47 | ||||||
48 | static { | |||||
49 | in stance = n ew Callbac kHandlerIm pl(); | |||||
50 | } | |||||
51 | ||||||
52 | ||||||
53 | public static Ca llbackHand ler getIns tance() { | |||||
54 | re turn insta nce; | |||||
55 | } | |||||
56 | ||||||
57 | ||||||
58 | privat e Callbac kHandlerIm pl() { | |||||
59 | // Hide defa ult constr uctor | |||||
60 | } | |||||
61 | ||||||
62 | ||||||
63 | @Overr ide | |||||
64 | public void hand le(Callbac k[] callba cks) throw s IOExcept ion, Unsup portedCall backExcept ion { | |||||
65 | ||||||
66 | St ring name = null; | |||||
67 | Pr incipal pr incipal = null; | |||||
68 | Su bject subj ect = null ; | |||||
69 | St ring[] gro ups = null ; | |||||
70 | ||||||
71 | if (callback s != null) { | |||||
72 | // Need to combine data from multiple callbacks so use thi s to hold | |||||
73 | // the d ata | |||||
74 | // Proce ss the cal lbacks | |||||
75 | for (Cal lback call back : cal lbacks) { | |||||
76 | if ( callback i nstanceof CallerPrin cipalCallb ack) { | |||||
77 | CallerPrin cipalCallb ack cpc = (CallerPri ncipalCall back) call back; | |||||
78 | name = cpc .getName() ; | |||||
79 | principal = cpc.getP rincipal() ; | |||||
80 | subject = cpc.getSub ject(); | |||||
81 | } el se if (cal lback inst anceof Gro upPrincipa lCallback) { | |||||
82 | GroupPrinc ipalCallba ck gpc = ( GroupPrinc ipalCallba ck) callba ck; | |||||
83 | groups = g pc.getGrou ps(); | |||||
84 | } el se { | |||||
85 | log.error( sm.getStri ng("callba ckHandlerI mpl.jaspic CallbackMi ssing", | |||||
86 | ca llback.get Class().ge tName())); | |||||
87 | } | |||||
88 | } | |||||
89 | ||||||
90 | // Creat e the Gene ricPrincip al | |||||
91 | Principa l gp = get Principal( principal, name, gro ups); | |||||
92 | if (subj ect != nul l && gp != null) { | |||||
93 | subj ect.getPri vateCreden tials().ad d(gp); | |||||
94 | } | |||||
95 | } | |||||
96 | } | |||||
97 | ||||||
98 | ||||||
99 | privat e Principa l getPrinc ipal(Princ ipal princ ipal, Stri ng name, S tring[] gr oups) { | |||||
100 | // If the Pr incipal is cached in the sessi on JASPIC may simply return it | |||||
101 | if (principa l instance of Generic Principal) { | |||||
102 | return p rincipal; | |||||
103 | } | |||||
104 | if (name == null && pr incipal != null) { | |||||
105 | name = p rincipal.g etName(); | |||||
106 | } | |||||
107 | if (name == null) { | |||||
108 | return n ull; | |||||
109 | } | |||||
110 | Li st<String> roles; | |||||
111 | if (groups = = null || groups.len gth == 0) { | |||||
112 | roles = Collection s.emptyLis t(); | |||||
113 | } else { | |||||
114 | roles = Arrays.asL ist(groups ); | |||||
115 | } | |||||
116 | ||||||
117 | re turn new G enericPrin cipal(name , null, ro les, princ ipal); | |||||
118 | } | |||||
119 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993–2017 Araxis Ltd (www.araxis.com). All rights reserved.