TrustedHostnameVerifier

public class TrustedHostnameVerifier implements HostnameVerifier

TrustedHostnameVerifier is a HostnameVerifier which verifies the host name in an SSL session based on a list of pre-defined hostnames. If there is no such a list in this verifier, it defaults to trust any host name.

Author:Hugo Y. K. Lam

Constructors

TrustedHostnameVerifier

public TrustedHostnameVerifier()

Creates a new intance of TrustedHostnameVerifier. The verifier will be set to trust all hostnames on verification.

TrustedHostnameVerifier

public TrustedHostnameVerifier(Collection hostnames)

Creates a new intance of TrustedHostnameVerifier.

Parameters:
  • hostnames – the host names to be trusted on verification.

Methods

verify

public boolean verify(String hostname, SSLSession sslSession)

Verifies that the host name is an acceptable match with the trusted host names pre-defined in this verifier.

Parameters:
  • hostname – the host name.
  • sslSession – the SSL session used on the connection to the host.
Returns:

true if the host name is acceptable.

See also: javax.net.ssl.HostnameVerifier.verify(java.lang.String, javax.net.ssl.SSLSession)