Package be.gaudry.swing.action
Class AuthenticatedAction
java.lang.Object
javax.swing.AbstractAction
be.gaudry.swing.action.LocalizableAction
be.gaudry.swing.action.AutoLocalizedAction
be.gaudry.swing.action.AuthenticatedAction
- All Implemented Interfaces:
ILocalized
,ActionListener
,PropertyChangeListener
,Serializable
,Cloneable
,EventListener
,Action
- Direct Known Subclasses:
AbstractShowPanelAction
,LocalizedSelectableAction
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 Summary
Modifier and TypeFieldDescriptionprotected String
Message to display on the login paneprotected String
Title of the login paneFields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
-
Constructor Summary
ConstructorDescriptionBuilds anAuthenticatedAction
object with a default description string and default icon.AuthenticatedAction(String name)
Builds anAuthenticatedAction
object with the specified description string and a default icon.AuthenticatedAction(String name, Icon icon)
Builds anAuthenticatedAction
object with the specified description string and a the specified icon. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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)protected void
This package method allows to set some operation after callingILocalized.setLanguage()
.protected abstract void
Invoked byactionPerformed(ActionEvent)
when an action occurs and authentication has been set and authentication succeed.protected void
Invoked on authentication canceled.protected void
Invoked on authentication failed.protected boolean
Does something before calling theactionPerformed(ActionEvent)
method, or to perform some controls to have a conditionalactionPerformed
.protected abstract org.jdesktop.swingx.auth.LoginService
Allows to use an authentication called on eachactionPerformed(ActionEvent)
call.(package private) void
setLoginPane(org.jdesktop.swingx.JXLoginPane loginPane)
method to set a specific loginPane only for the classes on this packageprotected void
Invoked if there is no loginService set.Methods inherited from class be.gaudry.swing.action.AutoLocalizedAction
beforeUpdateLanguage, doAfterCreate, init, propertyChange
Methods inherited from class be.gaudry.swing.action.LocalizableAction
doOnCreate
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface be.gaudry.model.locale.ILocalized
setLanguage
-
Field Details
-
loginTitle
Title of the login pane -
loginMessage
Message to display on the login pane
-
-
Constructor Details
-
AuthenticatedAction
public AuthenticatedAction()Builds anAuthenticatedAction
object with a default description string and default icon. -
AuthenticatedAction
Builds anAuthenticatedAction
object with the specified description string and a default icon.- Parameters:
name
- description of the action
-
AuthenticatedAction
Builds anAuthenticatedAction
object with the specified description string and a the specified icon.- Parameters:
name
- description of the actionicon
- image of the action
-
-
Method Details
-
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 eachactionPerformed(ActionEvent)
call. May returnnull
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 callingILocalized.setLanguage()
. This may be overrided ie. if theAbstractAction.getValue(String)
is used withAction.NAME
to get the name of the action after having set the language. \nThis is only called after an update due to aLanguageHelper
notification, not after an explicitILocalized.setLanguage()
call. \nDefault implementation does nothing.- Overrides:
afterUpdateLanguage
in classAutoLocalizedAction
-
actionPerformed
- 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)
- If a LoginService is set
-
beforeActionPerformed
protected boolean beforeActionPerformed()Does something before calling theactionPerformed(ActionEvent)
method, or to perform some controls to have a conditionalactionPerformed
. The default implementation does nothing and simply returnstrue
.- Returns:
- true to authenticate before performing the action,
false if no action is allowed(calls the
authenticationCanceled(ActionEvent)
).
-
authenticatedActionPerformed
Invoked byactionPerformed(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
Invoked on authentication failed. Default implementation does nothing, but logs with info level.- Parameters:
e
- to get event and source informations
-
authenticationCanceled
Invoked on authentication canceled. Default implementation does nothing, but logs with debug level.- Parameters:
e
- to get event and source informations
-
unSecuredActionPerformed
Invoked if there is no loginService set. Default implementation is calling theauthenticatedActionPerformed(ActionEvent)
method.- Parameters:
e
- to get event and source informations- See Also:
actionPerformed(ActionEvent)
,authenticatedActionPerformed(ActionEvent)
-