public abstract class WaspAuthorizationStrategy extends Object implements org.apache.wicket.authorization.IAuthorizationStrategy, Serializable
| Modifier and Type | Field and Description |
|---|---|
protected static AuthorizationErrorKey |
MESSAGE_KEY
Key used to store the
IAuthorizationMessageSource in the RequestCycle
metadata. |
| Constructor and Description |
|---|
WaspAuthorizationStrategy() |
| Modifier and Type | Method and Description |
|---|---|
protected IAuthorizationMessageSource |
createMessageSource()
Creates a new
IAuthorizationMessageSource. |
abstract void |
destroy()
Called at the end of the sessions lifecycle to perform some clean up.
|
static WaspAuthorizationStrategy |
get()
Returns the WaspAuthorizationStrategy.
|
protected WaspActionFactory |
getActionFactory()
Shortcut to the actionfactory.
|
protected IAuthorizationMessageSource |
getMessageSource()
Retrieves the messagesource from the
RequestCycle's metadata. |
protected IAuthorizationMessageSource |
getMessageSource(boolean create)
Retrieves the messagesource from the
RequestCycle's metadata. |
protected ISecurityCheck |
getSecurityCheck(org.apache.wicket.Component component)
We cannot assume everybody uses the here specified public methods to store the securitycheck,
so we check if the component is a ISecureComponent and if so use the getSecurityCheck on the
secure component else we fall back to the SecureComponentHelper.
|
boolean |
isActionAuthorized(org.apache.wicket.Component component,
org.apache.wicket.authorization.Action action) |
abstract boolean |
isClassAuthenticated(Class<?> clazz)
Performs the authentication check.
|
abstract boolean |
isClassAuthorized(Class<?> clazz,
WaspAction action)
Performs the actual authorization check on the component class.
|
abstract boolean |
isComponentAuthenticated(org.apache.wicket.Component component)
Performs the authentication check.
|
abstract boolean |
isComponentAuthorized(org.apache.wicket.Component component,
WaspAction action)
Performs the actual authorization check on the component.
|
abstract boolean |
isModelAuthenticated(org.apache.wicket.model.IModel<?> model,
org.apache.wicket.Component component)
Performs the authentication check.
|
abstract boolean |
isModelAuthorized(ISecureModel<?> model,
org.apache.wicket.Component component,
WaspAction action)
Performs the actual authorization check on the model of the component.
|
abstract boolean |
isUserAuthenticated()
Checks if there is a user logged in at all.
|
abstract void |
login(Object context)
Attempts to log the user in.
|
protected void |
logMessage(IAuthorizationMessageSource message)
Logs a message indication an action was denied.
|
protected void |
logMessage(String key,
Map<String,Object> variables,
IAuthorizationMessageSource message)
Logs a message indication an action was denied.
|
protected void |
logMessage(String key,
Map<String,Object> variables,
IAuthorizationMessageSource message,
boolean remove)
Logs a message indication an action was denied.
|
protected boolean |
logMessages()
Indicates if messages about denied actions should be logged.
|
abstract boolean |
logoff(Object context)
Log the user off.
|
protected void |
removeMessageSource()
Removes the message from the
RequestCycle's metadata. |
static void |
setStrategyResolver(StrategyResolver threadResolver)
Sets the StrategyResolver for the current thread
|
protected static final AuthorizationErrorKey MESSAGE_KEY
IAuthorizationMessageSource in the RequestCycle
metadata.public abstract boolean isComponentAuthorized(org.apache.wicket.Component component,
WaspAction action)
component - action - public abstract boolean isModelAuthorized(ISecureModel<?> model, org.apache.wicket.Component component, WaspAction action)
model - the modelcomponent - component 'owning' the model if availableaction - the action to checkpublic abstract boolean isClassAuthorized(Class<?> clazz, WaspAction action)
clazz - typically a componentaction - the action to checkpublic abstract boolean isComponentAuthenticated(org.apache.wicket.Component component)
component - the wicket componentpublic abstract boolean isModelAuthenticated(org.apache.wicket.model.IModel<?> model,
org.apache.wicket.Component component)
model - the (secure) modelcomponent - the component owning the modelpublic abstract boolean isClassAuthenticated(Class<?> clazz)
clazz - the class of the wicket componentpublic abstract boolean isUserAuthenticated()
login(Object) and false after a successful logoff(Object). Note that in a
multi-login scenario this method returns true until all successful logins are countered with
a successful logoff.public abstract void login(Object context) throws LoginException
context - a not further specified object that provides all the information to log the user
onLoginException - if the login is unsuccessfulpublic abstract boolean logoff(Object context)
context - a not further specified object, might be nullpublic abstract void destroy()
public boolean isActionAuthorized(org.apache.wicket.Component component,
org.apache.wicket.authorization.Action action)
isActionAuthorized in interface org.apache.wicket.authorization.IAuthorizationStrategyIAuthorizationStrategy.isActionAuthorized(org.apache.wicket.Component,
org.apache.wicket.authorization.Action)protected final void logMessage(IAuthorizationMessageSource message)
message - messagesourcelogMessage(String, Map, IAuthorizationMessageSource, boolean)protected final void logMessage(String key, Map<String,Object> variables, IAuthorizationMessageSource message, boolean remove)
logMessage(String, Map, IAuthorizationMessageSource)key - the resource key to lookup the messagevariables - optional map containing additional variables that can be used during the message
lookupmessage - messagesourceremove - flag indicating if the message should be removed or notremoveMessageSource(),
logMessage(String, Map, IAuthorizationMessageSource)protected void logMessage(String key, Map<String,Object> variables, IAuthorizationMessageSource message)
log.debug(...) Overwrite this method if you want for example wicket to print
feedback messages with something like Session.get().error(...)key - the resource key for the messagevariables - optional map containing additional variables that can be used during message
constructionmessage - the messagesourceprotected final void removeMessageSource()
RequestCycle's metadata.protected final IAuthorizationMessageSource getMessageSource()
RequestCycle's metadata.protected final IAuthorizationMessageSource getMessageSource(boolean create)
RequestCycle's metadata. optionally creating a
new one if there is not already one.create - protected IAuthorizationMessageSource createMessageSource()
IAuthorizationMessageSource. Subclasses can override this to return
there own implementation.protected boolean logMessages()
log4j.category.org.wicketstuff.security.strategies.WaspAuthorizationStrategy=DEBUG
protected final ISecurityCheck getSecurityCheck(org.apache.wicket.Component component)
component - SecureComponentHelper.getSecurityCheck(Component)protected final WaspActionFactory getActionFactory()
public static WaspAuthorizationStrategy get()
WaspSession.getAuthorizationStrategy(), but a different implementation can be
registered via a StrategyResolver.public static void setStrategyResolver(StrategyResolver threadResolver)
threadResolver - Copyright © 2015. All rights reserved.