Hi,

> So it would be really cool if the User ( which implements UserDetails )
> also had an id ( Integer ) properties.

You can return any object implementing UserDetails interface from your
loadUserByUsername() implementation of AuthenticationDao interface, so at
any place you can cast this user object from the UserDetails to your
appropriate user object and access all its properties for example the
integer id.

> Also is there any way that I could get this information into the service
> beans without adding any ageci dependant code into my struts actions ?
>

I think you can encapsulate the acegi code for obtaining the current user
into a method in your service layer like this:

public class MyServiceImpl {
  ...
public MyUser getCurrentUser() {
   SecureContext secureContext = ((SecureContext)
ContextHolder.getContext());
   final Authentication currentUser = secureContext.getAuthentication();
   return (MyUser)currentUser.getPrincipal();
}
...
}

HTH,
Karel




-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
Acegisecurity-developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/acegisecurity-developer

Reply via email to