org.apache.commons.ssl
Class Certificates

java.lang.Object
  extended by org.apache.commons.ssl.Certificates

public class Certificates
extends Object

Since:
19-Aug-2005
Author:
Credit Union Central of British Columbia, www.cucbc.com, juliusdavies@cucbc.com

Nested Class Summary
private static class Certificates.CRLHolder
           
static interface Certificates.SerializableComparator
           
 
Field Summary
static CertificateFactory CF
           
static Certificates.SerializableComparator COMPARE_BY_EXPIRY
           
private static HashMap crl_cache
           
static String CRL_EXTENSION
           
private static DateFormat DF
           
static String LINE_ENDING
           
static String OCSP_EXTENSION
           
 
Constructor Summary
Certificates()
           
 
Method Summary
static void checkCRL(X509Certificate cert)
           
static String getCN(X509Certificate cert)
           
static String[] getCNs(X509Certificate cert)
           
static List getCRLs(X509Extension cert)
           
static String[] getDNSSubjectAlts(X509Certificate cert)
          Extracts the array of SubjectAlt DNS names from an X509Certificate.
static BigInteger getFingerprint(byte[] x509)
           
static BigInteger getFingerprint(X509Certificate x509)
           
static void main(String[] args)
           
static String toPEMString(X509Certificate cert)
           
static String toString(byte[] x509Encoded)
           
static String toString(X509Certificate cert)
           
static String toString(X509Certificate cert, boolean htmlStyle)
           
static Certificate[] trimChain(Certificate[] chain)
          Trims off any null entries on the array.
static X509Certificate[] x509ifyChain(Certificate[] chain)
          Returns a chain of type X509Certificate[].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CF

public static final CertificateFactory CF

LINE_ENDING

public static final String LINE_ENDING

crl_cache

private static final HashMap crl_cache

CRL_EXTENSION

public static final String CRL_EXTENSION
See Also:
Constant Field Values

OCSP_EXTENSION

public static final String OCSP_EXTENSION
See Also:
Constant Field Values

DF

private static final DateFormat DF

COMPARE_BY_EXPIRY

public static final Certificates.SerializableComparator COMPARE_BY_EXPIRY
Constructor Detail

Certificates

public Certificates()
Method Detail

toPEMString

public static String toPEMString(X509Certificate cert)
                          throws CertificateEncodingException
Throws:
CertificateEncodingException

toString

public static String toString(byte[] x509Encoded)

toString

public static String toString(X509Certificate cert)

toString

public static String toString(X509Certificate cert,
                              boolean htmlStyle)

getCRLs

public static List getCRLs(X509Extension cert)

checkCRL

public static void checkCRL(X509Certificate cert)
                     throws CertificateException
Throws:
CertificateException

getFingerprint

public static BigInteger getFingerprint(X509Certificate x509)
                                 throws CertificateEncodingException
Throws:
CertificateEncodingException

getFingerprint

public static BigInteger getFingerprint(byte[] x509)
                                 throws CertificateEncodingException
Throws:
CertificateEncodingException

getCN

public static String getCN(X509Certificate cert)

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.

trimChain

public static Certificate[] trimChain(Certificate[] chain)
Trims off any null entries on the array. Returns a shrunk array.

Parameters:
chain - X509Certificate[] chain to trim
Returns:
Shrunk array with all trailing null entries removed.

x509ifyChain

public static X509Certificate[] x509ifyChain(Certificate[] chain)
Returns a chain of type X509Certificate[].

Parameters:
chain - Certificate[] chain to cast to X509Certificate[]
Returns:
chain of type X509Certificate[].

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception