You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Aleksandar Matijaca <am...@gmail.com> on 2005/07/14 15:17:28 UTC

struts and multi-level access - please give me your ideas how to restructure..

Hi there,

I have an application that I am working on that requires two different role 
levels (administrator and user).
The administrator, will have some extra links visible to them. I want to use 
only one struts-config file.
I am currently running into a scalability issue -- here is what I mean:



<action path="/someAction" ....... >

<forward name="a_success" path="someAdministratorPath.def"> <!-- I am using 
tiles -->
<forward name="u_success" path="someUserPath.def"> <!-- I am using tiles -->

</aciton>

The someAdministratorPath.def has a jsp with different kind of a menu 
structure - for administrators only,
and someUserPath.def has a jsp with a subset of different menu structures -- 
the only real difference between
the two .def files is a single jsp.

Somehow the above seems awkward and unscalable to me, and I am afraid I will 
run into a problem later. 
I know that I can probably put in some <c:if statements in one of the JSPs, 
and there discriminate between
a User and Administrator, but somehow, that seems like a band-aid solution.

If you have any idea on how to restructure this thing, please let me know.

Thanks, Alex.

Re: struts and multi-level access - please give me your ideas how to restructure..

Posted by Aleksandar Matijaca <am...@gmail.com>.
That is a very interesting tag, I have never used it - thanks Laurie!!
 Cheers, Alex.


 On 7/14/05, Laurie Harper <la...@holoweb.net> wrote: 
> 
> Not sure what a .def file is, but I think you're on the right track with
> combining them and using conditional logic within the JSP to control 
> what's
> displayed based on user role. Look at <logic:present role=''/> for a 
> simple
> way to wrap role-dependent markup in your JSPs:
> 
> http://struts.apache.org/userGuide/struts-logic.html#present
> 
> L.
> 
> Aleksandar Matijaca wrote:
> > Hi there,
> >
> > I have an application that I am working on that requires two different 
> role
> > levels (administrator and user).
> > The administrator, will have some extra links visible to them. I want to 
> use
> > only one struts-config file.
> > I am currently running into a scalability issue -- here is what I mean:
> >
> >
> >
> > <action path="/someAction" ....... >
> >
> > <forward name="a_success" path="someAdministratorPath.def"> <!-- I am 
> using
> > tiles -->
> > <forward name="u_success" path="someUserPath.def"> <!-- I am using tiles 
> -->
> >
> > </aciton>
> >
> > The someAdministratorPath.def has a jsp with different kind of a menu
> > structure - for administrators only,
> > and someUserPath.def has a jsp with a subset of different menu 
> structures --
> > the only real difference between
> > the two .def files is a single jsp.
> >
> > Somehow the above seems awkward and unscalable to me, and I am afraid I 
> will
> > run into a problem later.
> > I know that I can probably put in some <c:if statements in one of the 
> JSPs,
> > and there discriminate between
> > a User and Administrator, but somehow, that seems like a band-aid 
> solution.
> >
> > If you have any idea on how to restructure this thing, please let me 
> know.
> >
> > Thanks, Alex.
> >
> 
> 
> --
> Laurie, Open Source advocate, Java geek and novice blogger:
> http://www.holoweb.net/~laurie/
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

Re: struts and multi-level access - please give me your ideas how to restructure..

Posted by Laurie Harper <la...@holoweb.net>.
Not sure what a .def file is, but I think you're on the right track with 
combining them and using conditional logic within the JSP to control what's 
displayed based on user role. Look at <logic:present role=''/> for a simple 
way to wrap role-dependent markup in your JSPs:

   http://struts.apache.org/userGuide/struts-logic.html#present

L.

Aleksandar Matijaca wrote:
> Hi there,
> 
> I have an application that I am working on that requires two different role 
> levels (administrator and user).
> The administrator, will have some extra links visible to them. I want to use 
> only one struts-config file.
> I am currently running into a scalability issue -- here is what I mean:
> 
> 
> 
> <action path="/someAction" ....... >
> 
> <forward name="a_success" path="someAdministratorPath.def"> <!-- I am using 
> tiles -->
> <forward name="u_success" path="someUserPath.def"> <!-- I am using tiles -->
> 
> </aciton>
> 
> The someAdministratorPath.def has a jsp with different kind of a menu 
> structure - for administrators only,
> and someUserPath.def has a jsp with a subset of different menu structures -- 
> the only real difference between
> the two .def files is a single jsp.
> 
> Somehow the above seems awkward and unscalable to me, and I am afraid I will 
> run into a problem later. 
> I know that I can probably put in some <c:if statements in one of the JSPs, 
> and there discriminate between
> a User and Administrator, but somehow, that seems like a band-aid solution.
> 
> If you have any idea on how to restructure this thing, please let me know.
> 
> Thanks, Alex.
> 


-- 
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/~laurie/


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: struts and multi-level access - please give me your ideas how to restructure..

Posted by Aleksandar Matijaca <am...@gmail.com>.
Thanks Wendy, I realy appreciate the effort you put in to
explain these things.

Cheers, Alex.


