at.knowcenter.wag.egov.egiz.commandline
Class Main

java.lang.Object
  extended by at.knowcenter.wag.egov.egiz.commandline.Main

public abstract class Main
extends Object

The main program entry point of the commandline tool.

Author:
wprinz

Field Summary
protected static String PARAMETER_CONNECTOR
          Command line parameter setting the application to connect
protected static String PARAMETER_MODE
          Command line parameter setting the application mode sign|verify
protected static String PARAMETER_POS
          Command line parameter selecting the position of the signature.
protected static String PARAMETER_SIGNATURE_MODE
          Command line parameter setting the signature mode.
protected static String PARAMETER_SIGNATURE_TYPE
          Command line parameter setting the signature type.
protected static String PARAMETER_USER_NAME
          Command line parameter setting the username
protected static String PARAMETER_USER_PASSWORD
          Command line parameter setting the users password
protected static String PARAMETER_VERIFY_WHICH
          Command line parameter selecting the signature which is going to be verified.
static String VALUE_MODE_SIGN
          The application mode sign
static String VALUE_MODE_VERIFY
          The application mode verify
static String VALUE_SIGNATURE_MODE_BINARY
          The application mode sign
static String VALUE_SIGNATURE_MODE_DETACHED
          The application mode verify
static String VALUE_SIGNATURE_MODE_TEXTUAL
          The application mode verify
 
Constructor Summary
Main()
           
 
Method Summary
protected static void carryOutCommand(String mode, String signature_mode, String connector, String signature_type, String user_name, String user_password, int verify_which, String input, String output, String pos_string)
          Carries out the actual command given via the commandline parameters.
protected static boolean checkConnector(String connector)
          Checks the value for correctness.
protected static boolean checkMode(String mode)
          Checks the value for correctness.
protected static boolean checkSignatureMode(String signature_mode)
          Checks the value for correctness.
protected static boolean checkSignatureType(String signature_type)
          Checks the value for correctness.
static void formatSignatureResponse(SignatureResponse result, PrintStream writer)
          Formats the SignatureResponse.
protected static void formatVerifyResults(List results, PrintStream writer)
          Formats the verification results.
protected static String generateOutputFileNameFromInput(String input, SignResult sign_result)
          Generates a suitable output file name for the output regarding the type of the sign_result.
static void main(String[] args)
          Main program entry point.
protected static void printErrorCodeException(ErrorCodeException ece)
          Prints out the ErrorCodeException in a descriptive form.
protected static void printMissing(String missing_term)
          Prints that something is missing.
protected static void printMissingParameter(String missing_term, String parameter)
          Prints that a certain parameter was missing.
protected static void printNoValue(String parameter)
          Prints that the provided value was unrecognized.
protected static void printUnrecognizedAdditionalCommandlineArgument(String argument)
          Prints that the provided additional commandline argument was unrecognized.
protected static void printUnrecognizedOption(String option)
          Prints that the provided option was unrecognized.
protected static void printUnrecognizedValue(String parameter, String value)
          Prints that the provided value was unrecognized.
static void printUsage(PrintStream writer)
          Prints the usage text.
protected static PdfASID translateSignatureModeToPdfASID(String signature_mode)
          Translates the commandline argument to a PDF-AS-ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAMETER_MODE

protected static final String PARAMETER_MODE
Command line parameter setting the application mode sign|verify

See Also:
Constant Field Values

PARAMETER_CONNECTOR

protected static final String PARAMETER_CONNECTOR
Command line parameter setting the application to connect

See Also:
Constant Field Values

PARAMETER_SIGNATURE_MODE

protected static final String PARAMETER_SIGNATURE_MODE
Command line parameter setting the signature mode.

See Also:
Constant Field Values

PARAMETER_SIGNATURE_TYPE

protected static final String PARAMETER_SIGNATURE_TYPE
Command line parameter setting the signature type.

See Also:
Constant Field Values

PARAMETER_USER_NAME

protected static final String PARAMETER_USER_NAME
Command line parameter setting the username

See Also:
Constant Field Values

PARAMETER_USER_PASSWORD

protected static final String PARAMETER_USER_PASSWORD
Command line parameter setting the users password

See Also:
Constant Field Values

PARAMETER_POS

protected static final String PARAMETER_POS
Command line parameter selecting the position of the signature.

See Also:
Constant Field Values

PARAMETER_VERIFY_WHICH

protected static final String PARAMETER_VERIFY_WHICH
Command line parameter selecting the signature which is going to be verified.

See Also:
Constant Field Values

VALUE_MODE_SIGN

public static final String VALUE_MODE_SIGN
The application mode sign

See Also:
Constant Field Values

VALUE_MODE_VERIFY

public static final String VALUE_MODE_VERIFY
The application mode verify

See Also:
Constant Field Values

VALUE_SIGNATURE_MODE_BINARY

public static final String VALUE_SIGNATURE_MODE_BINARY
The application mode sign

See Also:
Constant Field Values

VALUE_SIGNATURE_MODE_TEXTUAL

public static final String VALUE_SIGNATURE_MODE_TEXTUAL
The application mode verify

See Also:
Constant Field Values

VALUE_SIGNATURE_MODE_DETACHED

public static final String VALUE_SIGNATURE_MODE_DETACHED
The application mode verify

See Also:
Constant Field Values
Constructor Detail

