APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.util

public final Class Exceptions

extends Object
Class Inheritance
Imports
java.io.IOException, java.lang.reflect.Constructor, java.net.InetSocketAddress, .SocketAddress, .UnixDomainSocketAddress, .URISyntaxException, java.util.Arrays, java.util.function.Consumer, java.util.stream.Stream, sun.security.util.SecurityProperties, jdk.internal.misc.VM

Contains static utility methods which can filter exception message strings for sensitive information. Code using this mechanism should use formatMsg() to generate a formatted (enhanced or restricted) string for exception messages. The methods above take variable numbers of SensitiveInfo objects as parameters which contain the text that may have to be filtered. The SensitiveInfo objects should be generated with one of the following: public static SensitiveInfo filterSocketInfo(String s) public static SensitiveInfo filterNonSocketInfo(String s) public static SensitiveInfo filterJarName(String name) public static SensitiveInfo filterUserName(String name)

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
public abstract static class
Exceptions.SensitiveInfo

Base class for generating exception messages that may contain sensitive information which in certain contexts needs to be filtered out, in case it gets revealed in unexpected places.

pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static volatile boolean
private static volatile boolean
private static volatile boolean
private static volatile boolean
private static volatile boolean

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static <T extends Exception> T
create(T e, String msg)

public static boolean
public static boolean
public static Exceptions.SensitiveInfo
public static Exceptions.SensitiveInfo
public static Exceptions.SensitiveInfo
public static Exceptions.SensitiveInfo
public static String
formatMsg(String format, Exceptions.SensitiveInfo... infos)

Transform each SensitiveInfo into a String argument which is passed to String.format().

public static String
formatMsg(Exceptions.SensitiveInfo info)

Simplification of above.

public static IOException
ioException(IOException e, SocketAddress addr)

The enhanced message text is the socket address appended to the original IOException message

private static IOException
private static IOException
public static void
pack-priv static String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

enhancedJarExceptionTextback to summary
private static volatile boolean enhancedJarExceptionText
enhancedNonSocketExceptionTextback to summary
private static volatile boolean enhancedNonSocketExceptionText
enhancedSocketExceptionTextback to summary
private static volatile boolean enhancedSocketExceptionText
enhancedUserExceptionTextback to summary
private static volatile boolean enhancedUserExceptionText
initializedback to summary
private static volatile boolean initialized

Constructor Detail

Exceptionsback to summary
private Exceptions()

Method Detail

createback to summary
private static <T extends Exception> T create(T e, String msg)
enhancedNonSocketExceptionsback to summary
public static boolean enhancedNonSocketExceptions()
enhancedSocketExceptionsback to summary
public static boolean enhancedSocketExceptions()
filterJarNameback to summary
public static Exceptions.SensitiveInfo filterJarName(String name)
filterNonSocketInfoback to summary
public static Exceptions.SensitiveInfo filterNonSocketInfo(String host)
filterSocketInfoback to summary
public static Exceptions.SensitiveInfo filterSocketInfo(String host)
filterUserNameback to summary
public static Exceptions.SensitiveInfo filterUserName(String name)
formatMsgback to summary
public static String formatMsg(String format, Exceptions.SensitiveInfo... infos)

Transform each SensitiveInfo into a String argument which is passed to String.format(). This string is then trimmed.

formatMsgback to summary
public static String formatMsg(Exceptions.SensitiveInfo info)

Simplification of above. Equivalent to: formatMsg("%s", SensitiveInfo[1]); // ie with one arg

ioExceptionback to summary
public static IOException ioException(IOException e, SocketAddress addr)

The enhanced message text is the socket address appended to the original IOException message

ofInetback to summary
private static IOException ofInet(IOException e, InetSocketAddress addr)
ofUnixDomainback to summary
private static IOException ofUnixDomain(IOException e, UnixDomainSocketAddress addr)
setupback to summary
public static void setup()
trimback to summary
pack-priv static String trim(String s)
jdk.internal.util back to summary

pack-priv final Class Exceptions.JarInfo

extends SensitiveInfo
Class Inheritance

Field Summary

Inherited from jdk.internal.util.Exceptions.SensitiveInfo:
enhancedinfoprefixreplacementsuffix

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
output()

Implements abstract jdk.internal.util.Exceptions.SensitiveInfo.output.

Implementation should call composeFilteredText(boolean flag) where flag contains the boolean value of whether the category is enabled or not.

Inherited from jdk.internal.util.Exceptions.SensitiveInfo:
composeFilteredTextenhancedprefixWithreplaceWithsuffixWith

Constructor Detail

JarInfoback to summary
public JarInfo(String name)

Method Detail

outputback to summary
public String output()

Implements abstract jdk.internal.util.Exceptions.SensitiveInfo.output.

Doc from jdk.internal.util.Exceptions.SensitiveInfo.output.

Implementation should call composeFilteredText(boolean flag) where flag contains the boolean value of whether the category is enabled or not.

Annotations
@Override
jdk.internal.util back to summary

pack-priv final Class Exceptions.NonSocketInfo

extends SensitiveInfo
Class Inheritance

Field Summary

Inherited from jdk.internal.util.Exceptions.SensitiveInfo:
enhancedinfoprefixreplacementsuffix

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
output()

Implements abstract jdk.internal.util.Exceptions.SensitiveInfo.output.

