On Fri, 22 Oct 2010 10:25:03 -0200, shinlang <sascha.hinl...@gameforge.de> wrote:

Hi,

Hi!

I have of course read the article at
http://tapestryjava.blogspot.com/2009/12/securing-tapestry-pages-with.html,
and i can't see any difference:

Component page = componentSource.getPage(pageName);
if (! page.getClass().isAnnotationPresent(RequiresLogin.class)) {
        return false;
}

This doesn't work if you add the annotation after you started the application. Another way of doing that, which works well with live class reloading (you add, remove or change an annotation and it automatically works) is using a worker. This is the one which handles the @Secure annotation in Tapestry:

public class SecureWorker implements ComponentClassTransformWorker
{
public void transform(ClassTransformation transformation, MutableComponentModel model)
    {
        Secure secure = transformation.getAnnotation(Secure.class);

        if (secure != null)
            model.setMeta(MetaDataConstants.SECURE_PAGE, "true");
    }
}

You can get the ComponentModel of a given page or component instance using getComponentResources().getComponentModel().

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to