issrg.security
Class FilenameCallback

java.lang.Object
  extended by javax.security.auth.callback.NameCallback
      extended by issrg.security.FilenameCallback
All Implemented Interfaces:
java.io.Serializable, javax.security.auth.callback.Callback

public class FilenameCallback
extends javax.security.auth.callback.NameCallback

This class represents a Filename Callback, which is used by CallbackHandler at the login stage. It helps the CallbackHandler display the right controls to select the right file (correct type and extension). By extending from NameCallback it is ensured that even CallbackHandlers that do not distinguish this special type of callback will still be able to let the user authenticate.

See Also:
Serialized Form

Constructor Summary
FilenameCallback(java.lang.String prompt, java.lang.String defaultFile, java.lang.String searchType, java.lang.String[] extensions)
          This constructor builds the FilenameCallback given the bunch of parameters describing the valid files.
 
Method Summary
 java.lang.String getDefaultFile()
          This method returns the default file name to be used if the user didn't select a new file name.
 java.lang.String[] getExtensions()
          This method returns the array of filename extensions to help filter out wrong candidate files in the OpenFile dialog.
 java.lang.String getFileName()
          This method returns the filename that was actiually selected by the user.
 java.lang.String getSearchType()
          This method returns the search type, which is a human-readable string, useful in OpenFile dialogs (it is the human-readable name of the file types, usually displayed in the drop-down list box with filename filters in it).
 void setFileName(java.lang.String fn)
          This method sets the filename that the user selected.
 
Methods inherited from class javax.security.auth.callback.NameCallback
getDefaultName, getName, getPrompt, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilenameCallback

public FilenameCallback(java.lang.String prompt,
                        java.lang.String defaultFile,
                        java.lang.String searchType,
                        java.lang.String[] extensions)
This constructor builds the FilenameCallback given the bunch of parameters describing the valid files. These values can be retrieved by corresponding get* methods.

Parameters:
prompt - - the prompt to be displayed next to the text input control
defaultFile - - the default file name that the CallbackHandler should assume if no input was collected from the user
searchType - - the human-readable string that hints what type of file the user should be looking for; useful for constructing FileOpen dialogs and such
extensions - - the set of extensions that the acceptable file must have; useful for constructing FileOpen dialogs
Method Detail

getDefaultFile

public java.lang.String getDefaultFile()
This method returns the default file name to be used if the user didn't select a new file name.

Returns:
String file name; can be null, if no default file name was specified

getSearchType

public java.lang.String getSearchType()
This method returns the search type, which is a human-readable string, useful in OpenFile dialogs (it is the human-readable name of the file types, usually displayed in the drop-down list box with filename filters in it).

Returns:
String giving the filename filter a human-readable description; can be null

getExtensions

public java.lang.String[] getExtensions()
This method returns the array of filename extensions to help filter out wrong candidate files in the OpenFile dialog.

Returns:
an array of String, each naming a single acceptable filename extension; can be null

getFileName

public java.lang.String getFileName()
This method returns the filename that was actiually selected by the user. It returns the same value as getName method inherited from NameCallback.

Returns:
String filename of the file selected by the user; can be null, if no file has been selected

setFileName

public void setFileName(java.lang.String fn)
This method sets the filename that the user selected. It also sets it as the name of the user. Note that this makes sense where two-factor authentication is used, with one being a file and the second being the password to decrypt it.

Parameters:
fn - - the filename that the user selected