< prev index next >
test/jdk/sun/security/ssl/SSLEngineImpl/EngineEnforceUseClientMode.java
Print this page
@@ -105,14 +105,13 @@
ssle3.wrap(appOut1, oneToTwo);
throw new RuntimeException(
"wrap(): Didn't catch the exception properly");
} catch (IllegalStateException e) {
System.out.println("Caught the correct exception.");
- ssle3.wrap(appOut1, oneToTwo);
oneToTwo.flip();
if (oneToTwo.hasRemaining()) {
- throw new Exception("wrap1 generated data");
+ throw new Exception("wrap generated data");
}
oneToTwo.clear();
}
try {
@@ -120,31 +119,24 @@
ssle4.unwrap(oneToTwo, appIn1);
throw new RuntimeException(
"unwrap(): Didn't catch the exception properly");
} catch (IllegalStateException e) {
System.out.println("Caught the correct exception.");
- ssle4.wrap(appOut1, oneToTwo);
- oneToTwo.flip();
- if (oneToTwo.hasRemaining()) {
- throw new Exception("wrap2 generated data");
+ appIn1.flip();
+ if (appIn1.hasRemaining()) {
+ throw new Exception("unwrap generated data");
}
- oneToTwo.clear();
+ appIn1.clear();
}
try {
System.out.println("Testing beginHandshake()");
ssle5.beginHandshake();
throw new RuntimeException(
"unwrap(): Didn't catch the exception properly");
} catch (IllegalStateException e) {
System.out.println("Caught the correct exception.");
- ssle5.wrap(appOut1, oneToTwo);
- oneToTwo.flip();
- if (oneToTwo.hasRemaining()) {
- throw new Exception("wrap3 generated data");
- }
- oneToTwo.clear();
}
boolean dataDone = false;
SSLEngineResult result1; // ssle1's results from last operation
@@ -198,11 +190,11 @@
checkTransfer(appOut1, appIn2);
checkTransfer(appOut2, appIn1);
System.out.println("Try changing modes...");
try {
- ssle2.setUseClientMode(false);
+ ssle2.setUseClientMode(true);
throw new RuntimeException(
"setUseClientMode(): " +
"Didn't catch the exception properly");
} catch (IllegalArgumentException e) {
System.out.println("Caught the correct exception.");
@@ -309,12 +301,14 @@
throw new Exception("Data didn't transfer cleanly");
} else {
log("Data transferred cleanly");
}
- a.clear();
- b.clear();
+ a.position(a.limit());
+ b.position(b.limit());
+ a.limit(a.capacity());
+ b.limit(b.capacity());
}
private static void log(String str) {
if (debug) {
System.out.println(str);
< prev index next >