tools.codec.pkcs
Class AbstractTool

java.lang.Object
  extended bytools.codec.pkcs.AbstractTool
Direct Known Subclasses:
Crypt, Sign, SignKey

public abstract class AbstractTool
extends Object

Base class for a family of tools for testing PKCS classes, and for demonstrating the functionality.

Version:
"$Id: AbstractTool.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Volker Roth

Field Summary
static String DESCR
          The options descriptor for the abstract tool.
protected  KeyStore keystore_
          The keystore.
protected  ArgsParser p_
          The command line option parser to use.
 
Constructor Summary
AbstractTool()
           
 
Method Summary
protected  X509Certificate getCertificate(String alias)
          Returns the X.509 certificate whose alias is defined in the command line parser option with the given name.
protected  KeyStore getKeyStore()
          Returns the keystore.
protected  PrivateKey getPrivateKey(String alias, String passwd)
          Returns the private key whose alias is defined in the command line parser option with the given name.
protected  ASN1Type loadContentInfo(String option)
          Loads a PKCS#7 ContentInfo and returns its content.
protected  void saveContentInfo(ASN1RegisteredType rt, String option)
          Saves the given ASN1RegisteredType in the file whose name is specified by the option with the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DESCR

public static final String DESCR
The options descriptor for the abstract tool.

See Also:
Constant Field Values

p_

protected ArgsParser p_
The command line option parser to use.


keystore_

protected KeyStore keystore_
The keystore.

Constructor Detail

AbstractTool

public AbstractTool()
Method Detail

getKeyStore

protected KeyStore getKeyStore()
                        throws GeneralSecurityException,
                               IOException,
                               ArgsParserException
Returns the keystore. If the keystore is not yet loaded then this method loads it. The parameters are taken from the command line parser by means of options.

The options required by this method are

storetype
The type of key store, e. g. JKS.
storepass
The password for the keystore.
keystore
The keystore file.

Returns:
The keystore.
Throws:
GeneralSecurityException
IOException
ArgsParserException

getPrivateKey

protected PrivateKey getPrivateKey(String alias,
                                   String passwd)
                            throws GeneralSecurityException,
                                   IOException,
                                   ArgsParserException
Returns the private key whose alias is defined in the command line parser option with the given name.

Parameters:
alias - The alias of the desired private key.
passwd - The password for the desired private key.
Returns:
The private key.
Throws:
GeneralSecurityException
IOException
ArgsParserException

getCertificate

protected X509Certificate getCertificate(String alias)
                                  throws GeneralSecurityException,
                                         IOException,
                                         ArgsParserException
Returns the X.509 certificate whose alias is defined in the command line parser option with the given name.

Returns:
The X.509 certificate.
Throws:
GeneralSecurityException
IOException
ArgsParserException

loadContentInfo

protected ASN1Type loadContentInfo(String option)
                            throws IOException,
                                   ASN1Exception,
                                   ArgsParserException
Loads a PKCS#7 ContentInfo and returns its content.

Parameters:
option - The name of the option that specifies the file.
Returns:
The content.
Throws:
IOException
ASN1Exception
ArgsParserException

saveContentInfo

protected void saveContentInfo(ASN1RegisteredType rt,
                               String option)
                        throws IOException,
                               ASN1Exception,
                               ArgsParserException
Saves the given ASN1RegisteredType in the file whose name is specified by the option with the given name. Before saving, the type is wrapped in a ContentInfo.

Throws:
IOException
ASN1Exception
ArgsParserException


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.