ADK CVS

tryllian.are.security
Class DNASigner

java.lang.Object
  extended bytryllian.are.security.DNASigner

public class DNASigner
extends java.lang.Object

Helper class for DNAComposer for dealing with jar signing related stuff. Mostly a wrapper class for our jarsigner, with a some additional setter methods to facilitate signing multiple files with the same settings.


Method Summary
 java.lang.String getAlias()
          Getter for alias.
 java.io.File getKeyStoreFile()
          Getter for keystore.
static boolean isSigned(java.io.File file)
          Test if a given file appears to be signed.
 boolean isSignedWithSameCertificate(java.io.File file)
          Test if a given File is already validly signed using the current settings for keystore, alias and password.
 void setAlias(java.lang.String alias)
          Setter for alias.
 void setKeyStore(java.io.File keyStore)
          Setter for keyStore.
 void setPassword(char[] password)
          Setter for password.
 void sign(java.io.File fileToSign, java.io.File signedFile)
          Signs an existing JAR file, creating a new signed file.
static void unsign(java.io.File fileToUnsign, java.io.File unsignedFile)
          Given a URL to a signed JAR file, creates a copy with the same content, minus the signing info in the original.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setKeyStore

public void setKeyStore(java.io.File keyStore)
Setter for keyStore. Use before signing.


getKeyStoreFile

public java.io.File getKeyStoreFile()
Getter for keystore. In case you forgot what you just set it to.


setAlias

public void setAlias(java.lang.String alias)
Setter for alias. Use before signing.


getAlias

public java.lang.String getAlias()
Getter for alias.

Returns:
the alias String

setPassword

public void setPassword(char[] password)
Setter for password. Use before signing.


isSigned

public static boolean isSigned(java.io.File file)
Test if a given file appears to be signed.

Parameters:
file - the file to test
Returns:
true iff this file appears to be signed.

isSignedWithSameCertificate

public boolean isSignedWithSameCertificate(java.io.File file)
Test if a given File is already validly signed using the current settings for keystore, alias and password.

Parameters:
file - the file to test
Returns:
true iff the URL is already signed with the same certificate.

unsign

public static void unsign(java.io.File fileToUnsign,
                          java.io.File unsignedFile)
                   throws DNAComposerException
Given a URL to a signed JAR file, creates a copy with the same content, minus the signing info in the original.

Parameters:
fileToUnsign - File location for the original signed JAR file
unsignedFile - File location to use for the result.
Throws:
DNAComposerException - if anything goes wrong

sign

public void sign(java.io.File fileToSign,
                 java.io.File signedFile)
          throws DNAComposerException
Signs an existing JAR file, creating a new signed file. The existing JAR file is not altered or deleted.

Parameters:
fileToSign - the file that should be signed
signedFile - where the resulting file should be written
Throws:
DNAComposerException - if :
-there is no alias, keystore and/or password specified
-the alias was not in the keystore
-something is wrong with the keystore
-the jarsigner throws an exception
-an I/O error occurs -some other unforseen exception occurs.

Copyright 2005, Tryllian Solutions B.V.