Implementation should call composeFilteredText(boolean flag) where flag contains the boolean value of whether the category is enabled or not.

Inherited from jdk.internal.util.Exceptions.SensitiveInfo:
composeFilteredTextenhancedprefixWithreplaceWithsuffixWith

Constructor Detail

NonSocketInfoback to summary
public NonSocketInfo(String host)

Method Detail

outputback to summary
public String output()

Implements abstract jdk.internal.util.Exceptions.SensitiveInfo.output.

Doc from jdk.internal.util.Exceptions.SensitiveInfo.output.

Implementation should call composeFilteredText(boolean flag) where flag contains the boolean value of whether the category is enabled or not.

Annotations
@Override
jdk.internal.util back to summary

public abstract Class Exceptions.SensitiveInfo

extends Object
Class Inheritance
Known Direct Subclasses
jdk.internal.util.Exceptions.SocketInfo, jdk.internal.util.Exceptions.NonSocketInfo, jdk.internal.util.Exceptions.JarInfo, jdk.internal.util.Exceptions.UserInfo

Base class for generating exception messages that may contain sensitive information which in certain contexts needs to be filtered out, in case it gets revealed in unexpected places. Exception messages are either enhanced or restricted. Enhanced messages include sensitive information. Restricted messages don't. Sub-class for any new category that needs to be independently controlled. Consider using a unique value for the SecurityProperties.includedInExceptions(String value) mechanism Current values defined are "jar", "userInfo" "hostInfo", "hostInfoExclSocket". New code can also piggy back on existing categories A SensitiveInfo contains the following components all of which default to empty strings. prefix, the sensitive info itself, a suffix and a replacement string. The composeFilteredText(boolean enhance) method generates an enhanced string when enhance is true. This comprises (enhance == true) prefix + info + suffix When (enhance == false), then by default the output is: "" empty string However, if a replacement is set, then when enhance == false the output is the replacement string.

Field Summary

Modifier and TypeField and Description
pack-priv boolean
pack-priv String
pack-priv String
pack-priv String
pack-priv String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected String
composeFilteredText(boolean enhance)

public boolean
public abstract String
output()

Implementation should call composeFilteredText(boolean flag) where flag contains the boolean value of whether the category is enabled or not.

public Exceptions.SensitiveInfo
public Exceptions.SensitiveInfo
replaceWith(String replacement)

public Exceptions.SensitiveInfo
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

enhancedback to summary
pack-priv boolean enhanced
infoback to summary
pack-priv String info
prefixback to summary
pack-priv String prefix
replacementback to summary
pack-priv String replacement
suffixback to summary
pack-priv String suffix

Constructor Detail

SensitiveInfoback to summary
pack-priv SensitiveInfo(String info)

Method Detail

composeFilteredTextback to summary
protected String composeFilteredText(boolean enhance)
enhancedback to summary
public boolean enhanced()
outputback to summary
public abstract String output()

Implementation should call composeFilteredText(boolean flag) where flag contains the boolean value of whether the category is enabled or not.

prefixWithback to summary
public Exceptions.SensitiveInfo prefixWith(String prefix)
replaceWithback to summary
public Exceptions.SensitiveInfo replaceWith(String replacement)
suffixWithback to summary
public Exceptions.SensitiveInfo suffixWith(String suffix)
jdk.internal.util back to summary

pack-priv final Class Exceptions.SocketInfo

extends SensitiveInfo
Class Inheritance

Field Summary

Inherited from jdk.internal.util.Exceptions.SensitiveInfo:
enhancedinfoprefixreplacementsuffix

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
output()

Implements abstract jdk.internal.util.Exceptions.SensitiveInfo.output.

Implementation should call composeFilteredText(boolean flag) where flag contains the boolean value of whether the category is enabled or not.

Inherited from jdk.internal.util.Exceptions.SensitiveInfo:
composeFilteredTextenhancedprefixWithreplaceWithsuffixWith

Constructor Detail

SocketInfoback to summary
public SocketInfo(String host)

Method Detail

outputback to summary
public String output()

Implements abstract jdk.internal.util.Exceptions.SensitiveInfo.output.

Doc from jdk.internal.util.Exceptions.SensitiveInfo.output.

Implementation should call composeFilteredText(boolean flag) where flag contains the boolean value of whether the category is enabled or not.

Annotations
@Override
jdk.internal.util back to summary

pack-priv final Class Exceptions.UserInfo

extends SensitiveInfo
Class Inheritance

Field Summary

Inherited from jdk.internal.util.Exceptions.SensitiveInfo:
enhancedinfoprefixreplacementsuffix

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
output()

Implements abstract jdk.internal.util.Exceptions.SensitiveInfo.output.

Implementation should call composeFilteredText(boolean flag) where flag contains the boolean value of whether the category is enabled or not.

Inherited from jdk.internal.util.Exceptions.SensitiveInfo:
composeFilteredTextenhancedprefixWithreplaceWithsuffixWith

Constructor Detail

UserInfoback to summary
public UserInfo(String host)

Method Detail

outputback to summary
public String output()

Implements abstract jdk.internal.util.Exceptions.SensitiveInfo.output.

Doc from jdk.internal.util.Exceptions.SensitiveInfo.output.

Implementation should call composeFilteredText(boolean flag) where flag contains the boolean value of whether the category is enabled or not.

Annotations
@Override