Yes, it could go in BaseAction, but it might fit better in a SecurityUtils
class that all frameworks can use.

Matt

On Wed, Aug 19, 2009 at 6:07 AM, tibi <[email protected]> wrote:

>
> thanks... matt should this method go into baseaction??
>
> next question
> there is some like a hashroles or something but can;t find it now.
>
> tibi
>
>
> lounnaci wrote:
> > Hello Tibi,
> >
> > That was very helpful for me, I thank you a lot.
> > The first problem is solved. My problem now is:
> >  I want to Enable/Disable a Hyperlink on my jsp page depending on the
> user
> > role. Do you have an idea please? I dont have an experience with struts
> but
> > I am obliged o use it.
> >
> > Thanks.
> >
> >
> > tibi wrote:
> >
> >> you mean something like this:
> >>
> >>    public User getLoggedInUser() {
> >>         User currentUser = null;
> >>         final SecurityContext ctx = SecurityContextHolder.getContext();
> >>         if (ctx.getAuthentication() != null) {
> >>             final Authentication auth = ctx.getAuthentication();
> >>             if (auth.getPrincipal() instanceof UserDetails) {
> >>                 currentUser = (User) auth.getPrincipal();
> >>             } else if (auth.getDetails() instanceof UserDetails) {
> >>                 currentUser = (User) auth.getDetails();
> >>             } else {
> >>                 throw new AccessDeniedException("User not properly
> >> authenticated.");
> >>             }
> >>         }
> >>         return currentUser;
> >>     }
> >>
> >>
> >> lounnaci wrote:
> >>
> >>> How can i recuperate the user logged in name using struts?
> >>>
> >>>
> >> ---------------------------------------------------------------------
> >> 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