org.apache.tsik.xmlsig.tools
Class Pkcs12Import

java.lang.Object
  extended byorg.apache.tsik.xmlsig.tools.Pkcs12Import

public class Pkcs12Import
extends Object

Pkcs12Import contains a simple static function and command line interpreter for importing a PKCS12 certificate file into a Java KeyStore.

See Also:
pkcs12Import(java.io.File, char[], java.lang.String, java.io.File, char[], char[]), usage()

Field Summary
static File DEFAULT_KEYSTORE
          The default keystore is defined as the ".keystore" file in the user's home directory.
 
Constructor Summary
Pkcs12Import()
           
 
Method Summary
static void main(String[] argv)
          Execute command as described by usage().
static void pkcs12Import(File pkcs12File, char[] pkcs12Password, String keyStoreAlias, File keyStoreFile, char[] storePassword, char[] keyPassword)
          Execute command as described by usage().
static void pkcs12Import(File pkcs12File, char[] pkcs12Password, String keyStoreAlias, File keyStoreFile, char[] storePassword, char[] keyPassword, String keyStoreType)
          Execute command as described by usage().
static void usage()
          Print the usage command and exit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_KEYSTORE

public static final File DEFAULT_KEYSTORE
The default keystore is defined as the ".keystore" file in the user's home directory. The home directory is defined by the "user.home" system property.

Constructor Detail

Pkcs12Import

public Pkcs12Import()
Method Detail

main

public static void main(String[] argv)
Execute command as described by usage().

Parameters:
argv - is the command argument array.

usage

public static void usage()
Print the usage command and exit.
  java Pkcs12Import
      -file pkcs12-file           # pkcs12 file to be imported
    [ -pass pkcs12-password ]     # user is prompted if omitted
    [ -alias alias ]              # defaults to pkcs12 alias
    [ -keystore keystore-file ]   # defaults to {user-home}/.keystore
    [ -storepass store-password ] # user is prompted if omitted
    [- keystoretype type ]        # defaults to the default keystore type
    [ -keypass key-password ]     # user is prompted if omitted and may
                                  # hit return to use store-password
 


pkcs12Import

public static void pkcs12Import(File pkcs12File,
                                char[] pkcs12Password,
                                String keyStoreAlias,
                                File keyStoreFile,
                                char[] storePassword,
                                char[] keyPassword)
                         throws IllegalArgumentException,
                                IOException,
                                GeneralSecurityException
Execute command as described by usage(). Assumes the keystore is of the default keystore type, as defined by KeyStore.getDefaultType()

Parameters:
pkcs12File - is the exported PKCS12 certificate file.
pkcs12Password - is the password used to encrypt the PKCS12 file when it was exported.
keyStoreAlias - is the alias used to store the imported cert, or null to use the alias stored in the pkcs12File. It is recommended that the pkcs12 alias be overridden since, at least when exported from IE, it is a UUID and is not appropriate for a keystore alias.
keyStoreFile - is the KeyStore file where the imported cert is to be saved, or null to use the default Java KeyStore.
storePassword - is the password used to open and save the java KeyStore.
keyPassword - is the password used to protect the imported key.
Throws:
IllegalArgumentException - if the PKCS12 file contains zero or more than one cert, or if the entry it contains cannot be recognized.
IOException - if a problem reading or writing the KeyStore files occurs.
GeneralSecurityException - if a security related problem occurs while accessing the KeyStores. This includes problems obtaining a PKCS12 keystore provider or other security algorithms that are needed.

pkcs12Import

public static void pkcs12Import(File pkcs12File,
                                char[] pkcs12Password,
                                String keyStoreAlias,
                                File keyStoreFile,
                                char[] storePassword,
                                char[] keyPassword,
                                String keyStoreType)
                         throws IllegalArgumentException,
                                IOException,
                                GeneralSecurityException
Execute command as described by usage(). See pkcs12Import(File, char[], String, File, char[], char[]) for more information. This mathod adds parameter keyStoreType.

Parameters:
pkcs12File - TODO.
pkcs12Password - TODO.
keyStoreAlias - TODO.
keyStoreFile - TODO.
storePassword - TODO.
keyPassword - TODO.
keyStoreType - the keystore type of keyStoreFile.
Throws:
IllegalArgumentException - TODO.
IOException - TODO.
GeneralSecurityException - TODO.