com.sshtools.ui.swing
Class PersistantAuthenticator

java.lang.Object
  extended by java.net.Authenticator
      extended by com.sshtools.ui.swing.PersistantAuthenticator

public class PersistantAuthenticator
extends java.net.Authenticator


Nested Class Summary
 
Nested classes/interfaces inherited from class java.net.Authenticator
java.net.Authenticator.RequestorType
 
Constructor Summary
PersistantAuthenticator()
          Creates a new GruntspudAuthenticator.
 
Method Summary
 java.lang.Throwable getException()
          Return the last exception
 javax.swing.Icon getIcon(java.lang.String scheme, int iconSize)
           
 int getIconSize()
           
 java.awt.Component getParent()
          Get the current parent component
protected  java.net.PasswordAuthentication getPasswordAuthentication()
           
 PasswordPairList getPasswordPairList()
          Return a list of all the password pairs
 char[] getPasswordSafeSecret(java.lang.String message, java.lang.String text, java.awt.Component parent)
          Show a dialog asking for the password safe secret
 void init()
          Initialise the authenticator.
 boolean isForceAskForPassword()
          Get if the password will be asked for no matter what.
 void removePassword(PasswordPair pair)
          Remove a password pair from the list.
 void setAllowEmptyPassword(boolean allowEmptyPassword)
           
static void setDirectory(java.io.File prefDir)
          Set the directory where the passwords will be store
 void setEmphasisePrompt(boolean emphasisePrompt)
          Set if the next request for a password should emphasise the 'prompt' field by colouring it red.
 void setForceAskForPassword(boolean forceAskForPassword)
          Set whether the master password should be asked for if it is needed.
 void setIconSize(int iconSize)
           
 void setInitialPassword(java.lang.String initialPassword)
          Set the initial password.
 void setParentComponent(java.awt.Component parent)
          Set the parent component to use as a parent for the modal authentication dialog (should it be displayed).
 void setUserName(java.lang.String userName)
          Set the user name to use next time a password is requested
 char[][] showMasterPasswordConfirmationDialog(javax.swing.JComponent parent, java.lang.String text, java.lang.String title, boolean checkAgainstOld)
          Show a dialog asking the use for a new password safe secret.
 void updateUI()
           
 
Methods inherited from class java.net.Authenticator
getRequestingHost, getRequestingPort, getRequestingPrompt, getRequestingProtocol, getRequestingScheme, getRequestingSite, getRequestingURL, getRequestorType, requestPasswordAuthentication, requestPasswordAuthentication, requestPasswordAuthentication, setDefault
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistantAuthenticator

public PersistantAuthenticator()
Creates a new GruntspudAuthenticator.

Parameters:
context - context
Throws:
java.io.IOException
Method Detail

setInitialPassword

public void setInitialPassword(java.lang.String initialPassword)
Set the initial password. This is used if no password has ever been stored. If this is set the password will not be prompted for unless force is or a password has already been stored. The value must be null to unset. The value is reset once the authenticator has been used.

Parameters:
initialPassword - initial password

getParent

public java.awt.Component getParent()
Get the current parent component

Returns:
parent

setDirectory

public static void setDirectory(java.io.File prefDir)
Set the directory where the passwords will be store

Parameters:
dir - directory

getPasswordPairList

public PasswordPairList getPasswordPairList()
Return a list of all the password pairs

Returns:
password pair list

removePassword

public void removePassword(PasswordPair pair)
                    throws java.lang.Exception
Remove a password pair from the list.

Parameters:
pair -
Throws:
java.lang.Exception

init

public void init()
          throws java.io.IOException
Initialise the authenticator. Should be called just after instantiation

Parameters:
context - context
Throws:
java.io.IOException - if password list cannot be loaded

showMasterPasswordConfirmationDialog

public char[][] showMasterPasswordConfirmationDialog(javax.swing.JComponent parent,
                                                     java.lang.String text,
                                                     java.lang.String title,
                                                     boolean checkAgainstOld)
Show a dialog asking the use for a new password safe secret. The user must enter the same secret twice, then an 2 element array of the old password and new password as a char[] array is returned. If the user cancels null will be returned.

Parameters:
context - context
parent - parent component
text - help text
title - dialog title
checkAgainstOld - make sure the old secret matches first
Returns:
2 element array of char[], first element is old secret, second is new

getPasswordSafeSecret

public char[] getPasswordSafeSecret(java.lang.String message,
                                    java.lang.String text,
                                    java.awt.Component parent)
Show a dialog asking for the password safe secret

Parameters:
message - message to show
text - text
parent - parent component
Returns:
password safe secret (or null if aborted)

setForceAskForPassword

public void setForceAskForPassword(boolean forceAskForPassword)
Set whether the master password should be asked for if it is needed. This should be set just before any operation that might require the use of a password is run.

Parameters:
forceAskForPassword - always ask for the master password next time it is needed

setEmphasisePrompt

public void setEmphasisePrompt(boolean emphasisePrompt)
Set if the next request for a password should emphasise the 'prompt' field by colouring it red. This would normally be used if this is the second request for a password as the first one was incorrect in some way.

Parameters:
emphasisePrompt - emphasis prompt

setParentComponent

public void setParentComponent(java.awt.Component parent)
Set the parent component to use as a parent for the modal authentication dialog (should it be displayed).

Parameters:
parent - parent component

setUserName

public void setUserName(java.lang.String userName)
Set the user name to use next time a password is requested

Parameters:
userName - user name

updateUI

public void updateUI()

setAllowEmptyPassword

public void setAllowEmptyPassword(boolean allowEmptyPassword)

getPasswordAuthentication

protected java.net.PasswordAuthentication getPasswordAuthentication()
Overrides:
getPasswordAuthentication in class java.net.Authenticator

setIconSize

public void setIconSize(int iconSize)

getIconSize

public int getIconSize()

getIcon

public javax.swing.Icon getIcon(java.lang.String scheme,
                                int iconSize)

getException

public java.lang.Throwable getException()
Return the last exception

Returns:
last exceptoion

isForceAskForPassword

public boolean isForceAskForPassword()
Get if the password will be asked for no matter what.

Returns:
force ask for password


Copyright © 2003-2009 SSHTOOLS LTD. All Rights Reserved.