your suggestion make sense.
however, I'm still finding a place for injecting my sessionFactory. Could I just inject it inside my own LdapAuthenticationProvider. A portion of my config is:
Code:
<bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager">
<property name="providers">
<list>
<ref local="ldapRoleAuthenticationProvider" />
</list>
</property>
</bean>
<bean id="ldapRoleAuthenticationProvider" class="com.fimat.security.util.LdapRoleAuthenticationProvider">
<constructor-arg>
<bean class="org.acegisecurity.providers.ldap.authenticator.BindAuthenticator">
...
</bean>
</constructor-arg>
<constructor-arg>
<bean class="org.acegisecurity.providers.ldap.populator.DefaultLdapAuthoritiesPopulator">
<constructor-arg>
<ref local="initialDirContextFactory"/>
</constructor-arg>
<constructor-arg>
...
</constructor-arg>
<property name="groupRoleAttribute">
...
</property>
</bean>
</constructor-arg>
</bean>
I try to embed the HibernateTemplate but find no way to inject the sessionFactory:
Code:
public class LdapRoleAuthenticationProvider extends LdapAuthenticationProvider{
public LdapRoleAuthenticationProvider(LdapAuthenticator arg0, LdapAuthoritiesPopulator arg1) {
super(arg0, arg1);
}
private HibernateTemplate hibernateTemplate;
public void setSessionFactory(SessionFactory sessionFactory)
{
hibernateTemplate = new HibernateTemplate(sessionFactory);
}
public List getUserRoleList(String userID)
{
return hibernateTemplate.findByNamedQueryAndNamedParam("getRolesAuthenticated", "user_id", userID);
}
}
Sorry for posting long code and appreciated for any suggestions.