Main

public Main()
Method Detail

main

public static void main(String[] args)
                 throws IOException
Main program entry point.

Parameters:
args - The commandline arguments.
Throws:
IOException

carryOutCommand

protected static void carryOutCommand(String mode,
                                      String signature_mode,
                                      String connector,
                                      String signature_type,
                                      String user_name,
                                      String user_password,
                                      int verify_which,
                                      String input,
                                      String output,
                                      String pos_string)
                               throws PresentableException
Carries out the actual command given via the commandline parameters.

This is simply the procedure that is executed after the commandline parameters have been parsed successfully.

Parameters:
mode - The operation mode (e.g. "sign", "verify").
signature_mode - The signature mode (e.g. "binary", "textual").
connector - The connector (e.g. "bku", "a1").
signature_type - The signature type/profile. For signing only.
user_name - The user name. For signing only.
user_password - The user password. For signing only.
verify_which - The number of the signature to be verified. For verifying only.
input - The input file name.
output - The output file name.
Throws:
PresentableException

generateOutputFileNameFromInput

protected static String generateOutputFileNameFromInput(String input,
                                                        SignResult sign_result)
Generates a suitable output file name for the output regarding the type of the sign_result.

Parameters:
input - The input file name.
sign_result - The sign result.
Returns:
Returns the output file name.

printUnrecognizedOption

protected static void printUnrecognizedOption(String option)
                                       throws PresentableException
Prints that the provided option was unrecognized.

Parameters:
option - The unrecognized option.
Throws:
PresentableException - Forwarded exception.

printNoValue

protected static void printNoValue(String parameter)
                            throws PresentableException
Prints that the provided value was unrecognized.

Parameters:
parameter - The parameter, which is missing a value.
Throws:
PresentableException - Forwarded exception.

printUnrecognizedValue

protected static void printUnrecognizedValue(String parameter,
                                             String value)
                                      throws PresentableException
Prints that the provided value was unrecognized.

Parameters:
value - The unrecognized value.
Throws:
PresentableException - Forwarded exception.

printUnrecognizedAdditionalCommandlineArgument

protected static void printUnrecognizedAdditionalCommandlineArgument(String argument)
                                                              throws PresentableException
Prints that the provided additional commandline argument was unrecognized.

Parameters:
argument - The unrecognized argument.
Throws:
PresentableException - Forwarded exception.

printMissingParameter

protected static void printMissingParameter(String missing_term,
                                            String parameter)
                                     throws PresentableException
Prints that a certain parameter was missing.

Parameters:
missing_term - A description of the missing parameter ("e.g. a mode").
parameter - The missing parameter itself (e.g. "-mode").
Throws:
PresentableException - Forwarded exception.

printMissing

protected static void printMissing(String missing_term)
                            throws PresentableException
Prints that something is missing.

Parameters:
missing_term - A descriptive message of the missing thing.
Throws:
PresentableException - Forwarded exception.

printErrorCodeException

protected static void printErrorCodeException(ErrorCodeException ece)
Prints out the ErrorCodeException in a descriptive form.

Parameters:
ece - The ErrorCodeException to be printed.

printUsage

public static void printUsage(PrintStream writer)
                       throws PresentableException
Prints the usage text.

Parameters:
writer - The writer to print the text to.
Throws:
PresentableException - Forwarded exception.

checkMode

protected static boolean checkMode(String mode)
Checks the value for correctness.

Parameters:
mode - The parameter's value.
Returns:
Returns true, if the value is correct, false otherwise.

checkSignatureMode

protected static boolean checkSignatureMode(String signature_mode)
Checks the value for correctness.

Parameters:
signature_mode - The parameter's value.
Returns:
Returns true, if the value is correct, false otherwise.

checkConnector

protected static boolean checkConnector(String connector)
                                 throws ConnectorFactoryException
Checks the value for correctness.

Parameters:
connector - The parameter's value.
Returns:
Returns true, if the value is correct, false otherwise.
Throws:
ConnectorFactoryException - F.e.

checkSignatureType

protected static boolean checkSignatureType(String signature_type)
                                     throws SignatureTypesException
Checks the value for correctness.

Parameters:
signature_type - The parameter's value.
Returns:
Returns true, if the value is correct, false otherwise.
Throws:
SignatureTypesException

translateSignatureModeToPdfASID

protected static PdfASID translateSignatureModeToPdfASID(String signature_mode)
Translates the commandline argument to a PDF-AS-ID.

Parameters:
signature_mode - The signator mode commandline argument.
Returns:
Returns the corresponding PDFASID.

formatVerifyResults

protected static void formatVerifyResults(List results,
                                          PrintStream writer)
                                   throws SettingNotFoundException
Formats the verification results.

Parameters:
results - The List of SignatureResponse verification results.
writer - The output sink to write the formatted text to.
Throws:
SettingNotFoundException - Forwarded exception.

formatSignatureResponse

public static void formatSignatureResponse(SignatureResponse result,
                                           PrintStream writer)
                                    throws SettingNotFoundException
Formats the SignatureResponse.

Parameters:
result - The SignatureResponse to be printed.
writer - The output sink to write the formatted text to.
Throws:
SettingNotFoundException - Forwarded exception.


Copyright © 2006-2007 EGIZ - E-Government Innovationszentrum. All Rights Reserved.