Thanks Ben. I think you may have misunderstood my question though. I've implmented my AuthenticationDao, and it works fine. I'm trying to understand why my role names have to be converted to "ROLE_" + role.toUpperCase() as in the following example:
Code:
package com.briankuhn.webapp.web.acegisecurity;
import com.briankuhn.webapp.data.value.Account;
import com.briankuhn.webapp.data.access.AccountDAO;
import ...
public class AccountAuthenticationDAO implements AuthenticationDao {
private AccountDAO accountDAO = null;
public void setAccountDAO(AccountDAO accountDAO) {
this.accountDAO = accountDAO;
}
public UserDetails loadUserByUsername(String username) {
UserDetails userDetails = null;
if (this.accountDAO != null) {
Account account = this.accountDAO.get(username);
if (account != null) {
String role = account.getRole();
if (role == null) {
role = "";
}
else {
role = "ROLE_" + role.toUpperCase();
}
GrantedAuthority[] authorities =
new GrantedAuthority[] {new GrantedAuthorityImpl(role)};
userDetails = new User(account.getEmailAddress(),
account.getPassword(),
true,
authorities);
}
}
return userDetails;
}
}
I'd rather use the roles already defined in my db (admin/user) and have a filterInvocationInterceptor configuration like this:
Code:
<bean id="filterInvocationInterceptor" class="net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor">
<property name="authenticationManager"><ref local="authenticationManager"/></property>
<property name="accessDecisionManager"><ref local="accessDecisionManager"/></property>
<property name="objectDefinitionSource">
<value>
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
PATTERN_TYPE_APACHE_ANT
/secure/admin/**=admin
/secure/**=user
</value>
</property>
</bean>
Am I missing the point?