@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class HostNameTrustManager extends java.lang.Object implements javax.net.ssl.X509TrustManager
AggregateTrustManager
in conjunction with other trust managers that
perform other forms of validation.Constructor and Description |
---|
HostNameTrustManager(boolean allowWildcards,
boolean checkCNWhenSubjectAltNameIsPresent,
java.util.Collection<java.lang.String> acceptableHostNames)
Creates a new hostname trust manager with the provided information.
|
HostNameTrustManager(boolean allowWildcards,
java.util.Collection<java.lang.String> acceptableHostNames)
Creates a new hostname trust manager with the provided information.
|
HostNameTrustManager(boolean allowWildcards,
java.lang.String... acceptableHostNames)
Creates a new hostname trust manager with the provided information.
|
Modifier and Type | Method and Description |
---|---|
boolean |
allowWildcards()
Indicates whether wildcard certificates should be allowed, which may
match multiple hosts in a given domain or subdomain.
|
void |
checkClientTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType)
Checks to determine whether the provided client certificate chain should be
trusted.
|
void |
checkServerTrusted(java.security.cert.X509Certificate[] chain,
java.lang.String authType)
Checks to determine whether the provided server certificate chain should be
trusted.
|
java.util.Set<java.lang.String> |
getAcceptableHostNames()
Retrieves the set of hostnames that will be considered acceptable.
|
java.security.cert.X509Certificate[] |
getAcceptedIssuers()
Retrieves the accepted issuer certificates for this trust manager.
|
public HostNameTrustManager(boolean allowWildcards, @NotNull java.lang.String... acceptableHostNames)
allowWildcards
- Indicates whether to allow wildcard
certificates which contain an asterisk as the
first component of a CN subject attribute or
dNSName subjectAltName extension.acceptableHostNames
- The set of hostnames and/or IP addresses that
will be considered acceptable. Only
certificates with a CN or subjectAltName value
that exactly matches one of these names
(ignoring differences in capitalization) will
be considered acceptable. It must not be
null
or empty.public HostNameTrustManager(boolean allowWildcards, @NotNull java.util.Collection<java.lang.String> acceptableHostNames)
allowWildcards
- Indicates whether to allow wildcard
certificates which contain an asterisk as the
first component of a CN subject attribute or
dNSName subjectAltName extension.acceptableHostNames
- The set of hostnames and/or IP addresses that
will be considered acceptable. Only
certificates with a CN or subjectAltName value
that exactly matches one of these names
(ignoring differences in capitalization) will
be considered acceptable. It must not be
null
or empty.public HostNameTrustManager(boolean allowWildcards, boolean checkCNWhenSubjectAltNameIsPresent, @NotNull java.util.Collection<java.lang.String> acceptableHostNames)
allowWildcards
- Indicates whether to allow wildcard certificates that contain
an asterisk in the leftmost component of a hostname in the
dNSName or uniformResourceIdentifier of the subject
alternative name extension, or in the CN attribute of the
subject DN.checkCNWhenSubjectAltNameIsPresent
- Indicates whether to check the CN attribute in the peer
certificate's subject DN if the certificate also contains a
subject alternative name extension that contains at least one
dNSName, uniformResourceIdentifier, or iPAddress value.
Although RFC 6125 section 6.4.4 indicates that the CN
attribute should not be checked in certificates that have an
appropriate subject alternative name extension, LDAP clients
historically treat both sources as equally valid.acceptableHostNames
- The set of hostnames and/or IP addresses that will be
considered acceptable. Only certificates with a CN or
subjectAltName value that exactly matches one of these names
(ignoring differences in capitalization) will be considered
acceptable. It must not be null
or empty.public boolean allowWildcards()
true
if wildcard certificates should be allowed, or
false
if not.@NotNull public java.util.Set<java.lang.String> getAcceptableHostNames()
public void checkClientTrusted(@NotNull java.security.cert.X509Certificate[] chain, @NotNull java.lang.String authType) throws java.security.cert.CertificateException
checkClientTrusted
in interface javax.net.ssl.X509TrustManager
chain
- The client certificate chain for which to make the
determination.authType
- The authentication type based on the client certificate.java.security.cert.CertificateException
- If the provided client certificate chain
should not be trusted.public void checkServerTrusted(@NotNull java.security.cert.X509Certificate[] chain, @NotNull java.lang.String authType) throws java.security.cert.CertificateException
checkServerTrusted
in interface javax.net.ssl.X509TrustManager
chain
- The server certificate chain for which to make the
determination.authType
- The key exchange algorithm used.java.security.cert.CertificateException
- If the provided server certificate chain
should not be trusted.@NotNull public java.security.cert.X509Certificate[] getAcceptedIssuers()
getAcceptedIssuers
in interface javax.net.ssl.X509TrustManager