Produced by Araxis Merge on 10/18/2018 2:02:18 PM Central Daylight 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 | VIX_SIV_v3_0_patch_201_build_8.zip\v3.0_patch_201_build_8\VISA\Java\FederationDataSourceProvider\main\src\java\gov\va\med\imaging\federation\proxy | FederationProxyUtilities.java | Thu Oct 11 13:30:10 2018 UTC |
2 | VIX_SIV_v3_0_patch_201_build_8.zip\v3.0_patch_201_build_8\VISA\Java\FederationDataSourceProvider\main\src\java\gov\va\med\imaging\federation\proxy | FederationProxyUtilities.java | Wed Oct 17 18:49:10 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 4 | 624 |
Changed | 3 | 8 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
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 | * | |
3 | Package: MAG - Vis tA Imaging | |
4 | WARNING: Per VHA D irective 2 004-038, t his routin e should n ot be modi fied. | |
5 | Date Cre ated: May 7, 2008 | |
6 | Site Nam e: Washin gton OI Fi eld Office , Silver S pring, MD | |
7 | Developer: PI I
|
|
8 | Descript ion: | |
9 | ||
10 | ;; +-------- ---------- ---------- ---------- ---------- ---------- ---------- + | |
11 | ;; Property of the US Government . | |
12 | ;; No permis sion to co py or redi stribute t his softwa re is give n. | |
13 | ;; Use of un released v ersions of this soft ware requi res the us er | |
14 | ;; to execu te a writt en test ag reement wi th the Vis tA Imaging | |
15 | ;; Developm ent Office of the De partment o f Veterans Affairs, | |
16 | ;; telephon e (301) 73 4-0100. | |
17 | ;; | |
18 | ;; The Food and Drug A dministrat ion classi fies this software a s | |
19 | ;; a Class I I medical device. A s such, it may not b e changed | |
20 | ;; in any wa y. Modifi cations to this soft ware may r esult in a n | |
21 | ;; adulterat ed medical device un der 21CFR8 20, the us e of which | |
22 | ;; is consid ered to be a violati on of US F ederal Sta tutes. | |
23 | ;; +-------- ---------- ---------- ---------- ---------- ---------- ---------- + | |
24 | ||
25 | */ | |
26 | package go v.va.med.i maging.fed eration.pr oxy; | |
27 | ||
28 | import jav a.net.Malf ormedURLEx ception; | |
29 | import jav a.net.URL; | |
30 | import jav a.security .Provider; | |
31 | import jav a.util.Set ; | |
32 | import jav a.util.Sor tedSet; | |
33 | ||
34 | import jav ax.net.ssl .TrustMana ger; | |
35 | import jav ax.net.ssl .TrustMana gerFactory ; | |
36 | ||
37 | import org .apache.co mmons.http client.pro tocol.Prot ocol; | |
38 | import org .apache.co mmons.http client.pro tocol.Prot ocolSocket Factory; | |
39 | import org .apache.lo gging.log4 j.LogManag er; | |
40 | import org .apache.lo gging.log4 j.Logger; | |
41 | ||
42 | import gov .va.med.im aging.exch ange.busin ess.Site; | |
43 | import gov .va.med.im aging.fede rationdata source.con figuration .Federatio nConfigura tion; | |
44 | import gov .va.med.im aging.prox y.ImagingP roxy; | |
45 | import gov .va.med.im aging.prox y.ids.IDSO peration; | |
46 | import gov .va.med.im aging.prox y.ids.IDSP roxy; | |
47 | import gov .va.med.im aging.prox y.ids.IDSS ervice; | |
48 | import gov .va.med.im aging.prox y.services .ProxyServ ice; | |
49 | import gov .va.med.im aging.prox y.services .ProxyServ iceType; | |
50 | import gov .va.med.im aging.prox y.services .ProxyServ ices; | |
51 | import gov .va.med.im aging.prox y.ssl.Auth SSLProtoco lSocketFac tory; | |
52 | ||
53 | /** | |
54 | * Common utilities for all Fe deration d ata source s | |
55 | * | |
56 | * @author PI I
|
|
57 | * | |
58 | */ | |
59 | public cla ss Federat ionProxyUt ilities | |
60 | { | |
61 | pr ivate fina l static I DSProxy ve rsionProxy = new IDS Proxy(); | |
62 | pr ivate fina l static L ogger logg er = LogMa nager.getL ogger(Fede rationProx yUtilities .class); | |
63 | pr ivate fina l static S tring def aultFedera tionProtoc ol = "http s"; | |
64 | ||
65 | pu blic final static in t defaultF ederationS slPort = PORT ; | |
66 | pu blic final static in t defaultF ederationS slNioPort = PORT ; | |
67 | pu blic final static in t starting NioVersion = 8; | |
68 | ||
69 | /* * | |
70 | * Configure the Feder ation cert ificate pr otocol to use certif icates to communicat e with rem ote server | |
71 | * @param fe derationCo nfiguratio n The conf iguration for the fe deration d ata source | |
72 | * / | |
73 | pu blic stati c void con figureFede rationCert ificate(Fe derationCo nfiguratio n federati onConfigur ation) | |
74 | { | |
75 | try | |
76 | { | |
77 | URL keysto reUrl = ne w URL(fede rationConf iguration. getKeystor eUrl()); // t he keystor e containi ng the key to send a s the clie nt | |
78 | URL trusts toreUrl = new URL(fe derationCo nfiguratio n.getTrust storeUrl() ); // t he keystor e containi ng the tru sted certi ficates, t o validate the serve r cert aga inst | |
79 | ||
80 | ProtocolSo cketFactor y socketFa ctory = | |
81 | new Au thSSLProto colSocketF actory(key storeUrl, | |
82 | federati onConfigur ation.getK eystorePas sword(), t ruststoreU rl, | |
83 | federati onConfigur ation.getT ruststoreP assword()) ; | |
84 | ||
85 | Protoc ol httpsPr otocol = n ew Protoco l(defaultF ederationP rotocol, s ocketFacto ry, defaul tFederatio nSslPort); | |
86 | Protocol.r egisterPro tocol(fede rationConf iguration. getFederat ionSslProt ocol(), ht tpsProtoco l); | |
87 | LogManager .getLogger (Federatio nProxyUtil ities.clas s).info("F ederation HTTPS prot ocol handl er success fully regi stered."); | |
88 | dumpSSLPro perties(); | |
89 | } | |
90 | catc h (Malform edURLExcep tion e) | |
91 | { | |
92 | LogManager .getLogger (ImagingPr oxy.class) .error( | |
93 | "E rror confi guring HTT PS client within fed eration pr oxy. \n" + | |
94 | "K eystore an d/or trust store are unavailabl e. \n" + | |
95 | "F ederation functional ity will n ot be avai lable."); | |
96 | } | |
97 | } | |
98 | ||
99 | /* * | |
100 | * Helper co de to outp ut the SSL propertie s loaded f rom the ke ystore/tru ststore | |
101 | * / | |
102 | pr ivate stat ic void du mpSSLPrope rties() | |
103 | ||
104 | { | |
105 | St ring defau ltAlgorith m = null; | |
106 | ja vax.net.ss l.KeyManag erFactory keyMgrFact ory = null ; | |
107 | Pr ovider pro vider = nu ll; | |
108 | Se t<Object> keySet = n ull; | |
109 | ja vax.net.ss l.KeyManag er[] keyMa nagers = n ull; | |
110 | Sy stem.out.p rintln("== ========== ======== S SL Propert ies ====== ========== ========== ========== =="); | |
111 | tr y | |
112 | { | |
113 | defa ultAlgorit hm = javax .net.ssl.K eyManagerF actory.get DefaultAlg orithm(); | |
114 | Syst em.out.pri ntln("Defa ult Algori thm is '" + defaultA lgorithm + "'"); | |
115 | } | |
116 | ca tch (Throw able x) | |
117 | { | |
118 | Syst em.out.pri ntln("Erro r (" + x.g etMessage( ) + ") get ting defau lt algorit hm"); | |
119 | } | |
120 | tr y | |
121 | { | |
122 | keyM grFactory = javax.ne t.ssl.KeyM anagerFact ory.getIns tance(defa ultAlgorit hm); | |
123 | Syst em.out.pri ntln("KeyM anagerFact ory type i s '" + key MgrFactory .getClass( ).getSimpl eName() + "'"); | |
124 | } | |
125 | ca tch (Throw able x) | |
126 | { | |
127 | Syst em.out.pri ntln("Erro r (" + x.g etMessage( ) + ") get ting key m anager fac tory"); | |
128 | } | |
129 | tr y | |
130 | { | |
131 | prov ider = key MgrFactory .getProvid er(); | |
132 | Syst em.out.pri ntln("KeyM anagerFact ory Provid er type is '" + prov ider.getCl ass().getS impleName( ) + "'"); | |
133 | } | |
134 | ca tch (Throw able x) | |
135 | { | |
136 | Syst em.out.pri ntln("Erro r (" + x.g etMessage( ) + ") get ting provi der"); | |
137 | } | |
138 | Sy stem.out.p rintln("== ========== ======= Tr ustManager Factory.PK IX Trust M anagers == ========== ========== ===="); | |
139 | tr y | |
140 | { | |
141 | Obje ct provide rValue = p rovider.ge t("TrustMa nagerFacto ry.PKIX"); | |
142 | Trus tManagerFa ctory pkix TrustMgrFa ctory = (T rustManage rFactory)p roviderVal ue; | |
143 | Trus tManager[] pkixTrust managers = pkixTrust MgrFactory .getTrustM anagers(); | |
144 | for (TrustMana ger pkixTr ustManager : pkixTru stmanagers ) | |
145 | System .out.print ln("Provid er " + pki xTrustMana ger.toStri ng() ); | |
146 | } | |
147 | ca tch (Throw able x) | |
148 | { | |
149 | Syst em.out.pri ntln("Erro r (" + x.g etMessage( ) + ") get ting Trust ManagerFac tory.PKIX value"); | |
150 | } | |
151 | Sy stem.out.p rintln("== ========== ======= Tr ustManager Factory.PK IX Trust M anagers == ========== ========== ===="); | |
152 | tr y | |
153 | { | |
154 | keyS et = provi der.keySet (); | |
155 | for (Object ke y : keySet ) | |
156 | System .out.print ln("Provid er [" + ke y.toString () + "] [" + provide r.get(key) .toString( ) + "]" ); | |
157 | } | |
158 | ca tch (Throw able x) | |
159 | { | |
160 | Syst em.out.pri ntln("Erro r (" + x.g etMessage( ) + ") get ting provi der keyset "); | |
161 | } | |
162 | tr y | |
163 | { | |
164 | keyM anagers = keyMgrFact ory.getKey Managers() ; | |
165 | for (javax.net .ssl.KeyMa nager keyM anager : k eyManagers ) | |
166 | System .out.print ln("KeyMan ager [" + keyManager .getClass( ).getSimpl eName() + "]" ); | |
167 | } | |
168 | ca tch (Throw able x) | |
169 | { | |
170 | Syst em.out.pri ntln("Erro r (" + x.g etMessage( ) + ") get ting key m anagers"); | |
171 | } | |
172 | Sy stem.out.p rintln("== ========== ======== E nd SSL Pro perties == ========== ========== ========== ======"); | |
173 | } | |
174 | ||
175 | /* * | |
176 | * | |
177 | * @param si te | |
178 | * @param se rviceName | |
179 | * @param da tasourceVe rsion | |
180 | * @return | |
181 | * / | |
182 | pu blic stati c ProxySer vices getF ederationP roxyServic es(Site si te, String serviceNa me, String datasourc eVersion) | |
183 | { | |
184 | // g et the ser vice from the IDS on the remot e web app | |
185 | Sort edSet<IDSS ervice> se rvices = v ersionProx y.getImagi ngServices (site, ser viceName, datasource Version); | |
186 | // i f nothing is returne d, then th ere are no facades t o service this versi on | |
187 | if(( services = = null) || (services .size() <= 0)) | |
188 | { | |
189 | logger .warn("Got null serv ices back from IDS s ervice for site [" + site.getS iteNumber( ) + "], in dicates re mote site does not h ave a VIX. Cannot us e Federati on for thi s site"); | |
190 | return null; | |
191 | } | |
192 | ||
193 | IDSS ervice ser vice = ser vices.firs t(); | |
194 | ||
195 | Prox yServices proxyServi ces = new ProxyServi ces(); | |
196 | ||
197 | for( IDSOperati on operati on : servi ce.getOper ations()) | |
198 | { | |
199 | proxyS ervices.ad d(new Fede rationProx yService(s ervice, op eration, s ite.getAcc eleratorSe rver(), de faultFeder ationSslPo rt)); | |
200 | } | |
201 | ||
202 | retu rn proxySe rvices; | |
203 | } | |
204 | ||
205 | /* * | |
206 | * | |
207 | * @param si te | |
208 | * @param se rviceName | |
209 | * @param da tasourceVe rsion | |
210 | * @return | |
211 | * / | |
212 | pu blic stati c ProxySer vices getC urrentFede rationProx yServices( Site site, String se rviceName, String da tasourceVe rsion) | |
213 | { | |
214 | logg er.debug(" Datasource Version: "+datasour ceVersion) ; | |
215 | int callerVers ion = Inte ger.parseI nt(datasou rceVersion ); | |
216 | ||
217 | // g et the ser vice from the IDS on the remot e web app | |
218 | Sort edSet<IDSS ervice> se rvices = v ersionProx y.getImagi ngServices (site, ser viceName, ""); | |
219 | ||
220 | // i f nothing is returne d, then th ere are no facades t o service this versi on | |
221 | if(( services = = null) || (services .size() <= 0)) | |
222 | { | |
223 | logger .warn("Got null serv ices back from IDS s ervice for site [" + site.getS iteNumber( ) + "], in dicates re mote site does not h ave a VIX. Cannot us e Federati on for thi s site"); | |
224 | return null; | |
225 | } | |
226 | ||
227 | IDSS ervice cur rentServic e = servic es.first() ; | |
228 | ||
229 | logg er.debug(" Current Fe deration I DSService version on site [" + site.getS iteNumber( ) + "] is " + curren tService.g etVersion( )); | |
230 | ||
231 | int version = Integer.pa rseInt(cur rentServic e.getVersi on()); | |
232 | int port = (ve rsion < st artingNioV ersion) ? defaultFed erationSsl Port : def aultFedera tionSslNio Port; | |
233 | ||
234 | Prox yServices proxyServi ces = new ProxyServi ces(); | |
235 | for (IDSServic e service : services ) | |
236 | { | |
237 | int se rviceVersi on = Integ er.parseIn t(service. getVersion ()); | |
238 | if (ca llerVersio n >= servi ceVersion) | |
239 | { | |
240 | for(IDSO peration o peration : service.g etOperatio ns()) | |
241 | { | |
242 | if (!IsPro xyServiceI nList( | |
243 | prox yServices, service, | |
244 | oper ation, sit e.getAccel eratorServ er(), port )) | |
245 | { | |
246 | lo gger.debug ("Adding F ederation IDSService version: " + servic e.getVersi on() + " o peration t ype: " + o peration.g etOperatio nType()); | |
247 | pr oxyService s.add(new Federation ProxyServi ce(service , operatio n, site.ge tAccelerat orServer() , port)); | |
248 | } | |
249 | } | |
250 | } | |
251 | } | |
252 | retu rn proxySe rvices; | |
253 | } | |
254 | ||
255 | ||
256 | pr ivate stat ic boolean IsProxySe rviceInLis t(ProxySer vices prox yServices, | |
257 | IDSSer vice servi ce, IDSOpe ration ope ration, | |
258 | String host, int port) | |
259 | { | |
260 | for (ProxyServ ice proxyS ervice : p roxyServic es) | |
261 | { | |
262 | ProxyS erviceType proxyServ iceType = | |
263 | ProxyServi ceType.get ProxyServi ceTypeFrom IDSOperati on(operati on); | |
264 | ||
265 | String applicati onPath = s ervice.get Applicatio nPath(); | |
266 | ||
267 | if ((p roxyServic e.getHost( ).equals(h ost)) | |
268 | && (prox yService.g etPort() = = port) | |
269 | && (prox yService.g etProxySer viceType() .equals(pr oxyService Type)) | |
270 | && (prox yService.g etApplicat ionPath(). equals(app licationPa th)) | |
271 | ) | |
272 | { | |
273 | return t rue; | |
274 | } | |
275 | } | |
276 | retu rn false; | |
277 | } | |
278 | ||
279 | pu blic stati c ProxySer vices getC urrentFede rationProx yServices( | |
280 | IDSSer vice servi ce, | |
281 | Site s ite) | |
282 | { | |
283 | int version = Integer.pa rseInt(ser vice.getVe rsion()); | |
284 | int port = (ve rsion < st artingNioV ersion) ? defaultFed erationSsl Port : def aultFedera tionSslNio Port; | |
285 | ||
286 | Prox yServices proxyServi ces = new ProxyServi ces(); | |
287 | ||
288 | for( IDSOperati on operati on : servi ce.getOper ations()) | |
289 | { | |
290 | proxyS ervices.ad d(new Fede rationProx yService(s ervice, op eration, s ite.getAcc eleratorSe rver(), po rt)); | |
291 | } | |
292 | ||
293 | retu rn proxySe rvices; | |
294 | } | |
295 | ||
296 | ||
297 | pu blic stati c IDSServi ce getIDSS ervice(Sit e site, St ring servi ceName) | |
298 | { | |
299 | // g et the ser vice from the IDS on the remot e web app | |
300 | Sort edSet<IDSS ervice> se rvices = v ersionProx y.getImagi ngServices (site, ser viceName, ""); | |
301 | ||
302 | // i f nothing is returne d, then th ere are no facades t o service this versi on | |
303 | if(( services = = null) || (services .size() <= 0)) | |
304 | { | |
305 | logger .warn("Got null serv ices back from IDS s ervice for site [" + site.getS iteNumber( ) + "], in dicates re mote site does not h ave a VIX. Cannot us e Federati on for thi s site"); | |
306 | return null; | |
307 | } | |
308 | ||
309 | IDSS ervice ser vice = ser vices.firs t(); | |
310 | logg er.debug(" Current Fe deration I DSService version: " + service .getVersio n()); | |
311 | ||
312 | retu rn service ; | |
313 | } | |
314 | ||
315 | ||
316 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.