org.neuclear.commons.crypto.signers
Class DefaultSigner

java.lang.Object
  extended by org.neuclear.commons.crypto.signers.DefaultSigner
All Implemented Interfaces:
BrowsableSigner, PublicKeySource, Signer

public final class DefaultSigner
extends java.lang.Object
implements BrowsableSigner

Easy to use preconfigured Signer that uses the standard default JCE KeyStore User: pelleb Date: Oct 29, 2003 Time: 3:22:17 PM


Field Summary
 
Fields inherited from interface org.neuclear.commons.crypto.signers.Signer
KEY_DSA, KEY_NONE, KEY_OTHER, KEY_RSA
 
Constructor Summary
DefaultSigner()
           
DefaultSigner(InteractiveAgent agent)
           
 
Method Summary
 boolean canSignFor(java.lang.String name)
          Returns true if the Signer contains a signer for the given name
 void createKeyPair(java.lang.String alias, char[] passphrase)
           
 java.security.PublicKey generateKey()
          Creates a new KeyPair, stores the PrivateKey using the base32 sha1 of the public key as it's alias and returns the PublicKey.
 java.security.PublicKey generateKey(java.lang.String alias)
          Creates a new KeyPair, stores the PrivateKey using the given alias and returns the PublicKey.
 InteractiveAgent getAgent()
           
 int getKeyType(java.lang.String name)
          Checks the key type of the given alias
 java.security.PublicKey getPublicKey(java.lang.String name)
           
 java.util.Iterator iterator()
           
 void save()
           
 void save(boolean force)
           
 byte[] sign(byte[] data, SetPublicKeyCallBack callback)
           
 byte[] sign(java.lang.String name, byte[] data)
          Signs the data with the privatekey of the given name
 byte[] sign(java.lang.String name, byte[] data, boolean incorrect)
           
 byte[] sign(java.lang.String name, char[] pass, byte[] data, SetPublicKeyCallBack callback)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSigner

public DefaultSigner(InteractiveAgent agent)
              throws UserCancellationException
Throws:
UserCancellationException

DefaultSigner

public DefaultSigner()
              throws UserCancellationException
Throws:
UserCancellationException
Method Detail

sign

public final byte[] sign(java.lang.String name,
                         byte[] data)
                  throws NonExistingSignerException,
                         UserCancellationException
Description copied from interface: Signer
Signs the data with the privatekey of the given name

Specified by:
sign in interface Signer
Parameters:
name - Alias of private key to be used within KeyStore
data - Data to be signed
Returns:
The signature
Throws:
NonExistingSignerException
UserCancellationException

sign

public final byte[] sign(java.lang.String name,
                         byte[] data,
                         boolean incorrect)
                  throws UserCancellationException,
                         NonExistingSignerException
Throws:
UserCancellationException
NonExistingSignerException

canSignFor

public final boolean canSignFor(java.lang.String name)
Description copied from interface: Signer
Returns true if the Signer contains a signer for the given name

Specified by:
canSignFor in interface Signer
Returns:
true if signer is contained

getKeyType

public final int getKeyType(java.lang.String name)
Description copied from interface: Signer
Checks the key type of the given alias

Specified by:
getKeyType in interface Signer
Returns:
KEY_NONE,KEY_RSA,KEY_DSA

generateKey

public final java.security.PublicKey generateKey(java.lang.String alias)
                                          throws UserCancellationException
Description copied from interface: Signer
Creates a new KeyPair, stores the PrivateKey using the given alias and returns the PublicKey.

Specified by:
generateKey in interface Signer
Returns:
Generated PublicKey
Throws:
UserCancellationException

generateKey

public java.security.PublicKey generateKey()
                                    throws UserCancellationException
Description copied from interface: Signer
Creates a new KeyPair, stores the PrivateKey using the base32 sha1 of the public key as it's alias and returns the PublicKey.

Specified by:
generateKey in interface Signer
Returns:
Generated PublicKey
Throws:
UserCancellationException

getPublicKey

public final java.security.PublicKey getPublicKey(java.lang.String name)
                                           throws NonExistingSignerException
Specified by:
getPublicKey in interface PublicKeySource
Throws:
NonExistingSignerException

sign

public byte[] sign(byte[] data,
                   SetPublicKeyCallBack callback)
            throws UserCancellationException
Specified by:
sign in interface BrowsableSigner
Throws:
UserCancellationException

sign

public byte[] sign(java.lang.String name,
                   char[] pass,
                   byte[] data,
                   SetPublicKeyCallBack callback)
            throws InvalidPassphraseException
Specified by:
sign in interface BrowsableSigner
Throws:
InvalidPassphraseException

createKeyPair

public void createKeyPair(java.lang.String alias,
                          char[] passphrase)
                   throws CryptoException
Specified by:
createKeyPair in interface BrowsableSigner
Throws:
CryptoException

getAgent

public InteractiveAgent getAgent()

save

public void save()
Specified by:
save in interface Signer

save

public void save(boolean force)
          throws java.io.IOException,
                 UserCancellationException
Throws:
java.io.IOException
UserCancellationException

iterator

public java.util.Iterator iterator()
                            throws java.security.KeyStoreException
Specified by:
iterator in interface BrowsableSigner
Throws:
java.security.KeyStoreException


Copyright © 2003-2004 Antilles Software Ventures SA. All Rights Reserved.