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
FieldsModifier and TypeFieldDescriptionprotected StringMessage to display on the login paneprotected StringTitle of the login paneFields inherited from class javax.swing.AbstractAction
changeSupport, enabledFields 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
ConstructorsConstructorDescriptionBuilds anAuthenticatedActionobject with a default description string and default icon.AuthenticatedAction(String name)Builds anAuthenticatedActionobject with the specified description string and a default icon.AuthenticatedAction(String name, Icon icon)Builds anAuthenticatedActionobject with the specified description string and a the specified icon. -
Method Summary
Modifier and TypeMethodDescriptionvoidIf 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 voidThis package method allows to set some operation after callingILocalized.setLanguage().protected abstract voidInvoked byactionPerformed(ActionEvent)when an action occurs and authentication has been set and authentication succeed.protected voidInvoked on authentication canceled.protected voidInvoked on authentication failed.protected booleanDoes something before calling theactionPerformed(ActionEvent)method, or to perform some controls to have a conditionalactionPerformed.protected abstract org.jdesktop.swingx.auth.LoginServiceAllows to use an authentication called on eachactionPerformed(ActionEvent)call.(package private) voidsetLoginPane(org.jdesktop.swingx.JXLoginPane loginPane)method to set a specific loginPane only for the classes on this packageprotected voidInvoked if there is no loginService set.Methods inherited from class be.gaudry.swing.action.AutoLocalizedAction
beforeUpdateLanguage, doAfterCreate, init, propertyChangeMethods inherited from class be.gaudry.swing.action.LocalizableAction
doOnCreateMethods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabledMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 anAuthenticatedActionobject with a default description string and default icon. -
AuthenticatedAction
Builds anAuthenticatedActionobject with the specified description string and a default icon.- Parameters:
name- description of the action
-
AuthenticatedAction
Builds anAuthenticatedActionobject 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 returnnullto disable authentication.- Returns:
- the loginService or null
- See Also:
authenticatedActionPerformed(ActionEvent)
-
afterUpdateLanguage
protected void afterUpdateLanguage()Description copied from class:AutoLocalizedActionThis package method allows to set some operation after callingILocalized.setLanguage(). This may be overrided ie. if theAbstractAction.getValue(String)is used withAction.NAMEto get the name of the action after having set the language. \nThis is only called after an update due to aLanguageHelpernotification, not after an explicitILocalized.setLanguage()call. \nDefault implementation does nothing.- Overrides:
afterUpdateLanguagein 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)
-