Hi,
That's exactly what you have to do. I've already implemented something that
can help you and will be included in http://oness.sourceforge.net. In the
meantime you can try something similar to this:
public class UserHibernateDao
extends HibernateDaoSupport
implements AuthenticationDao {
public net.sf.acegisecurity.providers.dao.User loadUserByUsername(
String name)
throws UsernameNotFoundException, DataAccessException {
User user;
try {
user = (User) getHibernateTemplate().load(User.class, name);
/* the following is needed if using lazy loading */
// user =
// (User) getHibernateTemplate()
// .find(
// "from User as user left join fetch
user.authorities where user.name = ?",
// name)
// .get(0);
} catch (HibernateObjectRetrievalFailureException e) {
throw new UsernameNotFoundException("User not found");
}
Set auths = user.getAuthorities();
if (auths.size() == 0) {
throw new UsernameNotFoundException("User has no
GrantedAuthority");
}
GrantedAuthority[] arrayAuths = new GrantedAuthority[auths.size()];
Iterator iter = auths.iterator();
int i = 0;
while (iter.hasNext()) {
Authority element = (Authority) iter.next();
arrayAuths[i++] = new GrantedAuthorityImpl(element.getName());
}
return new net.sf.acegisecurity.providers.dao.User(
user.getName(),
user.getPassword(),
user.isEnabled(),
arrayAuths);
}
}
Regards
Carlos Sanchez
A Coru�a, Spain
Oness Project
http://oness.sourceforge.net
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> On Behalf Of Indra Gunawan
> Sent: Wednesday, June 30, 2004 8:58 AM
> To: '[EMAIL PROTECTED]'
> Subject: [Acegisecurity-developer] is there support for Hibernate?
>
> Hi all,
>
> I want to implement the security authentication using
> Hibernate? But seems that I can't find one class that support
> it.... should I extends from HibernateDaoSupport class of
> Spring framework and implements AuthenticationDao ? or do I
> miss the support class ?
>
> TIA
>
> Indra
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by Black Hat Briefings & Training.
> Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
> digital self defense, top technical experts, no vendor
> pitches, unmatched networking opportunities. Visit
> www.blackhat.com _______________________________________________
> Acegisecurity-developer mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/acegisecurity-developer
>
>
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Acegisecurity-developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/acegisecurity-developer