We use an approach where the ACL checks are done in your base SecureScreen
class, which is the superclass for all of your own screen classes.

Using something like:

protected void setContextACLs(AccessControlList acl, Context ctx)
        {
                if (acl == null)
                        return;

                if (acl.hasPermission("admin_users"))
                        ctx.put("Admin", "1");
                if (acl.hasPermission("client_access"))
                        ctx.put("Client", "1");
                if (acl.hasPermission("staff_access"))
                        ctx.put("Staff", "1");
        }


And then in your menu you can simply use this pattern:

#if ($Client || $Staff)
&nbsp;|&nbsp;<a href="$link.setPage("ClientStaffSharedAccess.vm")">Client
and Staff accessible page</a>
#end

#if ($Staff)
&nbsp;|&nbsp;<a href="$link.setPage("StaffOnly.vm")">Staff Only Page</a>

#if ($Admin)
&nbsp;|&nbsp;<a href="$link.setPage("user,FluxUserList.vm")">Users</a>
&nbsp;|&nbsp;<a href="$link.setPage("role,FluxRoleList.vm")">Roles</a>
#end

&nbsp;|&nbsp;<a href="$link.setAction("LogoutUser")">Logout</a>

Gavin Barron B.Sc
J2EE Developer
Genix Systems Ltd
http://www.genixsystems.com/

"Never underestimate the bandwidth of a station wagon full of hard drives"
 

-----Original Message-----
From: Jeffery Painter [mailto:[EMAIL PROTECTED] 
Sent: Thursday, 23 October 2003 12:56 a.m.
To: Turbine Users List
Subject: Re: Dynamic Menu


I don't know how safe it is, but I have used velocity in my Menu.vm to do 
the check, and so far it hasn't broken yet :P


        #if ( $data.getACL().hasRole("sales") )
                d.add(1,0,'Orders' ,'$link.setPage("orders,Status.vm")');
                d.add(2,0,'Customers' );
                d.add(3,0,'Inventory');
                d.add(4,0,'Suppliers' );
        #end

        #if ( $data.getACL().hasRole("administrator") )
        // USERS
            d.add(43, 9, 'Users', '$link.setPage("user,FluxUserList.vm")');
            d.add(44, 9, 'Groups',
'$link.setPage("group,FluxGroupList.vm")');
            d.add(45, 9, 'Roles', '$link.setPage("role,FluxRoleList.vm")');
            d.add(46, 9, 'Permissions',
'$link.setPage("permission,FluxPermissionList.vm")');
        #end


I'm using a javascript tree object so that is what the d.add() methods are 
doing. Depending on the user's roles, they get more and more options added 
to their navigation tree.

If anyone has a better solution I would be interested to hear as well.


        Jeffery Painter


On Wed, 22 Oct 2003 David_Solbach/MR/de/[EMAIL PROTECTED] wrote:

> Hi,
> 
> I try to implement a dynamic menu, but creating Menu.java for the Menu.vm 
> in /navigations doesn't help, unfortunately the Java-file isn't called.
> I'd like to dynamicly generate a menu depending on the permissions of the 
> user, listed in the ACL.
> 
> Any suggestions?
> 
> David
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


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


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

Reply via email to