org.nuiton.web.tapestry5.services
Interface ServiceAuthentication<U>

Type Parameters:
U - user type
All Known Implementing Classes:
ServiceAuthenticationImpl

public interface ServiceAuthentication<U>

This service is used to provide authentication managment for a final application. The user type used in the application is needed. This service need to be implemented and build in the AppModule of your application. An abstract implementation is available ServiceAuthenticationAbstract This service is used in AbstractAuthenticationFilter to verify user rights for displaying pages using isAllowed(Class) method. See documentation site for more explanation of using this service and authentication managment.

AppModule contribution : Exemple with MyUser type for user and ServiceAuthenticationImpl for implementation :
  public ServiceAuthentication buildServiceAuthentication(
          ApplicationStateManager stateManager) {
      ServiceAuthentication instance =
              new ServiceAuthenticationImpl(stateManager);
      return instance;
  }
 
Contribute to ApplicationStateManager to instantiate MyUser automatically :
 public void contributeApplicationStateManager(
           MappedConfiguration,
           ApplicationStateContribution> configuration,
           final ServiceAuthentication serviceAuthentication) {
 

ApplicationStateCreator creator = new ApplicationStateCreator() {

Version:
$Id: ServiceAuthentication.java 49 2011-01-26 16:08:25Z tchemit $
Author:
fdesbois

Method Summary
 U getNewUserInstance()
          Create a new instance of user.
 U getUserConnected()
          Get the current user connected.
 boolean isAllowed(Class<?> page)
          Check if the current user is allowed to display this page.
 boolean isUserConnected()
          Detect if user is connected.
 void setUserConnected(U user)
          Set the connected user to user.
 

Method Detail

isUserConnected

boolean isUserConnected()
Detect if user is connected.

Returns:
true if the user is connected, false otherwise.

getUserConnected

U getUserConnected()
Get the current user connected.

Returns:
the user connected

setUserConnected

void setUserConnected(U user)
Set the connected user to user.

Parameters:
user - that will be connected

isAllowed

boolean isAllowed(Class<?> page)
Check if the current user is allowed to display this page.

Parameters:
page - to check
Returns:
true if the connected user is allowed, false otherwise

getNewUserInstance

U getNewUserInstance()
Create a new instance of user.

Returns:
a new user.


Copyright © 2010-2011 CodeLutin. All Rights Reserved.