org.apache.http.conn.ssl
Class AbstractCommonHostnameVerifier

java.lang.Object
  extended by org.apache.http.conn.ssl.AbstractBaseHostnameVerifier
      extended by org.apache.http.conn.ssl.AbstractCommonHostnameVerifier
All Implemented Interfaces:
HostnameVerifier, X509HostnameVerifier
Direct Known Subclasses:
AbstractVerifier

@Immutable
public abstract class AbstractCommonHostnameVerifier
extends AbstractBaseHostnameVerifier

/** Abstract base class for all standard X509HostnameVerifier implementations that provides methods to extract Common Name (CN) and alternative subjects (subjectAlt) from X509Certificate being validated as well as verify(String, String[], String[], boolean) method that implements common certificate subject validation logic.

Since:
4.4

Constructor Summary
AbstractCommonHostnameVerifier()
           
 
Method Summary
static boolean acceptableCountryWildcard(String cn)
          Deprecated. (4.3.1) should not be a part of public APIs.
static int countDots(String s)
          Counts the number of dots "." in a string.
static String[] getCNs(X509Certificate cert)
           
static String[] getDNSSubjectAlts(X509Certificate cert)
          Extracts the array of SubjectAlt DNS names from an X509Certificate.
 void verify(String host, String[] cns, String[] subjectAlts, boolean strictWithSubDomains)
           
 void verify(String host, X509Certificate cert)
          Verifies that the host name is an acceptable match with the server's authentication scheme based on the given X509Certificate.
 
Methods inherited from class org.apache.http.conn.ssl.AbstractBaseHostnameVerifier
verify, verify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.http.conn.ssl.X509HostnameVerifier
verify
 

Constructor Detail

AbstractCommonHostnameVerifier

public AbstractCommonHostnameVerifier()
Method Detail

verify

public final void verify(String host,
                         X509Certificate cert)
                  throws SSLException
Description copied from interface: X509HostnameVerifier
Verifies that the host name is an acceptable match with the server's authentication scheme based on the given X509Certificate.

Parameters:
host - the host.
cert - the certificate.
Throws:
SSLException - if the verification process fails.

verify

public final void verify(String host,
                         String[] cns,
                         String[] subjectAlts,
                         boolean strictWithSubDomains)
                  throws SSLException
Throws:
SSLException

acceptableCountryWildcard

@Deprecated
public static boolean acceptableCountryWildcard(String cn)
Deprecated. (4.3.1) should not be a part of public APIs.


getCNs

public static String[] getCNs(X509Certificate cert)

getDNSSubjectAlts

public static String[] getDNSSubjectAlts(X509Certificate cert)
Extracts the array of SubjectAlt DNS names from an X509Certificate. Returns null if there aren't any.

Note: Java doesn't appear able to extract international characters from the SubjectAlts. It can only extract international characters from the CN field.

(Or maybe the version of OpenSSL I'm using to test isn't storing the international characters correctly in the SubjectAlts?).

Parameters:
cert - X509Certificate
Returns:
Array of SubjectALT DNS names stored in the certificate.

countDots

public static int countDots(String s)
Counts the number of dots "." in a string.

Parameters:
s - string to count dots from
Returns:
number of dots


Copyright © 1999–2014 The Apache Software Foundation. All rights reserved.