edu.vt.middleware.crypt.asymmetric
Class AsymmetricCli

java.lang.Object
  extended by edu.vt.middleware.crypt.AbstractCli
      extended by edu.vt.middleware.crypt.AbstractEncryptionCli
          extended by edu.vt.middleware.crypt.asymmetric.AsymmetricCli

public class AsymmetricCli
extends AbstractEncryptionCli

Command line interface for asymmetric encryption operations.

Version:
$Revision: 2745 $
Author:
Middleware Services

Field Summary
protected static String OPT_GENKEYPAIR
          Generate key pair option.
protected static String OPT_PRIVKEYPATH
          Output path of private key for keypair generation option.
 
Fields inherited from class edu.vt.middleware.crypt.AbstractEncryptionCli
OPT_CIPHER, OPT_DECRYPT, OPT_ENCODING, OPT_ENCRYPT, OPT_OUTFILE, OPT_TAIL
 
Fields inherited from class edu.vt.middleware.crypt.AbstractCli
BASE_64_ENCODING, HEX_ENCODING, OPT_EXAMPLE, OPT_INFILE, options, PEM_SUFFIX
 
Constructor Summary
AsymmetricCli()
           
 
Method Summary
protected  void decrypt(org.apache.commons.cli.CommandLine line)
          Perform a decryption operation using data specified on the command line.
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 encrypt(org.apache.commons.cli.CommandLine line)
          Perform an encryption operation using data specified on the command line.
protected  void genKeyPair(org.apache.commons.cli.CommandLine line)
          Generate a new encryption public/private key pair using CLI arguments.
protected  String getCommandName()
          Gets the name of the command for which this class provides a CLI interface.
protected  void initOptions()
          Initialize CLI options.
static void main(String[] args)
          CLI entry point method.
protected  AsymmetricAlgorithm newAlgorithm(org.apache.commons.cli.CommandLine line)
          Creates a new asymmetric encryption algorithm instance based on CLI options.
protected  PrivateKey readPrivateKey(org.apache.commons.cli.CommandLine line)
          Creates a private key from a file defined by CLI arguments.
protected  PublicKey readPublicKey(org.apache.commons.cli.CommandLine line)
          Creates a public key from a file defined by CLI 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.AbstractEncryptionCli
decrypt, encrypt, getInputStream, getOutputStream
 
Methods inherited from class edu.vt.middleware.crypt.AbstractCli
closeStream, closeStream, getInputStream, performAction, printExamples, printHelp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPT_GENKEYPAIR

protected static final String OPT_GENKEYPAIR
Generate key pair option.

See Also:
Constant Field Values

OPT_PRIVKEYPATH

protected static final String OPT_PRIVKEYPATH
Output path of private key for keypair generation option.

See Also:
Constant Field Values
Constructor Detail

AsymmetricCli

public AsymmetricCli()
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 AbstractEncryptionCli

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.

newAlgorithm

protected AsymmetricAlgorithm newAlgorithm(org.apache.commons.cli.CommandLine line)
Creates a new asymmetric encryption algorithm instance based on CLI options.

Parameters:
line - Parsed command line arguments container.
Returns:
New instance of an initialized asymmetric algorithm.

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.

encrypt

protected void encrypt(org.apache.commons.cli.CommandLine line)
                throws Exception
Perform an encryption operation using data specified on the command line.

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

decrypt

protected void decrypt(org.apache.commons.cli.CommandLine line)
                throws Exception
Perform a decryption operation using data specified on the command line.

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

genKeyPair

protected void genKeyPair(org.apache.commons.cli.CommandLine line)
                   throws Exception
Generate a new encryption public/private key pair using CLI arguments.

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

readPublicKey

protected PublicKey readPublicKey(org.apache.commons.cli.CommandLine line)
                           throws Exception
Creates a public key from a file defined by CLI arguments.

Parameters:
line - Parsed command line arguments container.
Returns:
Public key used for signature verification.
Throws:
Exception - On IO or key format errors.

readPrivateKey

protected PrivateKey readPrivateKey(org.apache.commons.cli.CommandLine line)
                             throws CryptException,
                                    IOException
Creates a private key from a file defined by CLI arguments.

Parameters:
line - Parsed command line arguments container.
Returns:
Private key.
Throws:
CryptException - On crypto errors.
IOException - On I/O 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.