core.crypto
Class ExportImport

java.lang.Object
  extended by core.crypto.ExportImport

public class ExportImport
extends Object

This class provides methods to export certificates and secret keys.

  Copyright (c) 2006 Sebastian Erdweg
  Copyright (c) 2006 Dominik Schulz
  Copyright (c) 2006 Florian Lindner
  Copyright (c) 2006 Betim Berjani
  
  This file is part of FlexiCrypt.

  FlexiCrypt is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  FlexiCrypt is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with FlexiCrypt; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  

Author:
Sebastian

Method Summary
static void exportPKCS12DER(PrivateKey privateKey, Certificate cert, Certificate[] chain, File file, char[] pass)
          Exports a PCKS#12-Keystore.
static X509Certificate readCertificateBase64(File file)
           
static X509Certificate readCertificateDER(File file)
           
static KeyStore.PrivateKeyEntry readCertificatePrivateKeyPKCS12DER(File file, char[] pass)
           
static SecretKey readSecretKeyXML(File file, char[] password)
           
static void writeCertificateBase64(Certificate cert, File file)
           
static void writeCertificateDER(Certificate cert, File file)
           
static void writeCertificatePrivateKeyPKCS12DER(PrivateKey privateKey, Certificate cert, Certificate[] chain, File file, char[] pass)
          Exports a private key with a certificate based on the PKCS#12 standard PKCS#12 will be DER encoded
static void writeSecretKeyXML(SecretKey secretKey, File file, char[] password)
          Exports a secret key base64 encoded
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

readCertificateBase64

public static X509Certificate readCertificateBase64(File file)
                                             throws Exception
Throws:
Exception

readCertificateDER

public static X509Certificate readCertificateDER(File file)
                                          throws Exception
Throws:
Exception

readSecretKeyXML

public static SecretKey readSecretKeyXML(File file,
                                         char[] password)
                                  throws Exception
Throws:
Exception

readCertificatePrivateKeyPKCS12DER

public static KeyStore.PrivateKeyEntry readCertificatePrivateKeyPKCS12DER(File file,
                                                                          char[] pass)
                                                                   throws Exception
Throws:
Exception

writeCertificateBase64

public static void writeCertificateBase64(Certificate cert,
                                          File file)
                                   throws CertificateEncodingException,
                                          IOException,
                                          NoSuchAlgorithmException,
                                          InvalidKeySpecException,
                                          InvalidKeyException,
                                          NoSuchPaddingException,
                                          InvalidAlgorithmParameterException,
                                          InterruptedException
Throws:
CertificateEncodingException
IOException
NoSuchAlgorithmException
InvalidKeySpecException
InvalidKeyException
NoSuchPaddingException
InvalidAlgorithmParameterException
InterruptedException

writeCertificateDER

public static void writeCertificateDER(Certificate cert,
                                       File file)
                                throws Exception
Throws:
Exception

writeCertificatePrivateKeyPKCS12DER

public static void writeCertificatePrivateKeyPKCS12DER(PrivateKey privateKey,
                                                       Certificate cert,
                                                       Certificate[] chain,
                                                       File file,
                                                       char[] pass)
                                                throws Exception
Exports a private key with a certificate based on the PKCS#12 standard PKCS#12 will be DER encoded

Parameters:
privateKey -
cert -
chain -
file -
pass -
Throws:
Exception

exportPKCS12DER

public static void exportPKCS12DER(PrivateKey privateKey,
                                   Certificate cert,
                                   Certificate[] chain,
                                   File file,
                                   char[] pass)
                            throws KeyStoreException,
                                   NoSuchAlgorithmException,
                                   CertificateException,
                                   IOException
Exports a PCKS#12-Keystore. This on works with Mozilla.

Parameters:
privateKey -
chain -
file -
pass -
Throws:
KeyStoreException
NoSuchAlgorithmException
CertificateException
IOException

writeSecretKeyXML

public static void writeSecretKeyXML(SecretKey secretKey,
                                     File file,
                                     char[] password)
                              throws InvalidKeyException,
                                     NoSuchPaddingException,
                                     NoSuchAlgorithmException,
                                     IOException,
                                     InvalidAlgorithmParameterException,
                                     InterruptedException
Exports a secret key base64 encoded

Parameters:
secretKey -
file -
password -
Throws:
InvalidKeyException
NoSuchPaddingException
NoSuchAlgorithmException
IOException
InterruptedException
InvalidAlgorithmParameterException