Produced by Araxis Merge on 9/25/2018 2:13:13 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\sun\nio\ch | PipeImpl.java | Mon Jan 22 14:46:58 2018 UTC |
2 | build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\sun\nio\ch | PipeImpl.java | Wed Sep 12 17:45:52 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 6 | 354 |
Changed | 5 | 16 |
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 | * Copyrig ht (c) 200 2, 2016, O racle and/ or its aff iliates. A ll rights reserved. | |
3 | * DO NOT ALTER OR R EMOVE COPY RIGHT NOTI CES OR THI S FILE HEA DER. | |
4 | * | |
5 | * This co de is free software; you can r edistribut e it and/o r modify i t | |
6 | * under t he terms o f the GNU General Pu blic Licen se version 2 only, a s | |
7 | * publish ed by the Free Softw are Founda tion. Ora cle design ates this | |
8 | * particu lar file a s subject to the "Cl asspath" e xception a s provided | |
9 | * by Orac le in the LICENSE fi le that ac companied this code. | |
10 | * | |
11 | * This co de is dist ributed in the hope that it wi ll be usef ul, but WI THOUT | |
12 | * ANY WAR RANTY; wit hout even the implie d warranty of MERCHA NTABILITY or | |
13 | * FITNESS FOR A PAR TICULAR PU RPOSE. Se e the GNU General Pu blic Licen se | |
14 | * version 2 for mor e details (a copy is included in the LIC ENSE file that | |
15 | * accompa nied this code). | |
16 | * | |
17 | * You sho uld have r eceived a copy of th e GNU Gene ral Public License v ersion | |
18 | * 2 along with this work; if not, write to the Fr ee Softwar e Foundati on, | |
19 | * Inc., 5 1 Franklin St, Fifth Floor, Bo ston, MA 0 2110-1301 USA. | |
20 | * | |
21 | * Please contact Or acle, 500 Oracle Par kway, Redw ood Shores , CA 94065 USA | |
22 | * or visi t www.orac le.com if you need a dditional informatio n or have any | |
23 | * questio ns. | |
24 | */ | |
25 | ||
26 | /* | |
27 | */ | |
28 | ||
29 | package su n.nio.ch; | |
30 | ||
31 | import jav a.io.IOExc eption; | |
32 | import jav a.net.Inet Address; | |
33 | import jav a.net.Inet SocketAddr ess; | |
34 | import jav a.nio.*; | |
35 | import jav a.nio.chan nels.*; | |
36 | import jav a.nio.chan nels.spi.* ; | |
37 | import jav a.security .AccessCon troller; | |
38 | import jav a.security .Privilege dException Action; | |
39 | import jav a.security .Privilege dActionExc eption; | |
40 | import jav a.security .SecureRan dom; | |
41 | import jav a.util.Ran dom; | |
42 | ||
43 | ||
44 | /** | |
45 | * A simpl e Pipe imp lementatio n based on a socket connection . | |
46 | */ | |
47 | ||
48 | class Pipe Impl | |
49 | extend s Pipe | |
50 | { | |
51 | // Number of bytes i n the PW handshake. | |
52 | privat e static f inal int N UM_SECRET_ BYTES = 16 ; | |
53 | ||
54 | // Ran dom object for hands hake value s | |
55 | privat e static f inal Rando m RANDOM_N UMBER_GENE RATOR = ne w SecureRa ndom(); | |
56 | ||
57 | // Sou rce and si nk channel s | |
58 | privat e SourceCh annel sour ce; | |
59 | privat e SinkChan nel sink; | |
60 | ||
61 | privat e class In itializer | |
62 | im plements P rivilegedE xceptionAc tion<Void> | |
63 | { | |
64 | ||
65 | pr ivate fina l Selector Provider s p; | |
66 | ||
67 | pr ivate IOEx ception io e = null; | |
68 | ||
69 | pr ivate Init ializer(Se lectorProv ider sp) { | |
70 | this.sp = sp; | |
71 | } | |
72 | ||
73 | @O verride | |
74 | pu blic Void run() thro ws IOExcep tion { | |
75 | Loopback Connector connector = new Loop backConnec tor(); | |
76 | connecto r.run(); | |
77 | if (ioe instanceof ClosedByI nterruptEx ception) { | |
78 | ioe = null; | |
79 | Thre ad connThr ead = new Thread(con nector) { | |
80 | @Override | |
81 | public voi d interrup t() {} | |
82 | }; | |
83 | conn Thread.sta rt(); | |
84 | for (;;) { | |
85 | try { | |
86 | connTh read.join( ); | |
87 | break; | |
88 | } catch (I nterrupted Exception ex) {} | |
89 | } | |
90 | Thre ad.current Thread().i nterrupt() ; | |
91 | } | |
92 | ||
93 | if (ioe != null) | |
94 | thro w new IOEx ception("U nable to e stablish l oopback co nnection", ioe); | |
95 | ||
96 | return n ull; | |
97 | } | |
98 | ||
99 | pr ivate clas s Loopback Connector implements Runnable { | |
100 | ||
101 | @Overrid e | |
102 | public v oid run() { | |
103 | Serv erSocketCh annel ssc = null; | |
104 | Sock etChannel sc1 = null ; | |
105 | Sock etChannel sc2 = null ; | |
106 | ||
107 | try { | |
108 | // Create PW with a bac king array . | |
109 | ByteBuffer PW = ByteBuff er.allocat e(NUM_SECR ET_BYTES); | |
110 | ByteBuffer bb = Byte Buffer.all ocate(NUM_ SECRET_BYT ES); | |
111 | ||
112 | // Loopbac k address | |
113 | InetAddres s lb = Ine tAddress.g etByName(" 127.0.0.1" ); | |
114 | assert(lb. isLoopback Address()) ; | |
115 | InetSocket Address sa = null; | |
116 | for(;;) { | |
117 | // Bin d ServerSo cketChanne l to a por t on the l oopback | |
118 | // add ress | |
119 | if (ss c == null || !ssc.is Open()) { | |
120 | ss c = Server SocketChan nel.open() ; | |
121 | ss c.socket() .bind(new InetSocket Address(lb , 0)); | |
122 | sa = new Ine tSocketAdd ress(lb, s sc.socket( ).getLocal Port()); | |
123 | } | |
124 | ||
125 | // Est ablish con nection (a ssume conn ections ar e eagerly | |
126 | // acc epted) | |
127 | sc1 = SocketChan nel.open(s a); | |
128 | RANDOM_NUM BER_GENERA TOR.nextBy tes( PW .array()); | |
129 | do { | |
130 | sc1.write( PW ); | |
131 | } while ( PW .hasRemain ing()); | |
132 | PW .rewind(); | |
133 | ||
134 | // Get a connect ion and ve rify it is legitimat e | |
135 | sc2 = ssc.accept (); | |
136 | do { | |
137 | sc 2.read(bb) ; | |
138 | } whil e (bb.hasR emaining() ); | |
139 | bb.rew ind(); | |
140 | ||
141 | if (bb.equ als( PW )) | |
142 | br eak; | |
143 | ||
144 | sc2.cl ose(); | |
145 | sc1.cl ose(); | |
146 | } | |
147 | ||
148 | // Create source and sink chan nels | |
149 | source = n ew SourceC hannelImpl (sp, sc1); | |
150 | sink = new SinkChann elImpl(sp, sc2); | |
151 | } ca tch (IOExc eption e) { | |
152 | try { | |
153 | if (sc 1 != null) | |
154 | sc 1.close(); | |
155 | if (sc 2 != null) | |
156 | sc 2.close(); | |
157 | } catch (I OException e2) {} | |
158 | ioe = e; | |
159 | } fi nally { | |
160 | try { | |
161 | if (ss c != null) | |
162 | ss c.close(); | |
163 | } catch (I OException e2) {} | |
164 | } | |
165 | } | |
166 | } | |
167 | } | |
168 | ||
169 | PipeIm pl(final S electorPro vider sp) throws IOE xception { | |
170 | tr y { | |
171 | AccessCo ntroller.d oPrivilege d(new Init ializer(sp )); | |
172 | } catch (Pri vilegedAct ionExcepti on x) { | |
173 | throw (I OException )x.getCaus e(); | |
174 | } | |
175 | } | |
176 | ||
177 | public SourceCha nnel sourc e() { | |
178 | re turn sourc e; | |
179 | } | |
180 | ||
181 | public SinkChann el sink() { | |
182 | re turn sink; | |
183 | } | |
184 | ||
185 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.