org.neuclear.commons.crypto.signers
Class PersonalSigner

java.lang.Object
  extended by org.neuclear.commons.crypto.signers.PersonalSigner
All Implemented Interfaces:
javax.swing.ComboBoxModel, javax.swing.ListModel, BrowsableSigner, PublicKeySource, Signer

public class PersonalSigner
extends java.lang.Object
implements BrowsableSigner, javax.swing.ComboBoxModel

User: pelleb Date: May 13, 2004 Time: 9:12:42 AM


Field Summary
 
Fields inherited from interface org.neuclear.commons.crypto.signers.Signer
KEY_DSA, KEY_NONE, KEY_OTHER, KEY_RSA
 
Constructor Summary
PersonalSigner(javax.swing.JFrame frame)
           
 
Method Summary
 void addListDataListener(javax.swing.event.ListDataListener l)
          Adds a listener to the list that's notified each time a change to the data model occurs.
 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)
           
protected  void fireListUpdated()
           
 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.
 java.lang.Object getElementAt(int index)
          Returns the value at the specified index.
 int getKeyType(java.lang.String name)
          Checks the key type of the given alias
 java.security.PublicKey getPublicKey(java.lang.String name)
           
 java.lang.Object getSelectedItem()
           
 int getSize()
          Returns the length of the list.
 boolean isOpen()
           
 java.util.Iterator iterator()
           
 void open()
           
 void removeListDataListener(javax.swing.event.ListDataListener l)
          Removes a listener from the list that's notified each time a change to the data model occurs.
 void save()
           
 void save(boolean force)
           
 void setSelectedItem(java.lang.Object anItem)
           
 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, 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

PersonalSigner

public PersonalSigner(javax.swing.JFrame frame)
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

open

public void open()
          throws UserCancellationException
Throws:
UserCancellationException

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

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

isOpen

public boolean isOpen()

iterator

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

getSize

public int getSize()
Returns the length of the list.

Specified by:
getSize in interface javax.swing.ListModel
Returns:
the length of the list

getElementAt

public java.lang.Object getElementAt(int index)
Returns the value at the specified index.

Specified by:
getElementAt in interface javax.swing.ListModel
Parameters:
index - the requested index
Returns:
the value at index

addListDataListener

public void addListDataListener(javax.swing.event.ListDataListener l)
Adds a listener to the list that's notified each time a change to the data model occurs.

Specified by:
addListDataListener in interface javax.swing.ListModel
Parameters:
l - the ListDataListener to be added

removeListDataListener

public void removeListDataListener(javax.swing.event.ListDataListener l)
Removes a listener from the list that's notified each time a change to the data model occurs.

Specified by:
removeListDataListener in interface javax.swing.ListModel
Parameters:
l - the ListDataListener to be removed

fireListUpdated

protected void fireListUpdated()

getSelectedItem

public java.lang.Object getSelectedItem()
Specified by:
getSelectedItem in interface javax.swing.ComboBoxModel

setSelectedItem

public void setSelectedItem(java.lang.Object anItem)
Specified by:
setSelectedItem in interface javax.swing.ComboBoxModel


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