Class AuthenticatedAction

All Implemented Interfaces:
ILocalized, ActionListener, PropertyChangeListener, Serializable, Cloneable, EventListener, Action
Direct Known Subclasses:
AbstractShowPanelAction, LocalizedSelectableAction

public abstract class AuthenticatedAction extends AutoLocalizedAction
The AuthenticatedAction allows to restrict this action to a defined user. If no LoginService is set, this action is executable by everyone; in the other case, a login pane will be shown, using the getLoginService() to authenticate the user. Provided by the broldev.core.swing project.
Since:
1.0 (Oct 17, 2010), broldev.core.swing 0.0.1-SNAPSHOT dependency
Version:
1.0 (Oct 17, 2010)
Author:
Steph GAUDRY
See Also:
Serialized Form
  • Field Details

    • loginTitle

      protected String loginTitle
      Title of the login pane
    • loginMessage

      protected String loginMessage
      Message to display on the login pane
  • Constructor Details

    • AuthenticatedAction

      public AuthenticatedAction()
      Builds an AuthenticatedAction object with a default description string and default icon.
    • AuthenticatedAction

      public AuthenticatedAction(String name)
      Builds an AuthenticatedAction object with the specified description string and a default icon.
      Parameters:
      name - description of the action
    • AuthenticatedAction

      public AuthenticatedAction(String name, Icon icon)
      Builds an AuthenticatedAction object with the specified description string and a the specified icon.
      Parameters:
      name - description of the action
      icon - image of the action
  • Method Details

    • getServers

      protected List<String> getServers()
    • setLoginPane

      void setLoginPane(org.jdesktop.swingx.JXLoginPane loginPane)
      method to set a specific loginPane only for the classes on this package
    • getLoginService

      protected abstract org.jdesktop.swingx.auth.LoginService getLoginService()
      Allows to use an authentication called on each actionPerformed(ActionEvent) call. May return null to disable authentication.
      Returns:
      the loginService or null
      See Also:
      authenticatedActionPerformed(ActionEvent)
    • afterUpdateLanguage

      protected void afterUpdateLanguage()
      Description copied from class: AutoLocalizedAction
      This package method allows to set some operation after calling ILocalized.setLanguage(). This may be overrided ie. if the AbstractAction.getValue(String) is used with Action.NAME to get the name of the action after having set the language. \nThis is only called after an update due to a LanguageHelper notification, not after an explicit ILocalized.setLanguage() call. \nDefault implementation does nothing.
      Overrides:
      afterUpdateLanguage in class AutoLocalizedAction
    • actionPerformed

      public final void actionPerformed(ActionEvent e)
      • If a LoginService is set
        • if authentication succeeds, performs the authenticatedActionPerformed(ActionEvent)
        • otherwise, performs the authenticationFailed(ActionEvent, String)
      • else performs the unSecuredActionPerformed(ActionEvent)(default implementation calls the authenticatedActionPerformed(ActionEvent), because don't defining a login service means allowing to perform the action without authentication)
      See Also:
      ActionListener.actionPerformed(java.awt.event.ActionEvent)
    • beforeActionPerformed

      protected boolean beforeActionPerformed()
      Does something before calling the actionPerformed(ActionEvent) method, or to perform some controls to have a conditional actionPerformed. The default implementation does nothing and simply returns true.
      Returns:
      true to authenticate before performing the action, false if no action is allowed(calls the authenticationCanceled(ActionEvent)).
    • authenticatedActionPerformed

      protected abstract void authenticatedActionPerformed(ActionEvent e)
      Invoked by actionPerformed(ActionEvent) when an action occurs and authentication has been set and authentication succeed. Do nothing if and authentication has been set and authentication failed.
      Parameters:
      e - to get event and source informations
      See Also:
      ActionListener.actionPerformed(java.awt.event.ActionEvent), ActionEvent
    • authenticationFailed

      protected void authenticationFailed(ActionEvent e)
      Invoked on authentication failed. Default implementation does nothing, but logs with info level.
      Parameters:
      e - to get event and source informations
    • authenticationCanceled

      protected void authenticationCanceled(ActionEvent e)
      Invoked on authentication canceled. Default implementation does nothing, but logs with debug level.
      Parameters:
      e - to get event and source informations
    • unSecuredActionPerformed

      protected void unSecuredActionPerformed(ActionEvent e)
      Invoked if there is no loginService set. Default implementation is calling the authenticatedActionPerformed(ActionEvent) method.
      Parameters:
      e - to get event and source informations
      See Also:
      actionPerformed(ActionEvent), authenticatedActionPerformed(ActionEvent)