tigase.cert
Class CertificateUtil

java.lang.Object
  extended by tigase.cert.CertificateUtil

public abstract class CertificateUtil
extends Object

Created: Sep 22, 2010 3:09:01 PM

Version:
$Rev: 644 $
Author:
Artur Hefczyc

Constructor Summary
CertificateUtil()
           
 
Method Summary
static KeyPair createKeyPair(int size, String password)
          Method description
static X509Certificate createSelfSignedCertificate(String email, String domain, String organizationUnit, String organization, String city, String state, String country, KeyPair keyPair)
          Method description
static String exportToPemFormat(CertificateEntry entry)
          Method description
static String getCertCName(X509Certificate cert)
          Method description
static boolean isExpired(X509Certificate cert)
          Method description
static boolean isSelfSigned(X509Certificate cert)
          Method description
static CertificateEntry loadCertificate(File file)
          Method description
static CertificateEntry loadCertificate(String file)
          Method description
static PrivateKey loadPrivateKeyFromDER(File file)
          Method description
static void main(String[] args)
          Method description
static CertificateEntry parseCertificate(Reader data)
          Method description
static void storeCertificate(String file, CertificateEntry entry)
          Method description
static CertCheckResult validateCertificate(Certificate[] chain, KeyStore trustKeystore, boolean revocationEnabled)
          Method description
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CertificateUtil

public CertificateUtil()
Method Detail

createKeyPair

public static KeyPair createKeyPair(int size,
                                    String password)
                             throws NoSuchAlgorithmException
Method description

Parameters:
size -
password -
Returns:
Throws:
NoSuchAlgorithmException

createSelfSignedCertificate

public static X509Certificate createSelfSignedCertificate(String email,
                                                          String domain,
                                                          String organizationUnit,
                                                          String organization,
                                                          String city,
                                                          String state,
                                                          String country,
                                                          KeyPair keyPair)
                                                   throws CertificateException,
                                                          IOException,
                                                          NoSuchAlgorithmException,
                                                          InvalidKeyException,
                                                          NoSuchProviderException,
                                                          SignatureException
Method description

Parameters:
email -
domain -
organizationUnit -
organization -
city -
state -
country -
keyPair -
Returns:
Throws:
CertificateException
IOException
NoSuchAlgorithmException
InvalidKeyException
NoSuchProviderException
SignatureException

exportToPemFormat

public static String exportToPemFormat(CertificateEntry entry)
                                throws CertificateEncodingException
Method description

Parameters:
entry -
Returns:
Throws:
CertificateEncodingException

getCertCName

public static String getCertCName(X509Certificate cert)
Method description

Parameters:
cert -
Returns:

isExpired

public static boolean isExpired(X509Certificate cert)
Method description

Parameters:
cert -
Returns:

isSelfSigned

public static boolean isSelfSigned(X509Certificate cert)
Method description

Parameters:
cert -
Returns:

loadCertificate

public static CertificateEntry loadCertificate(String file)
                                        throws FileNotFoundException,
                                               IOException,
                                               CertificateException,
                                               NoSuchAlgorithmException,
                                               InvalidKeySpecException
Method description

Parameters:
file -
Returns:
Throws:
CertificateException
FileNotFoundException
IOException
InvalidKeySpecException
NoSuchAlgorithmException

loadCertificate

public static CertificateEntry loadCertificate(File file)
                                        throws FileNotFoundException,
                                               IOException,
                                               CertificateException,
                                               NoSuchAlgorithmException,
                                               InvalidKeySpecException
Method description

Parameters:
file -
Returns:
Throws:
CertificateException
FileNotFoundException
IOException
InvalidKeySpecException
NoSuchAlgorithmException

loadPrivateKeyFromDER

public static PrivateKey loadPrivateKeyFromDER(File file)
                                        throws FileNotFoundException,
                                               IOException,
                                               NoSuchAlgorithmException,
                                               InvalidKeySpecException
Method description

Parameters:
file -
Returns:
Throws:
FileNotFoundException
IOException
InvalidKeySpecException
NoSuchAlgorithmException

main

public static void main(String[] args)
                 throws Exception
Method description

Parameters:
args -
Throws:
Exception

parseCertificate

public static CertificateEntry parseCertificate(Reader data)
                                         throws IOException,
                                                CertificateException,
                                                NoSuchAlgorithmException,
                                                InvalidKeySpecException
Method description

Parameters:
data -
Returns:
Throws:
CertificateException
IOException
InvalidKeySpecException
NoSuchAlgorithmException

storeCertificate

public static void storeCertificate(String file,
                                    CertificateEntry entry)
                             throws CertificateEncodingException,
                                    IOException
Method description

Parameters:
file -
entry -
Throws:
CertificateEncodingException
IOException

validateCertificate

public static CertCheckResult validateCertificate(Certificate[] chain,
                                                  KeyStore trustKeystore,
                                                  boolean revocationEnabled)
                                           throws NoSuchAlgorithmException,
                                                  KeyStoreException,
                                                  InvalidAlgorithmParameterException,
                                                  CertificateException
Method description

Parameters:
chain -
revocationEnabled -
trustKeystore -
Returns:
Throws:
CertificateException
NoSuchAlgorithmException
KeyStoreException
InvalidAlgorithmParameterException


Copyright © 2012 Tigase. All Rights Reserved.