org.springframework.richclient.security
Class LoginCommand

java.lang.Object
  extended by org.springframework.binding.value.support.AbstractPropertyChangePublisher
      extended by org.springframework.richclient.command.AbstractCommand
          extended by org.springframework.richclient.command.ActionCommand
              extended by org.springframework.richclient.command.support.ApplicationWindowAwareCommand
                  extended by org.springframework.richclient.security.LoginCommand
All Implemented Interfaces:
BeanNameAware, InitializingBean, PropertyChangePublisher, ApplicationWindowAware, ActionCommandExecutor, GuardedActionCommandExecutor, ParameterizableActionCommandExecutor, Authorizable, Guarded, SecurityControllable

public class LoginCommand
extends ApplicationWindowAwareCommand

Provides a login interface to the user.

Presents a dialog to the user to collect login credentials. It then invokes the ApplicationSecurityManager.doLogin(org.acegisecurity.Authentication) method to validate the credentials. The ApplicationSecurityManager is responsible for updating the security context and firing appropriate security events.

The default user name can be specified as a configuration parameter. This is useful when combined with PropertyPlaceholderConfigurer to install the current (system) username.

If the login is unsuccesful, a message is presented to the user and they are offered another chance to login.

The closeOnCancel property controls what happens if the user cancels the login dialog. If closeOnCancel is true (the default), if there is no valid authentication in place (from a previous login) then the application is closed. If it is false or an authentication token is available, then no action is taken other than closing the dialog.

The clearPasswordOnFailure controls the handling of the password field after a login failure. If clearPasswordOnFailure is true (the default), then the password field will be cleared after the failure is reported.

A typical configuration for this component might look like this:

        <bean id="placeholderConfigurer"
             class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>

         <bean id="loginCommand"
             class="org.springframework.richclient.security.LoginCommand">
             <property name="displaySuccess" value="false"/>
             <property name="defaultUserName" value="${user.name}"/>
         </bean>
 

Author:
Ben Alex, Larry Streepy
See Also:
LoginForm, LoginDetails, ApplicationSecurityManager

Field Summary
 
Fields inherited from class org.springframework.richclient.command.ActionCommand
ACTION_COMMAND_PARAMETER_KEY, ACTION_COMMAND_PROPERTY, ACTION_EVENT_PARAMETER_KEY, MODIFIERS_PARAMETER_KEY
 
Fields inherited from class org.springframework.richclient.command.AbstractCommand
ENABLED_PROPERTY_NAME, VISIBLE_PROPERTY_NAME
 
Fields inherited from class org.springframework.binding.value.support.AbstractPropertyChangePublisher
logger
 
Fields inherited from interface org.springframework.richclient.core.Authorizable
AUTHORIZED_PROPERTY
 
Constructor Summary
LoginCommand()
          Constructor.
 
Method Summary
protected  LoginForm createLoginForm()
          Construct the Form to place in the login dialog.
protected  void doExecuteCommand()
          Execute the login command.
 String getDefaultUserName()
          Get the default user name.
protected  ApplicationDialog getDialog()
          Get the dialog in use, if available.
 boolean isClearPasswordOnFailure()
          Get the "clear password on failure" setting.
 boolean isCloseOnCancel()
          Get the "close on cancel" setting.
protected  void postLogin()
          Called to give subclasses control after a successful login.
 void setClearPasswordOnFailure(boolean clearPasswordOnFailure)
          Indicates if the password field should be cleared after a login failure.
 void setCloseOnCancel(boolean closeOnCancel)
          Indicates if the application should be closed if the user cancels the login operation.
 void setDefaultUserName(String defaultUserName)
          Set the default user name.
 void setDisplaySuccess(boolean displaySuccessMessage)
          Indicates whether an information message is displayed to the user upon successful authentication.
 
Methods inherited from class org.springframework.richclient.command.support.ApplicationWindowAwareCommand
getApplicationWindow, getParentWindowControl, setApplicationWindow
 
Methods inherited from class org.springframework.richclient.command.ActionCommand
addCommandInterceptor, addParameter, execute, execute, getActionAdapter, getActionCommand, getModifiers, getParameter, getParameter, getParameters, isDisplaysInputDialog, onButtonAttached, onPostExecute, onPreExecute, removeCommandInterceptor, setActionCommand, setDefaultButton, setDefaultButtonIn, setDisplaysInputDialog
 
Methods inherited from class org.springframework.richclient.command.AbstractCommand
addEnabledListener, afterPropertiesSet, attach, attach, attach, buttonIterator, createButton, createButton, createButton, createButton, createButton, createButton, createMenuItem, createMenuItem, createMenuItem, createMenuItem, createMenuItem, createMenuItem, defaultButtonIterator, detach, getAccelerator, getButtonFactory, getButtonIn, getCommandServices, getComponentFactory, getDefaultButtonConfigurer, getDefaultFaceDescriptorId, getFaceDescriptor, getFaceDescriptorRegistry, getIcon, getId, getMenuFactory, getMenuItemButtonConfigurer, getMnemonic, getMnemonicIndex, getSecurityControllerId, getText, getToolBarButtonConfigurer, getToolBarButtonFactory, isAnonymous, isAttached, isAuthorized, isEnabled, isFaceConfigured, isVisible, onButtonDetached, removeEnabledListener, requestFocusIn, setAuthorized, setBeanName, setCaption, setCommandServices, setDefaultFaceDescriptorId, setEnabled, setFaceDescriptor, setFaceDescriptor, setFaceDescriptorRegistry, setFaceDescriptors, setIcon, setIconInfo, setId, setLabel, setLabel, setSecurityControllerId, setVisible, toString, updatedEnabledState, updatedVisibleState
 
Methods inherited from class org.springframework.binding.value.support.AbstractPropertyChangePublisher
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, firePropertiesChanged, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasChanged, hasChanged, hasChanged, hasChanged, hasChanged, hasChanged, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LoginCommand

public LoginCommand()
Constructor.

Method Detail

setDisplaySuccess

public void setDisplaySuccess(boolean displaySuccessMessage)
Indicates whether an information message is displayed to the user upon successful authentication. Defaults to true.

Parameters:
displaySuccessMessage - displays an information message upon successful login if true, otherwise false

doExecuteCommand

protected void doExecuteCommand()
Execute the login command. Display the dialog and attempt authentication.

Specified by:
doExecuteCommand in class ActionCommand

createLoginForm

protected LoginForm createLoginForm()
Construct the Form to place in the login dialog.

Returns:
form to use

getDialog

protected ApplicationDialog getDialog()
Get the dialog in use, if available.

Returns:
dialog instance in use

postLogin

protected void postLogin()
Called to give subclasses control after a successful login.


isCloseOnCancel

public boolean isCloseOnCancel()
Get the "close on cancel" setting.

Returns:
close on cancel

setCloseOnCancel

public void setCloseOnCancel(boolean closeOnCancel)
Indicates if the application should be closed if the user cancels the login operation. Default is true.

Parameters:
closeOnCancel -

isClearPasswordOnFailure

public boolean isClearPasswordOnFailure()
Get the "clear password on failure" setting.

Returns:
clear password

setClearPasswordOnFailure

public void setClearPasswordOnFailure(boolean clearPasswordOnFailure)
Indicates if the password field should be cleared after a login failure. Default is true.

Parameters:
clearPasswordOnFailure -

getDefaultUserName

public String getDefaultUserName()
Get the default user name.

Returns:
default user name.

setDefaultUserName

public void setDefaultUserName(String defaultUserName)
Set the default user name.

Parameters:
defaultUserName - to use as default, null indicates no default


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.