When integrating Acegi security, you need to redirect login and logouts to Acegi's special URIs. You can do this from Tapestry by returning a Link object constructed using the encoder from the response, the context path from the request and the appropriate URI and parameters.

Example

import org.apache.tapestry.internal.services.LinkImpl;
import org.apache.tapestry.services.Request;
import org.apache.tapestry.services.Response;

public class Login {
    @Inject
    private Request request;
    
    @Inject
    private Response response;

    Link onSuccessFromLoginForm() {
        Link link= new LinkImpl(response, request.getContextPath(), "j_acegi_security_check");
        link.addParameter("j_username", username);
        link.addParameter("j_password", password);
        return link;
    }

Small word of caution: For convenience we're using the internal class LinkImpl. Although it's unlikely to change much, you may prefer to write your own implementation of the Link interface.

  • No labels