Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.classpath.tools.jarsigner
Class Main  view Main download Main.java

java.lang.Object
  extended bygnu.classpath.tools.jarsigner.Main

public class Main
extends java.lang.Object

The GNU Classpath implementation of the jarsigner tool.

The jarsigner tool is used to sign and verify JAR (Java ARchive) files.

This implementation is intended to be compatible with the behaviour described in the public documentation of the same tool included in JDK 1.4.


Field Summary
private  java.lang.String alias
           
private  boolean certs
           
(package private) static java.lang.String DIGEST
           
(package private) static java.util.jar.Attributes.Name DIGEST_ATTR
           
(package private) static java.lang.String DIGEST_MANIFEST
           
(package private) static java.util.jar.Attributes.Name DIGEST_MANIFEST_ATTR
           
(package private) static gnu.java.security.OID DSA_SIGNATURE_OID
           
private static java.util.Locale EN_US_LOCALE
           
private  javax.security.auth.callback.CallbackHandler handler
          The callback handler to use when needing to interact with user.
private static java.lang.String HELP_PATH
           
private  boolean internalSF
           
private  java.lang.String jarFileName
           
private  java.lang.String ksPassword
           
private  char[] ksPasswordChars
           
private  java.lang.String ksType
           
private  java.lang.String ksURL
           
private static java.util.logging.Logger log
           
private  java.lang.String password
           
private  char[] passwordChars
           
protected  java.security.Provider provider
           
private  java.lang.String providerClassName
           
private  boolean providerInstalled
           
(package private) static gnu.java.security.OID RSA_SIGNATURE_OID
           
private  boolean sectionsOnly
           
private  java.lang.String sigFileName
           
private  java.lang.String signedJarFileName
           
private  java.security.cert.Certificate[] signerCertificateChain
           
private  java.security.PrivateKey signerPrivateKey
           
private  java.security.KeyStore store
           
private  boolean verbose
           
private  boolean verify
           
 
Constructor Summary
private Main()
           
 
Method Summary
protected  javax.security.auth.callback.CallbackHandler getCallbackHandler()
          Return a CallbackHandler which uses the Console (System.in and System.out) for interacting with the user.
(package private)  java.lang.String getJarFileName()
           
(package private)  java.lang.String getSigFileName()
           
(package private)  java.lang.String getSignedJarFileName()
           
(package private)  java.security.cert.Certificate[] getSignerCertificateChain()
           
(package private)  java.security.PrivateKey getSignerPrivateKey()
           
private  void installNewProvider()
          Install the user defined security provider in the underlying JVM.
(package private)  boolean isCerts()
           
(package private)  boolean isInternalSF()
           
(package private)  boolean isSectionsOnly()
           
(package private)  boolean isVerbose()
           
static void main(java.lang.String[] args)
           
private  void processArgs(java.lang.String[] args)
          Read the command line arguments setting the tool's parameters in preparation for the user desired action.
private  void setupCommonParams()
          After processing the command line arguments, this method is invoked to process the common parameters which may have been encountered among the actual arguments.
private  void setupSigningParams()
          After processing the command line arguments, this method is invoked to process the parameters which may have been encountered among the actual arguments, and which are specific to the signing action of the tool.
private  void start()
          Invokes the start() method of the concrete handler.
private  void teardown()
          Ensures that the underlying JVM is left in the same state as we found it when we first launched the tool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final java.util.logging.Logger log

HELP_PATH

private static final java.lang.String HELP_PATH
See Also:
Constant Field Values

EN_US_LOCALE

private static final java.util.Locale EN_US_LOCALE

DIGEST

static final java.lang.String DIGEST
See Also:
Constant Field Values

DIGEST_MANIFEST

static final java.lang.String DIGEST_MANIFEST
See Also:
Constant Field Values

DIGEST_ATTR

static final java.util.jar.Attributes.Name DIGEST_ATTR

DIGEST_MANIFEST_ATTR

static final java.util.jar.Attributes.Name DIGEST_MANIFEST_ATTR

DSA_SIGNATURE_OID

