Author: fdesbois Date: 2010-05-06 19:22:56 +0200 (Thu, 06 May 2010) New Revision: 2989 Url: http://chorem.org/repositories/revision/pollen/2989 Log: Evo #191 : add javadoc on Authentication service. Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.java trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.java 2010-05-06 17:03:11 UTC (rev 2988) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/data/PollenRequiresAuthentication.java 2010-05-06 17:22:56 UTC (rev 2989) @@ -8,20 +8,20 @@ import java.lang.annotation.Target; import org.chorem.pollen.ui.services.PollenAuthenticationFilter; import org.chorem.pollen.ui.base.AbstractPollenPage; -import org.nuiton.web.tapestry5.services.ServiceAuthentication; +import org.chorem.pollen.ui.services.PollenAuthentication; /** * This annotation is used on pages and components that need authentication - * to be rendered. The ServiceAuthentication is used to check authorizations - * on each page from {@link AbstractPollenPage}. This service is called from - * a Filter {@link PollenAuthenticationFilter} registered in Tapestry registry - * that intercept event on component and page render. + * to be rendered. The {@link PollenAuthentication} service is used to check + * authorizations on each page from {@link AbstractPollenPage}. This service is + * called from a Filter {@link PollenAuthenticationFilter} registered in + * Tapestry registry that intercept event on component and page render. * * Created: 3 mai 2010 * * @author fdesbois <fdesbois@codelutin.com> * @version $Id$ - * @see ServiceAuthentication + * @see PollenAuthentication * @see PollenAuthenticationFilter */ @Target( { ElementType.TYPE }) Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java 2010-05-06 17:03:11 UTC (rev 2988) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/services/PollenAuthentication.java 2010-05-06 17:22:56 UTC (rev 2989) @@ -1,19 +1,28 @@ package org.chorem.pollen.ui.services; +import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.services.ApplicationStateManager; import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.entity.UserAccountImpl; import org.chorem.pollen.ui.data.PollenRequiresAuthentication; +import org.chorem.pollen.ui.pages.admin.AdminUsers; import org.nuiton.web.tapestry5.services.ServiceAuthenticationImpl; /** - * ServiceAuthenticationImpl + * Service to manage user connected and also check his authorizations to + * display Pollen pages depends on {@link PollenRequiresAuthentication} + * annotation over each page. This service used {@link ApplicationStateManager} + * service of Tapestry to store and retrieve connected user. This user + * can also be retrieve in pages using {@link SessionState} annotation on + * property of type {@link UserAccount}. * * Created: 4 mai 2010 * - * @author fdesbois - * $Id$ + * @author fdesbois <fdesbois@codelutin.com> + * @version $Id$ + * @see ServiceAuthenticationImpl + * @see PollenRequiresAuthentication */ public class PollenAuthentication extends ServiceAuthenticationImpl<UserAccount, PollenRequiresAuthentication> { @@ -23,6 +32,15 @@ PollenRequiresAuthentication.class); } + /** + * Check authorizations of {@code user} for the {@code annotation} from + * current page to render. The {@code annotation} contains constraint + * on admin user for some specific pages as {@link AdminUsers}. + * + * @param user connected user to check for authorizations. + * @param annotation PollenRequiresAuthentication of the page to test + * @return true if user is allowed to render the page, false otherwise + */ @Override protected boolean checkAuthorizations(UserAccount user, PollenRequiresAuthentication annotation) { @@ -30,6 +48,13 @@ return user.getAdmin() || !annotation.adminOnly(); } + /** + * Instanciate a new UserAccount for ApplicationStateManager contribution + * in AppModule. + * + * @return a new instance of UserAccount. + * @see AppModule#contributeApplicationStateManager(MappedConfiguration, ServiceAuthentication) + */ @Override public UserAccount getNewUserInstance() { return new UserAccountImpl();