Class AuthenticationPane

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class AuthenticationPane extends JComponent
Authenticator GUI component.

Typical usage: Authenticator.setDefault(AuthenticationPane.getAuthenticator(component)); where component is a component on which to center a dialog that is created when interaction with the user is necessary.

If the server does not have a certificate signed by a certificate authority, SSL will have to be configured to handle this case. The class SSLUtilities has methods that can handle this situation. The class ConfigPropUtilities may also be useful.

See Also:
  • Method Details

    • setPrivateKey

      public static void setPrivateKey(File pemfile) throws IllegalArgumentException
      Set the default private key for secure basic authentication. The file's extension should be ".pem", ".pem.gpg" when the file is GPG encrypted, or ".sbl" if the file was created with the program sbl.
      Parameters:
      pemfile - a file, possibly encrypted, in PEM format containing the private key; null to remove the default private key
      Throws:
      IllegalArgumentException - if the argument is not an ordinary file, is not readable, or has the wrong extension
    • setPrivateKey

      public static void setPrivateKey(Authenticator authenticator, File pemfile)
      Set the private key for secure basic authentication for a specific authenticator. This method should be used when there are multiple authenticators, some with an authenticator-specific private key. The file-name extensions should be either
      • .pem if the file is a PEM file.
      • .pem.gpg if the file is a GPG-encrypted PEM file.
      • .sbl if the file is a saved sbl configuration.
      Parameters:
      authenticator - the authenticator
      pemfile - a file, possibly encrypted, in PEM format containing the private key, or a file created with the program sbl; null to remove the authenticator-specific key
      Throws:
      IllegalArgumentException - if the second argument is not an ordinary file, is not readable, or has the wrong extension
    • requestPassphrase

      public static void requestPassphrase(Component owner)
      Request a GPG passphrase. This method will open a dialog box to request a GPG passphrase for decryption. GPG encryption can be optionally used to protect a private key when Secure Basic Authentication is used.
      Parameters:
      owner - a component over which a dialog box should be displayed
    • clearPassphrase

      public static void clearPassphrase()
      Remove the current GPG passphrase. As a general rule, this method should be called as soon as a passphrase is no longer needed, or will not be needed for some time.
    • setTimeLimit

      public static void setTimeLimit(long limit)
      Set the time limit used to determine if multiple authentication failures for cached entries are occurring close to each other in time to indicate that the user should be queried. The default value is 60 seconds.

      Ideally this would not be necessary, but the Java API for an Authenticator does not allow us to determine whether a failed authentication request was generated by this authenticator or by a cached value stored elsewhere.

      The value should be large enough to account for a server that is heavily overloaded. When a server is on a local-area network and is not going to be overloaded, a much lower value than the default is appropriate.

      Parameters:
      limit - the limit in milliseconds
    • getAuthenticator

      public static Authenticator getAuthenticator(Component comp)
      Get an authenticator for network authentication requests. This is equivalent to getAuthenticator(comp,true).

      Parameters:
      comp - the component on which a dialog box should be centered when an authentication request is given to the user
      Returns:
      an authenticator
      See Also:
    • getAuthenticator

      public static Authenticator getAuthenticator(Component comp, boolean withMap)
      Get an authenticator for network authentication requests, optionally placing the authenticator in a map.

      When the argument withMap is true, the user names and passwords entered in a dialog box will be saved for future use so that new secure-basic passwords can be generated as needed without querying the user.

      Parameters:
      comp - the component on which a dialog box should be centered when an authentication request is given to the user
      withMap - true if the authenticator maps URLs to results; false otherwise
      Returns:
      an authenticator
      See Also: