Produced by Araxis Merge on 9/25/2018 2:13:05 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 | build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\org\apache\xml\internal\security\utils\resolver\implementations | ResolverDirectHTTP.java | Mon Jan 22 14:46:50 2018 UTC |
2 | build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\org\apache\xml\internal\security\utils\resolver\implementations | ResolverDirectHTTP.java | Wed Sep 12 16:38:24 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 3 | 542 |
Changed | 2 | 4 |
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 | * reserve d comment block | |
3 | * DO NOT REMOVE OR ALTER! | |
4 | */ | |
5 | /** | |
6 | * License d to the A pache Soft ware Found ation (ASF ) under on e | |
7 | * or more contribut or license agreement s. See the NOTICE fi le | |
8 | * distrib uted with this work for additi onal infor mation | |
9 | * regardi ng copyrig ht ownersh ip. The AS F licenses this file | |
10 | * to you under the Apache Lic ense, Vers ion 2.0 (t he | |
11 | * "Licens e"); you m ay not use this file except in complianc e | |
12 | * with th e License. You may o btain a co py of the License at | |
13 | * | |
14 | * http:// www.apache .org/licen ses/LICENS E-2.0 | |
15 | * | |
16 | * Unless required b y applicab le law or agreed to in writing , | |
17 | * softwar e distribu ted under the Licens e is distr ibuted on an | |
18 | * "AS IS" BASIS, WI THOUT WARR ANTIES OR CONDITIONS OF ANY | |
19 | * KIND, e ither expr ess or imp lied. See the Licens e for the | |
20 | * specifi c language governing permissio ns and lim itations | |
21 | * under t he License . | |
22 | */ | |
23 | package co m.sun.org. apache.xml .internal. security.u tils.resol ver.implem entations; | |
24 | ||
25 | import jav a.io.ByteA rrayOutput Stream; | |
26 | import jav a.io.IOExc eption; | |
27 | import jav a.io.Input Stream; | |
28 | import jav a.net.Inet SocketAddr ess; | |
29 | import jav a.net.Malf ormedURLEx ception; | |
30 | import jav a.net.Prox y; | |
31 | import jav a.net.URIS yntaxExcep tion; | |
32 | import jav a.net.URI; | |
33 | import jav a.net.URL; | |
34 | import jav a.net.URLC onnection; | |
35 | ||
36 | import com .sun.org.a pache.xml. internal.s ecurity.si gnature.XM LSignature Input; | |
37 | import com .sun.org.a pache.xml. internal.s ecurity.ut ils.Base64 ; | |
38 | import com .sun.org.a pache.xml. internal.s ecurity.ut ils.resolv er.Resourc eResolverC ontext; | |
39 | import com .sun.org.a pache.xml. internal.s ecurity.ut ils.resolv er.Resourc eResolverE xception; | |
40 | import com .sun.org.a pache.xml. internal.s ecurity.ut ils.resolv er.Resourc eResolverS pi; | |
41 | ||
42 | /** | |
43 | * A simpl e Resource Resolver f or HTTP re quests. Th is class h andles onl y 'pure' | |
44 | * HTTP UR Is which m eans witho ut a fragm ent. The F ragment ha ndling is done by th e | |
45 | * {@link ResolverFr agment} cl ass. | |
46 | * <BR> | |
47 | * If the user has a corporate HTTP prox y which is to be use d, the usa ge can be | |
48 | * switche d on by se tting prop erties for the resol ver: | |
49 | * <PRE> | |
50 | * resourc eResolver. setPropert y("http.pr oxy.host", "proxy.co mpany.com" ); | |
51 | * resourc eResolver. setPropert y("http.pr oxy.port", "8080"); | |
52 | * | |
53 | * // if w e need a p assword fo r the prox y | |
54 | * resourc eResolver. setPropert y("http.pr oxy.userna me", "prox yuser3"); | |
55 | * resourc eResolver. setPropert y("http.pr oxy.passwo rd", " PW ca"); | |
56 | * </PRE> | |
57 | * | |
58 | * @see <A HREF="htt p://www.ja vaworld.co m/javaworl d/javatips /jw-javati p42_p.html ">Java Tip 42: Write Java apps that work with prox y-based fi rewalls</A > | |
59 | * @see <A HREF="htt ps://docs. oracle.com /javase/1. 4.2/docs/g uide/net/p roperties. html">SUN J2SE docs for networ k properti es</A> | |
60 | * @see <A HREF="htt p://metala b.unc.edu/ javafaq/ja vafaq.html #proxy">Th e JAVA FAQ Question 9.5: How d o I make J ava work w ith a prox y server?< /A> | |
61 | */ | |
62 | public cla ss Resolve rDirectHTT P extends ResourceRe solverSpi { | |
63 | ||
64 | /** {@ link org.a pache.comm ons.loggin g} logging facility */ | |
65 | privat e static j ava.util.l ogging.Log ger log = | |
66 | ja va.util.lo gging.Logg er.getLogg er(Resolve rDirectHTT P.class.ge tName()); | |
67 | ||
68 | /** Fi eld proper ties[] */ | |
69 | privat e static f inal Strin g properti es[] = { | |
70 | " http.proxy .host", "h ttp.proxy. port", | |
71 | " http.proxy .username" , "http.pr oxy.passwo rd", | |
72 | " http.basic .username" , "http.ba sic.passwo rd" | |
73 | }; | |
74 | ||
75 | /** Fi eld HttpPr oxyHost */ | |
76 | privat e static f inal int H ttpProxyHo st = 0; | |
77 | ||
78 | /** Fi eld HttpPr oxyPort */ | |
79 | private st atic final int HttpP roxyP ORT
|
|
80 | ||
81 | /** Fi eld HttpPr oxyUser */ | |
82 | privat e static f inal int H ttpProxyUs er = 2; | |
83 | ||
84 | /** Fi eld HttpPr oxyPass */ | |
85 | privat e static f inal int H ttpProxyPa ss = 3; | |
86 | ||
87 | /** Fi eld HttpPr oxyUser */ | |
88 | privat e static f inal int H ttpBasicUs er = 4; | |
89 | ||
90 | /** Fi eld HttpPr oxyPass */ | |
91 | privat e static f inal int H ttpBasicPa ss = 5; | |
92 | ||
93 | @Overr ide | |
94 | public boolean e ngineIsThr eadSafe() { | |
95 | re turn true; | |
96 | } | |
97 | ||
98 | /** | |
99 | * Met hod resolv e | |
100 | * | |
101 | * @pa ram uri | |
102 | * @pa ram baseUR I | |
103 | * | |
104 | * @th rows Resou rceResolve rException | |
105 | * @re turn | |
106 | * $to do$ calcul ate the co rrect URI from the a ttribute a nd the bas eURI | |
107 | */ | |
108 | @Overr ide | |
109 | public XMLSignat ureInput e ngineResol veURI(Reso urceResolv erContext context) | |
110 | th rows Resou rceResolve rException { | |
111 | tr y { | |
112 | ||
113 | // calcu late new U RI | |
114 | URI uriN ew = getNe wURI(conte xt.uriToRe solve, con text.baseU ri); | |
115 | URL url = uriNew.t oURL(); | |
116 | URLConne ction urlC onnection; | |
117 | urlConne ction = op enConnecti on(url); | |
118 | ||
119 | // check if Basic authentica tion is re quired | |
120 | String a uth = urlC onnection. getHeaderF ield("WWW- Authentica te"); | |
121 | ||
122 | if (auth != null & & auth.sta rtsWith("B asic")) { | |
123 | // d o http bas ic authent ication | |
124 | Stri ng user = | |
125 | engineGetP roperty(Re solverDire ctHTTP.pro perties[Re solverDire ctHTTP.Htt pBasicUser ]); | |
126 | Stri ng pass = | |
127 | engineGetP roperty(Re solverDire ctHTTP.pro perties[Re solverDire ctHTTP.Htt pBasicPass ]); | |
128 | ||
129 | if ( (user != n ull) && (p ass != nul l)) { | |
130 | urlConnect ion = open Connection (url); | |
131 | ||
132 | String pas sword = us er + ":" + pass; | |
133 | String enc odedPasswo rd = Base6 4.encode(p assword.ge tBytes("IS O-8859-1") ); | |
134 | ||
135 | // set aut henticatio n property in the ht tp header | |
136 | urlConnect ion.setReq uestProper ty("Author ization", | |
137 | "Basic " + encode dPassword) ; | |
138 | } | |
139 | } | |
140 | ||
141 | String m imeType = urlConnect ion.getHea derField(" Content-Ty pe"); | |
142 | InputStr eam inputS tream = ur lConnectio n.getInput Stream(); | |
143 | ByteArra yOutputStr eam baos = new ByteA rrayOutput Stream(); | |
144 | byte buf [] = new b yte[4096]; | |
145 | int read = 0; | |
146 | int summ arized = 0 ; | |
147 | ||
148 | while (( read = inp utStream.r ead(buf)) >= 0) { | |
149 | baos .write(buf , 0, read) ; | |
150 | summ arized += read; | |
151 | } | |
152 | ||
153 | if (log. isLoggable (java.util .logging.L evel.FINE) ) { | |
154 | log. log(java.u til.loggin g.Level.FI NE, "Fetch ed " + sum marized + " bytes fr om URI " + uriNew.to String()); | |
155 | } | |
156 | ||
157 | XMLSigna tureInput result = n ew XMLSign atureInput (baos.toBy teArray()) ; | |
158 | ||
159 | result.s etSourceUR I(uriNew.t oString()) ; | |
160 | result.s etMIMEType (mimeType) ; | |
161 | ||
162 | return r esult; | |
163 | } catch (URI SyntaxExce ption ex) { | |
164 | throw ne w Resource ResolverEx ception("g eneric.Emp tyMessage" , ex, cont ext.attr, context.ba seUri); | |
165 | } catch (Mal formedURLE xception e x) { | |
166 | throw ne w Resource ResolverEx ception("g eneric.Emp tyMessage" , ex, cont ext.attr, context.ba seUri); | |
167 | } catch (IOE xception e x) { | |
168 | throw ne w Resource ResolverEx ception("g eneric.Emp tyMessage" , ex, cont ext.attr, context.ba seUri); | |
169 | } catch (Ill egalArgume ntExceptio n e) { | |
170 | throw ne w Resource ResolverEx ception("g eneric.Emp tyMessage" , e, conte xt.attr, c ontext.bas eUri); | |
171 | } | |
172 | } | |
173 | ||
174 | privat e URLConne ction open Connection (URL url) throws IOE xception { | |
175 | ||
176 | St ring proxy HostProp = | |
177 | engi neGetPrope rty(Resolv erDirectHT TP.propert ies[Resolv erDirectHT TP.HttpPro xyHost]); | |
178 | St ring proxy PortProp = | |
179 | engi neGetPrope rty(Resolv erDirectHT TP.propert ies[Resolv erDirectHT TP.HttpPro xyPort]); | |
180 | St ring proxy User = | |
181 | engi neGetPrope rty(Resolv erDirectHT TP.propert ies[Resolv erDirectHT TP.HttpPro xyUser]); | |
182 | St ring proxy Pass = | |
183 | engi neGetPrope rty(Resolv erDirectHT TP.propert ies[Resolv erDirectHT TP.HttpPro xyPass]); | |
184 | ||
185 | Pr oxy proxy = null; | |
186 | if ((proxyHo stProp != null) && ( proxyPortP rop != nul l)) { | |
187 | int port = Integer .parseInt( proxyPortP rop); | |
188 | proxy = new Proxy( Proxy.Type .HTTP, new InetSocke tAddress(p roxyHostPr op, port)) ; | |
189 | } | |
190 | ||
191 | UR LConnectio n urlConne ction; | |
192 | if (proxy != null) { | |
193 | urlConne ction = ur l.openConn ection(pro xy); | |
194 | ||
195 | if ((pro xyUser != null) && ( proxyPass != null)) { | |
196 | Stri ng passwor d = proxyU ser + ":" + proxyPas s; | |
197 | Stri ng authStr ing = "Bas ic " + Bas e64.encode (password. getBytes(" ISO-8859-1 ")); | |
198 | ||
199 | urlC onnection. setRequest Property(" Proxy-Auth orization" , authStri ng); | |
200 | } | |
201 | } else { | |
202 | urlConne ction = ur l.openConn ection(); | |
203 | } | |
204 | ||
205 | re turn urlCo nnection; | |
206 | } | |
207 | ||
208 | /** | |
209 | * We resolve ht tp URIs <I >without</ I> fragmen t... | |
210 | * | |
211 | * @pa ram uri | |
212 | * @pa ram baseUR I | |
213 | * @re turn true if can be resolved | |
214 | */ | |
215 | public boolean e ngineCanRe solveURI(R esourceRes olverConte xt context ) { | |
216 | if (context. uriToResol ve == null ) { | |
217 | if (log. isLoggable (java.util .logging.L evel.FINE) ) { | |
218 | log. log(java.u til.loggin g.Level.FI NE, "quick fail, uri == null") ; | |
219 | } | |
220 | return f alse; | |
221 | } | |
222 | ||
223 | if (context. uriToResol ve.equals( "") || (co ntext.uriT oResolve.c harAt(0)== '#')) { | |
224 | if (log. isLoggable (java.util .logging.L evel.FINE) ) { | |
225 | log. log(java.u til.loggin g.Level.FI NE, "quick fail for empty URIs and local ones"); | |
226 | } | |
227 | return f alse; | |
228 | } | |
229 | ||
230 | if (log.isLo ggable(jav a.util.log ging.Level .FINE)) { | |
231 | log.log( java.util. logging.Le vel.FINE, "I was ask ed whether I can res olve " + c ontext.uri ToResolve) ; | |
232 | } | |
233 | ||
234 | if (context. uriToResol ve.startsW ith("http: ") || | |
235 | (context .baseUri ! = null && context.ba seUri.star tsWith("ht tp:") )) { | |
236 | if (log. isLoggable (java.util .logging.L evel.FINE) ) { | |
237 | log. log(java.u til.loggin g.Level.FI NE, "I sta te that I can resolv e " + cont ext.uriToR esolve); | |
238 | } | |
239 | return t rue; | |
240 | } | |
241 | ||
242 | if (log.isLo ggable(jav a.util.log ging.Level .FINE)) { | |
243 | log.log( java.util. logging.Le vel.FINE, "I state t hat I can' t resolve " + contex t.uriToRes olve); | |
244 | } | |
245 | ||
246 | re turn false ; | |
247 | } | |
248 | ||
249 | /** | |
250 | * @in heritDoc | |
251 | */ | |
252 | public String[] engineGetP ropertyKey s() { | |
253 | re turn Resol verDirectH TTP.proper ties.clone (); | |
254 | } | |
255 | ||
256 | privat e static U RI getNewU RI(String uri, Strin g baseURI) throws UR ISyntaxExc eption { | |
257 | UR I newUri = null; | |
258 | if (baseURI == null || "".equals (baseURI)) { | |
259 | newUri = new URI(u ri); | |
260 | } else { | |
261 | newUri = new URI(b aseURI).re solve(uri) ; | |
262 | } | |
263 | ||
264 | // if the UR I contains a fragmen t, ignore it | |
265 | if (newUri.g etFragment () != null ) { | |
266 | URI uriN ewNoFrag = | |
267 | new URI(newUri .getScheme (), newUri .getScheme SpecificPa rt(), null ); | |
268 | return u riNewNoFra g; | |
269 | } | |
270 | re turn newUr i; | |
271 | } | |
272 | ||
273 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.