You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "T. Papke" <de...@thopap.de> on 2007/10/02 14:24:49 UTC

RequestGlobals in tapestry-ACEGI UserDetailsService

Hi,

i have tried the tapestry 5 acegi example providing security controll 
for tapestry pages.

I need the hostname of the requested url for getting the user by 
username. So i want to have the username per page.

I have tried it with RequestGlobals, but it did not work to inject it 
into this service? Anyone an idea?


public class UserDetailsServiceImpl implements UserDetailsService {
    private final Session session;
    public UserDetailsServiceImpl(Session session) {
        this.session = session;
    }
   
    public UserDetails loadUserByUsername(String username)
            throws UsernameNotFoundException, DataAccessException {
        ....
       //here i need the hostname of the request to do something like 
'SELECT x FROM UserDetailsBean x WHERE x.username = :username and 
x.hostname=:hostname'
       ...
        return bean;
    }
}


Thank you,
Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: RequestGlobals in tapestry-ACEGI UserDetailsService

Posted by Robin Helgelin <lo...@gmail.com>.
On 10/2/07, T. Papke <de...@thopap.de> wrote:
> Hi,

Hi!

> i have tried the tapestry 5 acegi example providing security controll
> for tapestry pages.
>
> I need the hostname of the requested url for getting the user by
> username. So i want to have the username per page.
>
> I have tried it with RequestGlobals, but it did not work to inject it
> into this service? Anyone an idea?

How do you inject it? @Inject on members only works on page and
component classes. You need to add RequestGlobals to the constructor
as Session is done, and depending on how you define your service in
AppModule inject the RequestGlobals there.

> public class UserDetailsServiceImpl implements UserDetailsService {
>     private final Session session;
>     public UserDetailsServiceImpl(Session session) {
>         this.session = session;
>     }

-- 
        regards,
        Robin

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org