8207846: Generalize the jdk.net.includeInExceptions security property
Reviewed-by: alanb, michaelm, rriggs, mullan
This commit is contained in:
parent
eec8b3b9a8
commit
1b1355c222
@ -44,7 +44,7 @@ public final class SocketExceptions {
|
|||||||
* The property value is a comma separated list of
|
* The property value is a comma separated list of
|
||||||
* case insignificant category names.
|
* case insignificant category names.
|
||||||
*/
|
*/
|
||||||
private static final String enhancedTextPropname = "jdk.net.includeInExceptions";
|
private static final String enhancedTextPropname = "jdk.includeInExceptions";
|
||||||
|
|
||||||
private static final boolean enhancedExceptionText = initTextProp();
|
private static final boolean enhancedExceptionText = initTextProp();
|
||||||
|
|
||||||
|
@ -1061,14 +1061,22 @@ jceks.key.serialFilter = java.base/java.lang.Enum;java.base/java.security.KeyRep
|
|||||||
java.base/java.security.KeyRep$Type;java.base/javax.crypto.spec.SecretKeySpec;!*
|
java.base/java.security.KeyRep$Type;java.base/javax.crypto.spec.SecretKeySpec;!*
|
||||||
|
|
||||||
#
|
#
|
||||||
# Enhanced exception message text
|
# Enhanced exception message information
|
||||||
#
|
#
|
||||||
# By default, socket exception messages do not include potentially sensitive
|
# By default, exception messages should not include potentially sensitive
|
||||||
# information such as hostnames or port numbers. This property may be set to one
|
# information such as file names, host names, or port numbers. This property
|
||||||
# or more values, separated by commas, and with no white-space. Each value
|
# accepts one or more comma separated values, each of which represents a
|
||||||
# represents a category of enhanced information. Currently, the only category defined
|
# category of enhanced exception message information to enable. Values are
|
||||||
# is "hostInfo" which enables more detailed information in the IOExceptions
|
# case-insensitive. Leading and trailing whitespaces, surrounding each value,
|
||||||
# thrown by java.net.Socket and also the socket types in the java.nio.channels package.
|
# are ignored. Unknown values are ignored.
|
||||||
# The setting in this file can be overridden by a system property of the same name
|
#
|
||||||
# and with the same syntax and possible values.
|
# The categories are:
|
||||||
#jdk.net.includeInExceptions=hostInfo
|
#
|
||||||
|
# hostInfo - IOExceptions thrown by java.net.Socket and the socket types in the
|
||||||
|
# java.nio.channels package will contain enhanced exception
|
||||||
|
# message information
|
||||||
|
#
|
||||||
|
# The property setting in this file can be overridden by a system property of
|
||||||
|
# the same name, with the same syntax and possible values.
|
||||||
|
#
|
||||||
|
#jdk.includeInExceptions=hostInfo
|
||||||
|
@ -25,18 +25,43 @@
|
|||||||
* @test
|
* @test
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @build jdk.test.lib.Utils
|
* @build jdk.test.lib.Utils
|
||||||
* @bug 8204233
|
* @bug 8204233 8207846
|
||||||
* @summary Add configurable option for enhanced socket IOException messages
|
* @summary Add configurable option for enhanced socket IOException messages
|
||||||
* @run main/othervm ExceptionText
|
* @run main/othervm
|
||||||
* @run main/othervm -Djdk.net.includeInExceptions= ExceptionText
|
* ExceptionText
|
||||||
* @run main/othervm -Djdk.net.includeInExceptions=hostInfo ExceptionText
|
* WITHOUT_Enhanced_Text
|
||||||
* @run main/othervm -Djdk.net.includeInExceptions=somethingElse ExceptionText
|
* @run main/othervm
|
||||||
|
* -Djdk.includeInExceptions=
|
||||||
|
* ExceptionText
|
||||||
|
* WITHOUT_Enhanced_Text
|
||||||
|
* @run main/othervm
|
||||||
|
* -Djdk.includeInExceptions=somethingElse
|
||||||
|
* ExceptionText
|
||||||
|
* WITHOUT_Enhanced_Text
|
||||||
|
* @run main/othervm
|
||||||
|
* -Djdk.includeInExceptions=blah,blah,blah,
|
||||||
|
* ExceptionText
|
||||||
|
* WITHOUT_Enhanced_Text
|
||||||
|
* @run main/othervm
|
||||||
|
* -Djdk.includeInExceptions=hostInfo
|
||||||
|
* ExceptionText
|
||||||
|
* expectEnhancedText
|
||||||
|
* @run main/othervm
|
||||||
|
* -Djdk.includeInExceptions=foo,hostinfo,bar
|
||||||
|
* ExceptionText
|
||||||
|
* expectEnhancedText
|
||||||
|
* @run main/othervm
|
||||||
|
* -Djdk.includeInExceptions=",HOSTINFO,"
|
||||||
|
* ExceptionText
|
||||||
|
* expectEnhancedText
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.net.*;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.nio.channels.AsynchronousSocketChannel;
|
||||||
import java.nio.channels.ClosedChannelException;
|
import java.nio.channels.ClosedChannelException;
|
||||||
import java.nio.channels.*;
|
import java.nio.channels.SocketChannel;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import jdk.test.lib.Utils;
|
import jdk.test.lib.Utils;
|
||||||
|
|
||||||
@ -44,16 +69,15 @@ public class ExceptionText {
|
|||||||
|
|
||||||
enum TestTarget {SOCKET, CHANNEL, ASYNC_CHANNEL};
|
enum TestTarget {SOCKET, CHANNEL, ASYNC_CHANNEL};
|
||||||
|
|
||||||
static boolean propEnabled() {
|
|
||||||
String val = System.getProperty("jdk.net.includeInExceptions");
|
|
||||||
if ("hostinfo".equalsIgnoreCase(val))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String args[]) throws Exception {
|
public static void main(String args[]) throws Exception {
|
||||||
boolean prop = propEnabled();
|
String passOrFail = args[0];
|
||||||
test(prop);
|
boolean expectEnhancedText;
|
||||||
|
if (passOrFail.equals("expectEnhancedText")) {
|
||||||
|
expectEnhancedText = true;
|
||||||
|
} else {
|
||||||
|
expectEnhancedText = false;
|
||||||
|
}
|
||||||
|
test(expectEnhancedText);
|
||||||
}
|
}
|
||||||
|
|
||||||
static final InetSocketAddress dest = Utils.refusingEndpoint();
|
static final InetSocketAddress dest = Utils.refusingEndpoint();
|
||||||
|
Loading…
Reference in New Issue
Block a user