edu.vt.middleware.crypt
Class KeyStoreCli

java.lang.Object
  extended by edu.vt.middleware.crypt.AbstractCli
      extended by edu.vt.middleware.crypt.KeyStoreCli

public class KeyStoreCli
extends AbstractCli

Command line interface for keystore operations.

Version:
$Revision: 2745 $
Author:
Middleware Services

Field Summary
static String DEFAULT_KEY_ALGORITHM
          Default key algorithm name.
protected static String OPT_ALIAS
          Option for specifying alias for keystore entry to import/export.
protected static String OPT_CERT
          Option for specifying certificate file to import/export.
protected static String OPT_EXPORT
          Option for exporting keypair from keystore.
protected static String OPT_IMPORT
          Option for importing keypair into keystore.
protected static String OPT_KEY
          Option for specifying key file to import/export.
protected static String OPT_KEYALG
          Option for specifying key cipher algorithm.
protected static String OPT_LIST
          Option for listing keystore contents.
protected static String OPT_PASS
          Option for specifying keystore password.
protected static String OPT_STORE
          Option for specifying keystore file.
protected static String OPT_TYPE
          Option for specifying keystore type.
 
Fields inherited from class edu.vt.middleware.crypt.AbstractCli
BASE_64_ENCODING, HEX_ENCODING, OPT_EXAMPLE, OPT_INFILE, options, PEM_SUFFIX
 
Constructor Summary
KeyStoreCli()
           
 
Method Summary
protected  void dispatch(org.apache.commons.cli.CommandLine line)
          Dispatch command line data to the handler that can perform the operation requested on the command line.
protected  void doExport(org.apache.commons.cli.CommandLine line)
          Exports a certificate or key pair from the keystore.
protected  void doImport(org.apache.commons.cli.CommandLine line)
          Imports a certificate or key pair into the keystore.
protected  String getCommandName()
          Gets the name of the command for which this class provides a CLI interface.
protected  void initOptions()
          Initialize CLI options.
protected  void list(org.apache.commons.cli.CommandLine line)
          Lists keystore contents on STDOUT.
static void main(String[] args)
          CLI entry point method.
protected  void printCertificate(Certificate cert)
          Prints a string representation of the given certificate to STDOUT.
protected  KeyStore readKeyStore(org.apache.commons.cli.CommandLine line)
          Reads a keystore from disk using command line arguments.
protected  void validateOptions(org.apache.commons.cli.CommandLine line)
          Validates the existence of required options for an operation.
 
Methods inherited from class edu.vt.middleware.crypt.AbstractCli
closeStream, closeStream, getInputStream, getInputStream, performAction, printExamples, printHelp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_KEY_ALGORITHM

public static final String DEFAULT_KEY_ALGORITHM
Default key algorithm name.

See Also:
Constant Field Values

OPT_LIST

protected static final String OPT_LIST
Option for listing keystore contents.

See Also:
Constant Field Values

OPT_IMPORT

protected static final String OPT_IMPORT
Option for importing keypair into keystore.

See Also:
Constant Field Values

OPT_EXPORT

protected static final String OPT_EXPORT
Option for exporting keypair from keystore.

See Also:
Constant Field Values

OPT_STORE

protected static final String OPT_STORE
Option for specifying keystore file.

See Also:
Constant Field Values

OPT_TYPE

protected static final String OPT_TYPE
Option for specifying keystore type.

See Also:
Constant Field Values

OPT_PASS

protected static final String OPT_PASS
Option for specifying keystore password.

See Also:
Constant Field Values

OPT_ALIAS

protected static final String OPT_ALIAS
Option for specifying alias for keystore entry to import/export.

See Also:
Constant Field Values

OPT_CERT

protected static final String OPT_CERT
Option for specifying certificate file to import/export.

See Also:
Constant Field Values

OPT_KEY

protected static final String OPT_KEY
Option for specifying key file to import/export.

See Also:
Constant Field Values

OPT_KEYALG

protected static final String OPT_KEYALG
Option for specifying key cipher algorithm.

See Also:
Constant Field Values
Constructor Detail

KeyStoreCli

public KeyStoreCli()
Method Detail

main

public static void main(String[] args)
CLI entry point method.

Parameters:
args - Command line arguments.

initOptions

protected void initOptions()
Initialize CLI options.

Overrides:
initOptions in class AbstractCli

dispatch

protected void dispatch(org.apache.commons.cli.CommandLine line)
                 throws Exception
Dispatch command line data to the handler that can perform the operation requested on the command line.

Specified by:
dispatch in class AbstractCli
Parameters:
line - Parsed command line arguments container.
Throws:
Exception - On errors thrown by handler.

list

protected void list(org.apache.commons.cli.CommandLine line)
             throws Exception
Lists keystore contents on STDOUT. Output is similar to keytool -list -v.

Parameters:
line - Parsed command line arguments container.
Throws:
Exception - On errors.

doImport

protected void doImport(org.apache.commons.cli.CommandLine line)
                 throws Exception
Imports a certificate or key pair into the keystore.

Parameters:
line - Parsed command line arguments container.
Throws:
Exception - On errors.

doExport

protected void doExport(org.apache.commons.cli.CommandLine line)
                 throws Exception
Exports a certificate or key pair from the keystore.

Parameters:
line - Parsed command line arguments container.
Throws:
Exception - On errors.

getCommandName

protected String getCommandName()
Gets the name of the command for which this class provides a CLI interface.

Specified by:
getCommandName in class AbstractCli
Returns:
Name of CLI command.

readKeyStore

protected KeyStore readKeyStore(org.apache.commons.cli.CommandLine line)
                         throws Exception
Reads a keystore from disk using command line arguments.

Parameters:
line - Parsed command line arguments container.
Returns:
Initialized key store read from disk.
Throws:
Exception - On errors.

printCertificate

protected void printCertificate(Certificate cert)
                         throws Exception
Prints a string representation of the given certificate to STDOUT. For an X.509 certificate, prints important fields.

Parameters:
cert - Certificate to print.
Throws:
Exception - On print errors.

validateOptions

protected void validateOptions(org.apache.commons.cli.CommandLine line)
Validates the existence of required options for an operation.

Parameters:
line - Parsed command line arguments container.


Copyright © 2003-2013 Virginia Tech. All Rights Reserved.