1 /* |
1 /* |
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
43 import javax.net.ssl.SSLEngineResult.*; |
43 import javax.net.ssl.SSLEngineResult.*; |
44 import java.io.*; |
44 import java.io.*; |
45 import java.security.*; |
45 import java.security.*; |
46 import java.nio.*; |
46 import java.nio.*; |
47 |
47 |
|
48 // Note that this test case depends on JSSE provider implementation details. |
48 public class CloseEngineException { |
49 public class CloseEngineException { |
49 |
50 |
50 private static boolean debug = false; |
51 private static boolean debug = true; |
51 |
52 |
52 private SSLContext sslc; |
53 private SSLContext sslc; |
53 private SSLEngine ssle1; // client |
54 private SSLEngine ssle1; // client |
54 private SSLEngine ssle2; // server |
55 private SSLEngine ssle2; // server |
55 |
56 |
92 createBuffers(); |
93 createBuffers(); |
93 |
94 |
94 SSLEngineResult result1; // ssle1's results from last operation |
95 SSLEngineResult result1; // ssle1's results from last operation |
95 SSLEngineResult result2; // ssle2's results from last operation |
96 SSLEngineResult result2; // ssle2's results from last operation |
96 |
97 |
97 while (!isEngineClosed(ssle1) || !isEngineClosed(ssle2)) { |
98 while (!isEngineClosed(ssle1) && !isEngineClosed(ssle2)) { |
98 |
99 |
99 log("================"); |
100 log("================"); |
100 |
101 |
101 result1 = ssle1.wrap(appOut1, oneToTwo); |
102 if (!isEngineClosed(ssle1)) { |
102 result2 = ssle2.wrap(appOut2, twoToOne); |
103 result1 = ssle1.wrap(appOut1, oneToTwo); |
103 |
104 runDelegatedTasks(result1, ssle1); |
104 log("wrap1: " + result1); |
105 |
105 log("oneToTwo = " + oneToTwo); |
106 log("wrap1: " + result1); |
106 log(""); |
107 log("oneToTwo = " + oneToTwo); |
107 |
108 log(""); |
108 log("wrap2: " + result2); |
109 |
109 log("twoToOne = " + twoToOne); |
110 oneToTwo.flip(); |
110 |
111 } |
111 runDelegatedTasks(result1, ssle1); |
112 if (!isEngineClosed(ssle2)) { |
112 runDelegatedTasks(result2, ssle2); |
113 result2 = ssle2.wrap(appOut2, twoToOne); |
113 |
114 runDelegatedTasks(result2, ssle2); |
114 oneToTwo.flip(); |
115 |
115 twoToOne.flip(); |
116 log("wrap2: " + result2); |
|
117 log("twoToOne = " + twoToOne); |
|
118 |
|
119 twoToOne.flip(); |
|
120 } |
116 |
121 |
117 log("----"); |
122 log("----"); |
118 |
123 |
119 result1 = ssle1.unwrap(twoToOne, appIn1); |
124 if (!isEngineClosed(ssle1) && !dataDone) { |
120 result2 = ssle2.unwrap(oneToTwo, appIn2); |
125 log("--"); |
121 |
126 result1 = ssle1.unwrap(twoToOne, appIn1); |
122 log("unwrap1: " + result1); |
127 runDelegatedTasks(result1, ssle1); |
123 log("twoToOne = " + twoToOne); |
128 |
124 log(""); |
129 log("unwrap1: " + result1); |
125 |
130 log("twoToOne = " + twoToOne); |
126 log("unwrap2: " + result2); |
131 log(""); |
127 log("oneToTwo = " + oneToTwo); |
132 |
128 |
133 twoToOne.compact(); |
129 runDelegatedTasks(result1, ssle1); |
134 } |
130 runDelegatedTasks(result2, ssle2); |
135 if (!isEngineClosed(ssle2)) { |
131 |
136 log("---"); |
132 oneToTwo.compact(); |
137 result2 = ssle2.unwrap(oneToTwo, appIn2); |
133 twoToOne.compact(); |
138 runDelegatedTasks(result2, ssle2); |
|
139 |
|
140 log("unwrap2: " + result2); |
|
141 log("oneToTwo = " + oneToTwo); |
|
142 |
|
143 oneToTwo.compact(); |
|
144 } |
134 |
145 |
135 /* |
146 /* |
136 * If we've transfered all the data between app1 and app2, |
147 * If we've transfered all the data between app1 and app2, |
137 * we try to close and see what that gets us. |
148 * we try to close and see what that gets us. |
138 */ |
149 */ |