On 7/15/05, Wendy Smoak <ja...@wendysmoak.com> wrote:
> 
> From: "Aleksandar Matijaca" <am...@gmail.com>
> 
> > these roles you mention, are these JAAS roles? I think that JAAS
> > roles would be way too much of an overkill for me...
> 
> Definitely not JAAS. And in my case, not even Container-Managed Security
> (though it pretends to be). :)
> 
> I have Struts Menu configured to use the result of calling
> request.isUserInRole() to decide whether to display a menu item. This is 
> as
> simple as using the "magic" value 'rolesAdapter' in the tag, which causes 
> it
> to use its RolesPermissionsAdapter:
> 
> <menu:useMenuDisplayer name="TabbedMenu"
> bundle="org.apache.struts.action.MESSAGE"
> permissions="rolesAdapter"> ...
> 
> I didn't look closely, but I'm fairly sure you can plug in a different
> PermissionsAdapter if you need to.
> 
> In my case, authorization info is stored in a database [that does not 
> easily
> speak JDBC] underneath a 3rd party telnet app. I have a Filter in front of
> the webapp that gets the authorization info out of the database, places a
> 'User' object in the session, and then wraps the request and overrides
> isUserInRole().
> 
> To do this "right" you'd probably want to override getUserPrincipal as
> well-- in fact if you can wait a bit, I *think* Frank has in mind to add a
> generic, configurable version of this idea to his Java Web Parts project.
> 
> --
> Wendy Smoak
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

Re: struts and multi-level access - please give me your ideas how to restructure..

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Yep, I did indeed have that in mind.  I was planning on blatantly ripping
off Wendy's work :)

I'm actually thinking now of a whole customization taglib, which may or
may not supercede that, I'm not sure... it's just beginning to take shape
in my warped little mind.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Fri, July 15, 2005 9:55 am, Wendy Smoak said:
> From: "Aleksandar Matijaca" <am...@gmail.com>
>
>> these roles you mention, are these JAAS roles? I think that JAAS
>> roles would be way too much of an overkill for me...
>
> Definitely not JAAS.  And in my case, not even Container-Managed Security
> (though it pretends to be). :)
>
> I have Struts Menu configured to use the result of calling
> request.isUserInRole() to decide whether to display a menu item.  This is
> as
> simple as using the "magic" value 'rolesAdapter' in the tag, which causes
> it
> to use its RolesPermissionsAdapter:
>
> <menu:useMenuDisplayer name="TabbedMenu"
>             bundle="org.apache.struts.action.MESSAGE"
>             permissions="rolesAdapter"> ...
>
> I didn't look closely, but I'm fairly sure you can plug in a different
> PermissionsAdapter if you need to.
>
> In my case, authorization info is stored in a database [that does not
> easily
> speak JDBC] underneath a 3rd party telnet app.  I have a Filter in front
> of
> the webapp that gets the authorization info out of the database, places a
> 'User' object in the session, and then wraps the request and overrides
> isUserInRole().
>
> To do this "right" you'd probably want to override getUserPrincipal as
> well-- in fact if you can wait a bit, I *think* Frank has in mind to add a
> generic, configurable version of this idea to his Java Web Parts project.
>
> --
> Wendy Smoak
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: struts and multi-level access - please give me your ideas how to restructure..

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Aleksandar Matijaca" <am...@gmail.com>

> these roles you mention, are these JAAS roles? I think that JAAS
> roles would be way too much of an overkill for me...

Definitely not JAAS.  And in my case, not even Container-Managed Security
(though it pretends to be). :)

I have Struts Menu configured to use the result of calling
request.isUserInRole() to decide whether to display a menu item.  This is as
simple as using the "magic" value 'rolesAdapter' in the tag, which causes it
to use its RolesPermissionsAdapter:

<menu:useMenuDisplayer name="TabbedMenu"
            bundle="org.apache.struts.action.MESSAGE"
            permissions="rolesAdapter"> ...

I didn't look closely, but I'm fairly sure you can plug in a different
PermissionsAdapter if you need to.

In my case, authorization info is stored in a database [that does not easily
speak JDBC] underneath a 3rd party telnet app.  I have a Filter in front of
the webapp that gets the authorization info out of the database, places a
'User' object in the session, and then wraps the request and overrides
isUserInRole().

To do this "right" you'd probably want to override getUserPrincipal as
well-- in fact if you can wait a bit, I *think* Frank has in mind to add a
generic, configurable version of this idea to his Java Web Parts project.

-- 
Wendy Smoak


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: struts and multi-level access - please give me your ideas how to restructure..

Posted by Aleksandar Matijaca <am...@gmail.com>.
Hi Wendy,

these roles you mention, are these JAAS roles? I think that JAAS
roles would be way too much of an overkill for me...

Cheers, Alex.


On 7/15/05, Wendy Smoak <ja...@wendysmoak.com> wrote:
> 
> From: "Aleksandar Matijaca" <am...@gmail.com>
> > I have an application that I am working on that requires two different
> > role levels (administrator and user).
> > The administrator, will have some extra links visible to them. I want to
> > use only one struts-config file.
> 
> Have you looked at Struts Menu? I'm currently using a tabbed menu that's
> based on roles.
> http://struts-menu.sourceforge.net/
> 
> --
> Wendy Smoak
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

Re: struts and multi-level access - please give me your ideas how to restructure..

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Aleksandar Matijaca" <am...@gmail.com>
> I have an application that I am working on that requires two different 
> role levels (administrator and user).
> The administrator, will have some extra links visible to them. I want to 
> use only one struts-config file.

Have you looked at Struts Menu?  I'm currently using a tabbed menu that's 
based on roles.
   http://struts-menu.sourceforge.net/

-- 
Wendy Smoak 



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org