Question

I am using SEAM 2.2.2 (JBoss AS6), trying to implement the following navigation logic:

I have 3 user types: user, client, admin

For each type I am using the following page rules...

<page login-required="true" view-id="/admin/*">
    <restrict>#{s:hasRole('admin')}</restrict>
    <navigation from-action="#{identity.logout}">
        <end-conversation/>
        <redirect view-id="/admin-login"/>
    </navigation>
</page>

to forward users to the login page when they log out

and

<exception class="org.jboss.seam.security.NotLoggedInException" log="false">
    <redirect view-id="/index.xhtml"/>
</exception>
<exception class="org.jboss.seam.security.AuthorizationException" log="false">
    <end-conversation/>
    <redirect view-id="/index.xhtml"/>
</exception>

to bounce users who are not logged in. However rather than redirecting them to the index page, I want to redirect them to their respective login pages, to for example, if I try to access /admin/somePage.xhtml without logging in, I am redirected to /admin-login page

I guess I need to somehow get the requested page as a parameter in pages.xml, but having looked through the docs I cant see anything

Something like below (as an example)...

<exception class="org.jboss.seam.security.NotLoggedInException" log="false">
    <rule if="#{requestedPage}='/admin/*'">
        <redirect view-id="/admin-login"/>
    </rule>
</exception>

UPDATE:

I have also tried the following,

    <page login-required="true" view-id="/admin/*">
        <restrict>#{s:hasRole('admin')}</restrict>
        <rule if="#{!s:hasRole('admin')}">
            <redirect view-id="/admin-login"/>
        </rule>
        <navigation from-action="#{identity.logout}">
            <end-conversation/>
            <redirect view-id="/admin-login"/>
        </navigation>
    </page>

But the org.jboss.seam.security.NotLoggedInException overrides it and forwards to index.xhtml.

Following some more googling I found the same problem here: https://community.jboss.org/thread/191214 which has a (not ideal) solution, if anyone can describe a better one please let me know, otherwise I will use this one.

Was it helpful?

Solution

Ok, I found the same question here https://community.jboss.org/thread/191214 and have used the solution provided at the end of the thread which seems to work quite well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top