Forgot to mention that the superclass must implement PageValidateListener. This tells Tapestry to invoke our pageValidate (PageEvent) method. BTW, my solution has not been tested in anger.

On 23/05/2007, at 2:01 AM, Geoff Callender wrote:

From trial and error I came up with this a little while ago, but there may be a better way,,,

At login, save the LoginContext into an application scoped object - in this example it's called MyVisit. Then in your superclass of all pages that require authorisation, do this...

    /**
     * pageValidate - ensure the user is logged in.
     */
    public void pageValidate(PageEvent event) {
        Visit visit = getMyVisit();

        // If you're not logged in, then we go to the login page.

        if (visit == null || !visit.isLoggedIn()) {
            redirectToLoginPage();
        }

// Is this too expensive to have here, or should it be called on demand?
        reEstablishLogin();
    }

    protected void reEstablishLogin() {
        // re-establish my JAAS login
        try {
            getMyVisit().getLoginContext().login();
        } catch (LoginException e) {
            redirectToLoginPage();
        }
    }

    private void redirectToLoginPage() {
LoginPage login = (LoginPage) getRequestCycle().getPage ("pages/login/LoginPage");
        login.setCallback(new PageCallback(this));
        throw new PageRedirectException(login);
    }

Any JAAS aficionados out there?

HTH,

Geoff

On 22/05/2007, at 7:00 PM, Jan Vissers wrote:

Hi,

How would one incorporate JAAS into Tapestry 4+.
We already have a login module, but need help to tie it in to the framework.

Thanks,
-J.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to