Issue Details (XML | Word | Printable)

Key: SM-19
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Matt Raible
Reporter: Matt Raible
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Struts Menu

PermissionsAdapter structural changes

Created: 08/May/06 11:38 PM   Updated: 08/May/06 11:41 PM
Component/s: Menu Core
Affects Version/s: 2.3
Fix Version/s: 2.5


 Description  « Hide
Moved from SourceForge - see bug on SF for patches and further details.

https://sourceforge.net/tracker/index.php?func=detail&aid=939422&group_id=48726&atid=453977

The current implementation of UseMenuDisplayerTag
contains what seem to be workaround for weaknesses in
the PermissionsAdapter class

It either creates a new instance of PermissionsAdapter
(with the Servlet request as a parameter), or retrieves a
previously stored instance from the page context.

The general idea seems to be to be able to support both
Servlet bound implementations
(RolesPermissionsAdapter), as well as non servlet bound
implementations (none that I'm aware of).

The weaknesses I see are the following (which are
caused by the definition of PermissionsAdapter):

1) if I'm in servlet mode, but don't want to use the
RolesPermissionsAdapter implementation, I can't write an
implementation of PermissionsAdapter that determines
access to a menu *for multiple logins or users*, because
the isAllowed () method only has 1 parameter:
MenuComponent... and I don't even have access to the
request, from which I could pull details of the currently
logged in user, for example.. so its a non runner.

2) If I'm in non-servlet mode, I have the same problem: I
can't check access for different users / logins, and I
have no means accessing that data because its not
available in the class, and its not available as a
parameter.

What I would suggest is the following, which would
satisfy at least the servlet mode case:

1) Define a sub-interface of PermissionsAdapter, called
ServletPermissionsAdapter (for example)

2) Define 2 additional methods on
ServletPermissionsAdapter:
public void setRequest (HttpServletRequest request)
public HttpServletRequest getRequest ()

3) Define an abstract
class "AbstractServletPermissionsAdapter" that
implements ServletPermissionsAdapter, and that
implements the setRequest and getRequest methods, by
simply storing off the "request" parameter into a private
variable for later access, and by returning the stored
variable, respectively

4) Modify RolesPermissionsAdapter to implement
AbstractServletPermissionsAdapter, instead of
PermissionsAdapter

3) Modify the getPermissionsAdapter() method in
UseMenuDisplayerTag (and others??) to do the following
(in place of the existing code):

if (permissions != null)

Matt Raible made changes - 08/May/06 11:41 PM
Field Original Value New Value
Fix Version/s 2.5 [ 10070 ]