U - user typeA - annotation type used to identify which page need authenticationpublic class ServiceAuthenticationImpl<U,A extends Annotation> extends Object implements ServiceAuthentication<U>
ServiceAuthentication.
This service use ApplicationStateManager to manage connected user.
You can inherit this class to provide a momre specific authentication
managmentan depends on user type and annotation used to identify
pages that need authentication. This behavior is done in
isAllowed(Class) that detect the annotation on the page (ex :
RequiresAuthentication annotation) and call the method
checkAuthorizations(Object, Annotation) that is implemented by
default to do nothing (return true).
public ServiceAuthenticationNo need to contribute to ApplicationStateManager to provide instantiation of user. Even this service used the default constructor to instanciate a new user.buildServiceAuthentication(ApplicationStateManager stateManager) { return new ServiceAuthenticationImpl (stateManager); }
| Modifier and Type | Field and Description |
|---|---|
protected Class<A> |
annotationClass
Annotation type to detect pages that need authentication (ex :
RequiresAuthentication).
|
protected Class<U> |
userClass
User type
|
| Constructor and Description |
|---|
ServiceAuthenticationImpl(org.apache.tapestry5.services.ApplicationStateManager stateManager,
Class<U> userClass,
Class<A> annotationClass)
Constructor to call in subclasses.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
checkAuthorizations(U user,
A annotation)
Check the connected user authorizations.
|
U |
getNewUserInstance()
Default instanciation of the user.
|
U |
getUserConnected()
Get the current user connected.
|
boolean |
isAllowed(Class<?> page)
Detect the annotation in the given
page. |
boolean |
isUserConnected()
Detect if user is connected.
|
void |
setUserConnected(U user)
Set the connected user to
user. |
protected Class<A extends Annotation> annotationClass
public ServiceAuthenticationImpl(org.apache.tapestry5.services.ApplicationStateManager stateManager,
Class<U> userClass,
Class<A> annotationClass)
stateManager - from TapestryuserClass - to identify which type of user is managedannotationClass - to identify which type of annotation is managed
for authentication treatment.public boolean isUserConnected()
ServiceAuthenticationisUserConnected in interface ServiceAuthentication<U>public U getUserConnected()
ServiceAuthenticationgetUserConnected in interface ServiceAuthentication<U>public void setUserConnected(U user)
ServiceAuthenticationuser.setUserConnected in interface ServiceAuthentication<U>user - that will be connectedpublic boolean isAllowed(Class<?> page)
page. If annotation is
detected, the user authorizations need to be check using
checkAuthorizations(Object, Annotation) method.isAllowed in interface ServiceAuthentication<U>page - to checkprotected boolean checkAuthorizations(U user, A annotation)
isAllowed(Class) method after detect the annotation on the
current page. Override this method to provide more specific
authentication managment.user - current user connected.annotation - from page to check authorizations.public U getNewUserInstance()
getNewUserInstance in interface ServiceAuthentication<U>Copyright © 2010-2012 CodeLutin. All Rights Reserved.