org.neuclear.commons.crypto.passphraseagents
Class ServletPassPhraseAgent

java.lang.Object
  extended by java.lang.ThreadLocal
      extended by org.neuclear.commons.crypto.passphraseagents.ServletPassPhraseAgent
All Implemented Interfaces:
InteractiveAgent, PassPhraseAgent

public class ServletPassPhraseAgent
extends java.lang.ThreadLocal
implements InteractiveAgent

PassPhraseAgent for use in server environments. You set the passphrase first by passing it a signers request. It fetches the passphrase from the paramater "passphrase"

WARNING The sequence of events is very important for the safe usage of this. The following is an example within a standard doPost() method.

  1. agent.setRequest(request); // Set the request
  2. signer.sign(data);// Sign some data
  3. agent.clear();// The moment we have used the passphrase we have to clear it
Note, the above assumes that a Signer with the name signer was initialised in init() with a ServletPassPhraseAgent called agent.

See Also:
Signer

Constructor Summary
ServletPassPhraseAgent()
           
 
Method Summary
 void clear()
          Clears the passphrase.
 char[] getNewPassPhrase(java.lang.String name)
           
 java.io.File getOpenFileName(java.lang.String title, java.lang.String def)
           
 char[] getPassPhrase(BrowsableSigner signer)
          The User is asked to pick a name by the PassPhraseAgent.
 char[] getPassPhrase(java.lang.String name)
          Gets the passphrase if set or null
 char[] getPassPhrase(java.lang.String name, boolean incorrect)
           
 java.io.File getSaveToFileName(java.lang.String title, java.lang.String def)
           
 void setRequest(javax.servlet.http.HttpServletRequest request)
          Set the passphrase from the request object.
 byte[] sign(BrowsableSigner signer, byte[] data, SetPublicKeyCallBack callback)
          The User is asked to pick a name by the PassPhraseAgent.
 
Methods inherited from class java.lang.ThreadLocal
get, initialValue, remove, set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletPassPhraseAgent

public ServletPassPhraseAgent()
Method Detail

setRequest

public void setRequest(javax.servlet.http.HttpServletRequest request)
Set the passphrase from the request object.

Parameters:
request -

getPassPhrase

public char[] getPassPhrase(java.lang.String name)
Gets the passphrase if set or null

Specified by:
getPassPhrase in interface PassPhraseAgent
Parameters:
name -
Returns:

clear

public void clear()
Clears the passphrase. (Important, you have to manually call this at the end of the request code, or better yet immediately after using your Signer).


getPassPhrase

public char[] getPassPhrase(java.lang.String name,
                            boolean incorrect)
                     throws UserCancellationException
Specified by:
getPassPhrase in interface PassPhraseAgent
Throws:
UserCancellationException

getPassPhrase

public char[] getPassPhrase(BrowsableSigner signer)
                     throws UserCancellationException
The User is asked to pick a name by the PassPhraseAgent. The PassPhraseAgent can query the given signer for a list of included aliases or even create a new keypair.

Returns:
Throws:
UserCancellationException

sign

public byte[] sign(BrowsableSigner signer,
                   byte[] data,
                   SetPublicKeyCallBack callback)
            throws UserCancellationException
The User is asked to pick a name by the PassPhraseAgent. The PassPhraseAgent can query the given signer for a list of included aliases or even create a new keypair.

Specified by:
sign in interface InteractiveAgent
Returns:
Throws:
UserCancellationException

getSaveToFileName

public java.io.File getSaveToFileName(java.lang.String title,
                                      java.lang.String def)
                               throws UserCancellationException
Specified by:
getSaveToFileName in interface InteractiveAgent
Throws:
UserCancellationException

getOpenFileName

public java.io.File getOpenFileName(java.lang.String title,
                                    java.lang.String def)
                             throws UserCancellationException
Specified by:
getOpenFileName in interface InteractiveAgent
Throws:
UserCancellationException

getNewPassPhrase

public char[] getNewPassPhrase(java.lang.String name)
                        throws UserCancellationException
Specified by:
getNewPassPhrase in interface InteractiveAgent
Throws:
UserCancellationException


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