|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.jdesktop.swingx.JXPanel
org.jdesktop.swingx.JXLoginPane
public class JXLoginPane
JXLoginPane is a specialized JPanel that implements a Login dialog with support for saving passwords supplied for future use in a secure manner. LoginService is invoked to perform authentication and optional PasswordStore can be provided to store the user login information.
In order to perform the authentication, JXLoginPane
calls the authenticate
method of the LoginService
. In order to perform the persistence of the password,
JXLoginPane calls the put method of the
PasswordStore object that is supplied. If
the PasswordStore is null
, then the password
is not saved. Similarly, if a PasswordStore is
supplied and the password is null, then the PasswordStore
will be queried for the password using the get
method.
Example:
final JXLoginPane panel = new JXLoginPane(new LoginService() {
public boolean authenticate(String name, char[] password,
String server) throws Exception {
// perform authentication and return true on success.
return false;
}});
final JFrame frame = JXLoginPane.showLoginFrame(panel);
Nested Class Summary | |
---|---|
static class |
JXLoginPane.JXLoginDialog
|
static class |
JXLoginPane.JXLoginFrame
|
protected class |
JXLoginPane.LoginListenerImpl
Listener class to track state in the LoginService |
static class |
JXLoginPane.SaveMode
The JXLoginPane can attempt to save certain user information such as the username, password, or both to their respective stores. |
static class |
JXLoginPane.Status
Returns the status of the login process |
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
JPanel.AccessibleJPanel |
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.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static String |
CANCEL_LOGIN_ACTION_COMMAND
Action key for an Action in the ActionMap that cancels the Login procedure |
static String |
LOGIN_ACTION_COMMAND
Action key for an Action in the ActionMap that initiates the Login procedure |
static String |
uiClassID
UI Class ID |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, 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 |
---|
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 |
Constructor Summary | |
---|---|
JXLoginPane()
Create a JXLoginPane that always accepts the user, never stores
passwords or user ids, and has no target servers. |
|
JXLoginPane(LoginService service)
Create a JXLoginPane with the specified LoginService
that does not store user ids or passwords and has no target servers. |
|
JXLoginPane(LoginService service,
PasswordStore passwordStore,
UserNameStore userStore)
Create a JXLoginPane with the specified LoginService ,
PasswordStore , and UserNameStore , but without a server
list. |
|
JXLoginPane(LoginService service,
PasswordStore passwordStore,
UserNameStore userStore,
List<String> servers)
Create a JXLoginPane with the specified LoginService ,
PasswordStore , UserNameStore , and server list. |
Method Summary | |
---|---|
void |
addNotify()
Notifies this component that it now has a parent component. |
protected void |
cancelLogin()
Cancels the login procedure. |
protected Action |
createCancelAction()
Create and return an Action for canceling login |
protected Action |
createLoginAction()
Create and return an Action for logging in |
protected Image |
createLoginBanner()
Create and return an image to use for the Banner. |
Image |
getBanner()
Return the image used as the banner |
String |
getBannerText()
Returns text used when creating the banner |
String |
getErrorMessage()
Returns the error message for this login panel |
LoginService |
getLoginService()
Gets the LoginService for this panel. |
String |
getMessage()
Returns the custom message for this login panel |
char[] |
getPassword()
Gets the Password for this panel. |
PasswordStore |
getPasswordStore()
Gets the PasswordStore for this panel. |
JXLoginPane.SaveMode |
getSaveMode()
|
List<String> |
getServers()
|
JXLoginPane.Status |
getStatus()
Returns the panel's status |
LoginPaneUI |
getUI()
Returns the look and feel (L&F) object that renders this component. |
String |
getUIClassID()
Returns the name of the L&F class that renders this component. |
String |
getUserName()
Gets the User name for this panel. |
UserNameStore |
getUserNameStore()
Gets the UserNameStore for this panel. |
boolean |
isCapsLockDetectionSupported()
Check current state of the caps lock state detection. |
boolean |
isCapsLockOn()
Gets current state of the caps lock as seen by the login panel. |
boolean |
isRememberPassword()
|
boolean |
isUserNameEnabled()
Gets current state of the user name field. |
protected void |
recreateLoginPanel()
Recreates the login panel, and replaces the current one with the new one |
void |
removeNotify()
Notifies this component that it no longer has a parent component. |
protected void |
savePassword()
Puts the password into the password store. |
void |
setBanner(Image img)
Set the image to use for the banner. |
void |
setBannerText(String text)
Set the text to use when creating the banner. |
void |
setComponentOrientation(ComponentOrientation orient)
This method adds functionality to support bidi languages within this component |
void |
setErrorMessage(String errorMessage)
Sets the error message for this login panel |
void |
setLocale(Locale l)
Sets the locale of this component. |
void |
setLoginService(LoginService service)
Sets the LoginService for this panel. |
void |
setMessage(String message)
Sets a custom message for this login panel |
void |
setPassword(char[] password)
Sets the Password for this panel. |
void |
setPasswordStore(PasswordStore store)
Sets the PasswordStore for this panel. |
void |
setSaveMode(JXLoginPane.SaveMode saveMode)
The save mode indicates whether the "save" password is checked by default. |
void |
setServers(List<String> servers)
Sets the list of servers. |
protected void |
setStatus(JXLoginPane.Status newStatus)
Change the status |
void |
setUI(LoginPaneUI ui)
Sets the look and feel (L&F) object that renders this component. |
void |
setUserName(String username)
Sets the User name for this panel. |
void |
setUserNameEnabled(boolean enabled)
Enables or disables User name for this panel. |
void |
setUserNameStore(UserNameStore store)
Sets the user name store for this panel. |
static JXLoginPane.Status |
showLoginDialog(Component parent,
JXLoginPane panel)
Shows a login dialog. |
static JXLoginPane.Status |
showLoginDialog(Component parent,
LoginService svc)
Shows a login dialog. |
static JXLoginPane.Status |
showLoginDialog(Component parent,
LoginService svc,
PasswordStore ps,
UserNameStore us)
Shows a login dialog. |
static JXLoginPane.Status |
showLoginDialog(Component parent,
LoginService svc,
PasswordStore ps,
UserNameStore us,
List<String> servers)
Shows a login dialog. |
static JXLoginPane.JXLoginFrame |
showLoginFrame(JXLoginPane panel)
|
static JXLoginPane.JXLoginFrame |
showLoginFrame(LoginService svc)
Shows a login frame. |
static JXLoginPane.JXLoginFrame |
showLoginFrame(LoginService svc,
PasswordStore ps,
UserNameStore us)
|
static JXLoginPane.JXLoginFrame |
showLoginFrame(LoginService svc,
PasswordStore ps,
UserNameStore us,
List<String> servers)
|
protected void |
startLogin()
Initiates the login procedure. |
void |
updateUI()
Notification from the UIManager that the L&F has changed. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, paramString, setUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String uiClassID
public static final String LOGIN_ACTION_COMMAND
public static final String CANCEL_LOGIN_ACTION_COMMAND
Constructor Detail |
---|
public JXLoginPane()
JXLoginPane
that always accepts the user, never stores
passwords or user ids, and has no target servers.
This constructor should NOT be used in a real application. It is provided for compliance to the bean specification and for use with visual editors.
public JXLoginPane(LoginService service)
JXLoginPane
with the specified LoginService
that does not store user ids or passwords and has no target servers.
service
- the LoginService
to use for logging inpublic JXLoginPane(LoginService service, PasswordStore passwordStore, UserNameStore userStore)
JXLoginPane
with the specified LoginService
,
PasswordStore
, and UserNameStore
, but without a server
list.
If you do not want to store passwords or user ids, those parameters can
be null
. SaveMode
is autoconfigured from passed in store
parameters.
service
- the LoginService
to use for logging inpasswordStore
- the PasswordStore
to use for storing password
informationuserStore
- the UserNameStore
to use for storing user informationpublic JXLoginPane(LoginService service, PasswordStore passwordStore, UserNameStore userStore, List<String> servers)
JXLoginPane
with the specified LoginService
,
PasswordStore
, UserNameStore
, and server list.
If you do not want to store passwords or user ids, those parameters can
be null
. SaveMode
is autoconfigured from passed in store
parameters.
Setting the server list to null
will unset all of the servers.
The server list is guaranteed to be non-null
.
service
- the LoginService
to use for logging inpasswordStore
- the PasswordStore
to use for storing password
informationuserStore
- the UserNameStore
to use for storing user informationservers
- a list of servers to authenticate againstMethod Detail |
---|
public boolean isCapsLockOn()
isCapsLockDetectionSupported()
returns false.public boolean isCapsLockDetectionSupported()
public LoginPaneUI getUI()
getUI
in class JPanel
public void setUI(LoginPaneUI ui)
ui
- the LoginPaneUI L&F objectUIDefaults.getUI(javax.swing.JComponent)
public void updateUI()
UIManager
that the L&F has changed.
Replaces the current UI object with the latest version from the
UIManager
.
updateUI
in class JPanel
JComponent.updateUI()
public String getUIClassID()
getUIClassID
in class JPanel
uiClassID
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
protected void recreateLoginPanel()
public void setComponentOrientation(ComponentOrientation orient)
setComponentOrientation
in class Component
ComponentOrientation
protected Image createLoginBanner()
protected Action createLoginAction()
protected Action createCancelAction()
public JXLoginPane.SaveMode getSaveMode()
public void setSaveMode(JXLoginPane.SaveMode saveMode)
saveMode
- The saveMode to set either SAVE_NONE, SAVE_PASSWORD or SAVE_USERNAMEpublic boolean isRememberPassword()
public List<String> getServers()
public void setServers(List<String> servers)
public void setLoginService(LoginService service)
LoginService
for this panel. Setting the login service
to null
will actually set the service to use
NullLoginService
.
service
- the service to set. If service == null
, then a
NullLoginService
is used.public LoginService getLoginService()
public void setPasswordStore(PasswordStore store)
store
- PasswordStorepublic UserNameStore getUserNameStore()
UserNameStore
for this panel.
UserNameStore
public void setUserNameStore(UserNameStore store)
store
- public PasswordStore getPasswordStore()
public void setUserName(String username)
username
- User namepublic void setUserNameEnabled(boolean enabled)
enabled
- public boolean isUserNameEnabled()
public String getUserName()
public void setPassword(char[] password)
password
- Passwordpublic char[] getPassword()
public Image getBanner()
public void setBanner(Image img)
img
is null
,
then no image will be displayed.
img
- the image to displaypublic void setBannerText(String text)
text
is null
, then
no text is displayed.
text
- the text to displaypublic String getBannerText()
public String getMessage()
public void setMessage(String message)
public String getErrorMessage()
public void setErrorMessage(String errorMessage)
public JXLoginPane.Status getStatus()
protected void setStatus(JXLoginPane.Status newStatus)
public void setLocale(Locale l)
java.awt.Component
setLocale
in class Component
l
- the locale to become this component's localeComponent.getLocale()
protected void startLogin()
getSynchronous()
returns true.
protected void cancelLogin()
startAuthentications()
and only when
authentication is performed asynchronously (getSynchronous()
returns false).
protected void savePassword()
public void removeNotify()
javax.swing.JComponent
KeyboardAction
s
set up in the the chain of parent components are removed.
removeNotify
in class JComponent
JComponent.registerKeyboardAction(java.awt.event.ActionListener, java.lang.String, javax.swing.KeyStroke, int)
public void addNotify()
javax.swing.JComponent
KeyboardAction
event listeners.
addNotify
in class JComponent
JComponent.registerKeyboardAction(java.awt.event.ActionListener, java.lang.String, javax.swing.KeyStroke, int)
public static JXLoginPane.Status showLoginDialog(Component parent, LoginService svc)
public static JXLoginPane.Status showLoginDialog(Component parent, LoginService svc, PasswordStore ps, UserNameStore us)
public static JXLoginPane.Status showLoginDialog(Component parent, LoginService svc, PasswordStore ps, UserNameStore us, List<String> servers)
public static JXLoginPane.Status showLoginDialog(Component parent, JXLoginPane panel)
public static JXLoginPane.JXLoginFrame showLoginFrame(LoginService svc)
public static JXLoginPane.JXLoginFrame showLoginFrame(LoginService svc, PasswordStore ps, UserNameStore us)
public static JXLoginPane.JXLoginFrame showLoginFrame(LoginService svc, PasswordStore ps, UserNameStore us, List<String> servers)
public static JXLoginPane.JXLoginFrame showLoginFrame(JXLoginPane panel)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |