View Javadoc
1 /* 2 * $Id: Signer.java,v 1.7 2004/07/21 23:07:16 pelle Exp $ 3 * $Log: Signer.java,v $ 4 * Revision 1.7 2004/07/21 23:07:16 pelle 5 * Updated the Signer interface with a new generateKey() method, which doesn't take any parameters. 6 * It stores the generated key using the Base32 encoded SHA1 digest as it's alias. 7 * 8 * Revision 1.6 2004/01/19 17:53:14 pelle 9 * Various clean ups 10 * 11 * Revision 1.5 2003/12/19 18:02:53 pelle 12 * Revamped a lot of exception handling throughout the framework, it has been simplified in most places: 13 * - For most cases the main exception to worry about now is InvalidNamedObjectException. 14 * - Most lowerlevel exception that cant be handled meaningful are now wrapped in the LowLevelException, a 15 * runtime exception. 16 * - Source and Store patterns each now have their own exceptions that generalizes the various physical 17 * exceptions that can happen in that area. 18 * 19 * Revision 1.4 2003/12/18 17:40:07 pelle 20 * You can now create keys that get stored with a X509 certificate in the keystore. These can be saved as well. 21 * IdentityCreator has been modified to allow creation of keys. 22 * Note The actual Creation of Certificates still have a problem that will be resolved later today. 23 * 24 * Revision 1.3 2003/12/10 23:55:45 pelle 25 * Did some cleaning up in the builders 26 * Fixed some stuff in IdentityCreator 27 * New maven goal to create executable jarapp 28 * We are close to 0.8 final of ID, 0.11 final of XMLSIG and 0.5 of commons. 29 * Will release shortly. 30 * 31 * Revision 1.2 2003/11/19 23:32:50 pelle 32 * Signers now can generatekeys via the generateKey() method. 33 * Refactored the relationship between SignedNamedObject and NamedObjectBuilder a bit. 34 * SignedNamedObject now contains the full xml which is returned with getEncoded() 35 * This means that it is now possible to further receive on or process a SignedNamedObject, leaving 36 * NamedObjectBuilder for its original purposes of purely generating new Contracts. 37 * NamedObjectBuilder.sign() now returns a SignedNamedObject which is the prefered way of processing it. 38 * Updated all major interfaces that used the old model to use the new model. 39 * 40 * Revision 1.1 2003/11/11 21:17:47 pelle 41 * Further vital reshuffling. 42 * org.neudist.crypto.* and org.neudist.utils.* have been moved to respective areas under org.neuclear.commons 43 * org.neuclear.signers.* as well as org.neuclear.passphraseagents have been moved under org.neuclear.commons.crypto as well. 44 * Did a bit of work on the Canonicalizer and changed a few other minor bits. 45 * 46 * Revision 1.3 2003/11/08 20:26:52 pelle 47 * Updated the Signer interface to return a key type to be used for XML SignatureInfo. Thus we now support DSA sigs yet again. 48 * 49 * Revision 1.2 2003/10/29 23:17:10 pelle 50 * Updated some javadocs 51 * Added a neuclear specific maven repository at: 52 * http://neuclear.org/maven/ and updated the properties files to reflect that. 53 * 54 * Revision 1.1 2003/10/29 21:15:53 pelle 55 * Refactored the whole signing process. Now we have an interface called Signer which is the old SignerStore. 56 * To use it you pass a byte array and an alias. The sign method then returns the signature. 57 * If a Signer needs a passphrase it uses a PassPhraseAgent to present a dialogue box, read it from a command line etc. 58 * This new Signer pattern allows us to use secure signing hardware such as N-Cipher in the future for server applications as well 59 * as SmartCards for end user applications. 60 * 61 * Revision 1.3 2003/10/28 23:44:03 pelle 62 * The GuiDialogAgent now works. It simply presents itself as a simple modal dialog box asking for a passphrase. 63 * The two Signer implementations both use it for the passphrase. 64 * 65 * Revision 1.2 2003/02/20 13:26:41 pelle 66 * Adding all of the modification from Rams?s Morales ramses@computer.org to support DSASHA1 Signatures 67 * Thanks Rams?s good work. 68 * So this means there is now support for: 69 * - DSA KeyInfo blocks 70 * - DSA Key Generation within CryptoTools 71 * - Signing using DSASHA1 72 * 73 * Revision 1.1 2003/02/18 00:03:32 pelle 74 * Moved the Signer classes from neuclearframework into neuclear-xmlsig 75 * 76 * Revision 1.4 2002/10/06 00:39:26 pelle 77 * I have now expanded support for different types of Signers. 78 * There is now a JCESigner which uses a JCE KeyStore for signing. 79 * I have refactored the SigningServlet a bit, eliminating most of the demo code. 80 * This has been moved into DemoSigningServlet. 81 * I have expanded the CommandLineSigner, so it now also has an option for specifying a default signing service. 82 * The default web application now contains two signers. 83 * - The Demo one is still at /Signer 84 * - There is a new one at /personal/Signer this uses the testkeys.ks for 85 * signing anything under neu://test 86 * Note neu://test now has a default interactive signer running on localhost. 87 * So to play with this you must install the webapp on your own local machine. 88 * 89 * Revision 1.3 2002/09/23 15:09:11 pelle 90 * Got the SimpleSigner working properly. 91 * I couldn't get SealedObjects working with BouncyCastle's Symmetric keys. 92 * Don't know what I was doing, so I reimplemented it. Encrypting 93 * and decrypting it my self. 94 * 95 * Revision 1.2 2002/09/21 23:11:16 pelle 96 * A bunch of clean ups. Got rid of as many hard coded URL's as I could. 97 * 98 * User: pelleb 99 * Date: Sep 20, 2002 100 * Time: 12:35:14 PM 101 * To change template for new class use 102 * Code Style | Class Templates options (Tools | IDE Options). 103 */ 104 package org.neuclear.commons.crypto.signers; 105 106 import org.neuclear.commons.crypto.passphraseagents.UserCancellationException; 107 108 import java.security.PublicKey; 109 110 111 /*** 112 * The Signer follows the following model: 113 * <pre> (Optional) 114 * +---------------+ 115 * |PassPhraseAgent| 116 * +-------+-------+ 117 * |PassPhrase 118 * +-------------------+ +---+----+ 119 * |Signing Application|--Data-->| Signer | 120 * +--------+----------+ +---+----+ 121 * +-<-----Signature--------+</pre> 122 */ 123 public interface Signer { 124 /*** 125 * Signs the data with the privatekey of the given name 126 * 127 * @param name Alias of private key to be used within KeyStore 128 * @param data Data to be signed 129 * @return The signature 130 */ 131 132 public byte[] sign(String name, byte data[]) throws UserCancellationException, NonExistingSignerException; 133 134 // public void addKey(String name, char passphrase[], PrivateKey key) throws GeneralSecurityException, IOException ; 135 136 /*** 137 * Returns true if the Signer contains a signer for the given name 138 * 139 * @param name 140 * @return true if signer is contained 141 */ 142 public boolean canSignFor(String name); 143 144 145 /*** 146 * Checks the key type of the given alias 147 * 148 * @param name 149 * @return KEY_NONE,KEY_RSA,KEY_DSA 150 */ 151 public int getKeyType(String name); 152 153 /*** 154 * Creates a new KeyPair, stores the PrivateKey using the given alias 155 * and returns the PublicKey. 156 * 157 * @param alias 158 * @return Generated PublicKey 159 * @throws UserCancellationException 160 */ 161 public PublicKey generateKey(String alias) throws UserCancellationException; 162 163 /*** 164 * Creates a new KeyPair, stores the PrivateKey using the base32 sha1 of the public key as it's alias 165 * and returns the PublicKey. 166 * 167 * @return Generated PublicKey 168 * @throws UserCancellationException 169 */ 170 public PublicKey generateKey() throws UserCancellationException; 171 172 final public static int KEY_NONE = 0; 173 final public static int KEY_RSA = 1; 174 final public static int KEY_DSA = 2; 175 final public static int KEY_OTHER = -1; 176 177 void save() throws UserCancellationException; 178 179 }

This page was automatically generated by Maven