- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable
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:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Method Summary
Modifier and TypeMethodDescriptionstatic URIaddSBLFile(File sblfile) Add an SBL file.static URIaddSBLFile(File sblfile, String key) Add an SBL file with a key.static URIAdd an SBL file given an input stream.static URIaddSBLFile(InputStream is, String key) Add an SBL file given an input stream and a key.static voidRemove the current GPG passphrase.static AuthenticatorgetAuthenticator(Component comp) Get an authenticator for network authentication requests.static AuthenticatorgetAuthenticator(Component comp, boolean withMap) Get an authenticator for network authentication requests, optionally requesting a map that stores data entered via a dialog box so that new secure-basic passwords can be generated without needlessly querying a user.static URIgetLoginURI(URI uri) static voidrequestPassphrase(Component owner) Request a GPG passphrase.static voidSet the GPG home directory given a file name.static voidsetGPGHome(File gpgdir) Set the GPG home directory given aFile.static voidsetPrivateKey(File pemfile) Set the default private key for secure basic authentication.static voidsetTimeLimit(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.Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUIMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Method Details
-
setPrivateKey
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.This can be used for simple cases where an SBL file is not available, in which case the user will have to enter a user name and password in addition to a passphrase when necessary to decrypt the private key.
- 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
-
getLoginURI
- Throws:
URISyntaxException
-
setGPGHome
Set the GPG home directory given aFile. The argument is a file whose name is used as the --homedir argument for gpg commands.- Parameters:
gpgdir- the GPG home directory; null for the default- Throws:
IOException- if an IO error occurs while constructing a cannonical path
-
setGPGDir
Set the GPG home directory given a file name. The argument is the directory name used as the --homedir argument for gpg commands.- Parameters:
gpgdir- the GPG home directory; null for the default
-
addSBLFile
Add an SBL file given an input stream. SBL files can be created by the program sbl and store private and public keys for creating and verifying secure one-time passwords. These files include some subsidiary data including URIs for logins, etc.- Parameters:
is- the input stream containing the SBL file- Returns:
- the first URI to visit when logging in
- Throws:
IOExceptionURISyntaxException
-
addSBLFile
Add an SBL file given an input stream and a key. SBL files can be created by the program sbl and store private and public keys for creating and verifying secure one-time passwords. These files include some subsidiary data including URIs for logins, etc.A key is the first component of a compound key in an SBL file, excluding an initial "base64" or "ebase64". This allows multiple web sites or portions of a web site to be handled by a single SBL file.
- Parameters:
is- the input stream containing the SBL filekey- the key- Returns:
- the first URI to visit when logging in
- Throws:
IOExceptionURISyntaxException
-
addSBLFile
Add an SBL file. SBL files can be created by the program sbl and store private and public keys for creating and verifying secure one-time passwords. These files include some subsidiary data including URIs for logins, etc.- Parameters:
sblfile- the SBL file- Returns:
- the first URI to visit when logging in
- Throws:
IOExceptionURISyntaxException
-
addSBLFile
Add an SBL file with a key. SBL files can be created by the program sbl and store private and public keys for creating and verifying secure one-time passwords. These files include some subsidiary data including URIs for logins, etc. See sections 1 and 5 of the manual for a description of sbl.A key is the first component of a compound key, excluding an initial "base64" or "ebase64". This allows multiple web sites or portions of a web site to be handled by a single SBL file.
- Parameters:
sblfile- the SBL filekey- the key- Returns:
- the first URI to visit when logging in
- Throws:
IOExceptionURISyntaxException
-
requestPassphrase
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
Authenticatordoes 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
Get an authenticator for network authentication requests. This is equivalent togetAuthenticator(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
Get an authenticator for network authentication requests, optionally requesting a map that stores data entered via a dialog box so that new secure-basic passwords can be generated without needlessly querying a user.- Parameters:
comp- the component on which a dialog box should be centered when an authentication request is given to the userwithMap- true if the authenticator maps keys based on schemes, hoste, ports, and realms with data that would otherwise be obtained from a dialog box; false otherwise- Returns:
- an authenticator
- See Also:
-