static final gnu.java.security.OID DSA_SIGNATURE_OID

RSA_SIGNATURE_OID

static final gnu.java.security.OID RSA_SIGNATURE_OID

verify

private boolean verify

ksURL

private java.lang.String ksURL

ksType

private java.lang.String ksType

password

private java.lang.String password

ksPassword

private java.lang.String ksPassword

sigFileName

private java.lang.String sigFileName

signedJarFileName

private java.lang.String signedJarFileName

verbose

private boolean verbose

certs

private boolean certs

internalSF

private boolean internalSF

sectionsOnly

private boolean sectionsOnly

providerClassName

private java.lang.String providerClassName

jarFileName

private java.lang.String jarFileName

alias

private java.lang.String alias

provider

protected java.security.Provider provider

providerInstalled

private boolean providerInstalled

ksPasswordChars

private char[] ksPasswordChars

store

private java.security.KeyStore store

passwordChars

private char[] passwordChars

signerPrivateKey

private java.security.PrivateKey signerPrivateKey

signerCertificateChain

private java.security.cert.Certificate[] signerCertificateChain

handler

private javax.security.auth.callback.CallbackHandler handler
The callback handler to use when needing to interact with user.

Constructor Detail

Main

private Main()
Method Detail

main

public static final void main(java.lang.String[] args)

processArgs

private void processArgs(java.lang.String[] args)
                  throws java.lang.Exception
Read the command line arguments setting the tool's parameters in preparation for the user desired action.


start

private void start()
            throws java.lang.Exception
Invokes the start() method of the concrete handler.

Depending on the result of processing the command line arguments, this handler may be one for signing the jar, or verifying it.


teardown

private void teardown()
Ensures that the underlying JVM is left in the same state as we found it when we first launched the tool. Specifically, if we have installed a new security provider then now is the time to remove it.

Note (rsn): this may not be necessary if we terminate the JVM; i.e. call System.exit(int)>System.exit(int) 55 at the end of the tool's invocation. Nevertheless it's good practive to return the JVM to its initial state.


setupCommonParams

private void setupCommonParams()
                        throws java.lang.InstantiationException,
                               java.lang.IllegalAccessException,
                               java.lang.ClassNotFoundException,
                               java.io.IOException
After processing the command line arguments, this method is invoked to process the common parameters which may have been encountered among the actual arguments.

Common parameters are those which are allowed in both signing and verification modes.


installNewProvider

private void installNewProvider()
Install the user defined security provider in the underlying JVM.

Also record this fact so we can remove it when we exit the tool.


setupSigningParams

private void setupSigningParams()
                         throws java.security.KeyStoreException,
                                java.io.IOException,
                                java.security.NoSuchAlgorithmException,
                                java.security.cert.CertificateException,
                                javax.security.auth.callback.UnsupportedCallbackException,
                                java.security.UnrecoverableKeyException
After processing the command line arguments, this method is invoked to process the parameters which may have been encountered among the actual arguments, and which are specific to the signing action of the tool.


isVerbose

boolean isVerbose()

isCerts

boolean isCerts()

getSigFileName

java.lang.String getSigFileName()

getJarFileName

java.lang.String getJarFileName()

isSectionsOnly

boolean isSectionsOnly()

isInternalSF

boolean isInternalSF()

getSignerPrivateKey

java.security.PrivateKey getSignerPrivateKey()

getSignerCertificateChain

java.security.cert.Certificate[] getSignerCertificateChain()

getSignedJarFileName

java.lang.String getSignedJarFileName()

getCallbackHandler

protected javax.security.auth.callback.CallbackHandler getCallbackHandler()
Return a CallbackHandler which uses the Console (System.in and System.out) for interacting with the user.

This method first finds all currently installed security providers capable of providing such service and then in turn attempts to instantiate the handler from those providers. As soon as one provider returns a non-null instance of the callback handler, the search stops and that instance is set to be used from now on.

If no installed providers were found, this method falls back on the GNU provider, by-passing the Security search mechanism. The default console callback handler implementation is gnu.javax.security.auth.callback.ConsoleCallbackHandler.