- 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 classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested 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_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Remove the current GPG passphrase.static Authenticator
getAuthenticator
(Component comp) Get an authenticator for network authentication requests.static Authenticator
getAuthenticator
(Component comp, boolean withMap) Get an authenticator for network authentication requests, optionally placing the authenticator in a map.static void
requestPassphrase
(Component owner) Request a GPG passphrase.static void
setPrivateKey
(File pemfile) Set the default private key for secure basic authentication.static void
setPrivateKey
(Authenticator authenticator, File pemfile) Set the private key for secure basic authentication for a specific authenticator.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.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, updateUI
Methods 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, validateTree
Methods 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.- 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
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 authenticatorpemfile
- 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
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
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 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 userwithMap
- true if the authenticator maps URLs to results; false otherwise- Returns:
- an authenticator
- See Also:
-