edu.vt.middleware.crypt
Class AbstractEncryptionCli

java.lang.Object
  extended by edu.vt.middleware.crypt.AbstractCli
      extended by edu.vt.middleware.crypt.AbstractEncryptionCli
Direct Known Subclasses:
AsymmetricCli, SymmetricCli

public abstract class AbstractEncryptionCli
extends AbstractCli

Abstract base class for CLI handler of encryption operations.

Version:
$Revision: 12 $
Author:
Middleware Services

Field Summary
protected static String OPT_CIPHER
          Cipher option.
protected static String OPT_DECRYPT
          Decrypt operation option.
protected static String OPT_ENCODING
          Cihpertext encoding format.
protected static String OPT_ENCRYPT
          Encrypt operation option.
protected static String OPT_OUTFILE
          Output file option.
protected static String OPT_TAIL
          Tail output option.
 
Fields inherited from class edu.vt.middleware.crypt.AbstractCli
BASE_64_ENCODING, HEX_ENCODING, OPT_EXAMPLE, OPT_INFILE, options, PEM_SUFFIX
 
Constructor Summary
AbstractEncryptionCli()
           
 
Method Summary
protected  void decrypt(EncryptionAlgorithm alg, InputStream in, OutputStream out)
          Decrypt the given ciphertext input stream into the output stream using the given encryption cipher algorithm.
protected  void encrypt(EncryptionAlgorithm alg, InputStream in, OutputStream out)
          Encrypt the given plaintext input stream into the output stream using the given encryption cipher algorithm.
protected  InputStream getInputStream(org.apache.commons.cli.CommandLine line)
          Get an input stream containing data to be encrypted or decrypted based on CLI arguments.
protected  OutputStream getOutputStream(org.apache.commons.cli.CommandLine line)
          Get an output stream containing data to be encrypted or decrypted based on CLI arguments.
protected  void initOptions()
          Initialize CLI options.
 
Methods inherited from class edu.vt.middleware.crypt.AbstractCli
closeStream, closeStream, dispatch, getCommandName, 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_CIPHER

protected static final String OPT_CIPHER
Cipher option.

See Also:
Constant Field Values

OPT_OUTFILE

protected static final String OPT_OUTFILE
Output file option.

See Also:
Constant Field Values

OPT_ENCODING

protected static final String OPT_ENCODING
Cihpertext encoding format.

See Also:
Constant Field Values

OPT_ENCRYPT

protected static final String OPT_ENCRYPT
Encrypt operation option.

See Also:
Constant Field Values

OPT_DECRYPT

protected static final String OPT_DECRYPT
Decrypt operation option.

See Also:
Constant Field Values

OPT_TAIL

protected static final String OPT_TAIL
Tail output option.

See Also:
Constant Field Values
Constructor Detail

AbstractEncryptionCli

public AbstractEncryptionCli()
Method Detail

initOptions

protected void initOptions()
Initialize CLI options.

Overrides:
initOptions in class AbstractCli

encrypt

protected void encrypt(EncryptionAlgorithm alg,
                       InputStream in,
                       OutputStream out)
                throws Exception
Encrypt the given plaintext input stream into the output stream using the given encryption cipher algorithm.

Parameters:
alg - Encryption cipher algorithm.
in - Input stream containing plaintext.
out - Output stream containing ciphertext.
Throws:
Exception - On encryption errors.

decrypt

protected void decrypt(EncryptionAlgorithm alg,
                       InputStream in,
                       OutputStream out)
                throws Exception
Decrypt the given ciphertext input stream into the output stream using the given encryption cipher algorithm.

Parameters:
alg - Encryption cipher algorithm.
in - Input stream containing ciphertext.
out - Output stream containing plaintext.
Throws:
Exception - On encryption errors.

getInputStream

protected InputStream getInputStream(org.apache.commons.cli.CommandLine line)
                              throws IOException
Get an input stream containing data to be encrypted or decrypted based on CLI arguments.

Overrides:
getInputStream in class AbstractCli
Parameters:
line - Parsed command line arguments container.
Returns:
Input stream.
Throws:
IOException - On stream creation errors.

getOutputStream

protected OutputStream getOutputStream(org.apache.commons.cli.CommandLine line)
                                throws IOException
Get an output stream containing data to be encrypted or decrypted based on CLI arguments.

Parameters:
line - Parsed command line arguments container.
Returns:
Output stream.
Throws:
IOException - On stream creation errors.


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