From 7ac3706eb961ffe39dda683a678e2fe5409898e0 Mon Sep 17 00:00:00 2001 From: Ben Alex Date: Sat, 24 Jul 2004 07:15:06 +0000 Subject: [PATCH] Allow subclasses to add their own custom GrantedAuthority[]s. --- .../acegisecurity/userdetails/jdbc/JdbcDaoImpl.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/src/main/java/org/acegisecurity/userdetails/jdbc/JdbcDaoImpl.java b/core/src/main/java/org/acegisecurity/userdetails/jdbc/JdbcDaoImpl.java index afba107dff..f435b63228 100644 --- a/core/src/main/java/org/acegisecurity/userdetails/jdbc/JdbcDaoImpl.java +++ b/core/src/main/java/org/acegisecurity/userdetails/jdbc/JdbcDaoImpl.java @@ -179,12 +179,25 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements AuthenticationDao { } GrantedAuthority[] arrayAuths = {}; + + addCustomAuthorities(user.getUsername(), dbAuths); + arrayAuths = (GrantedAuthority[]) dbAuths.toArray(arrayAuths); return new User(user.getUsername(), user.getPassword(), user.isEnabled(), arrayAuths); } + /** + * Allows subclasses to add their own granted authorities to the list to be + * returned in the User. + * + * @param username the username, for use by finder methods + * @param authorities the current granted authorities, as populated from + * the authoritiesByUsername mapping + */ + protected void addCustomAuthorities(String username, List authorities) {} + protected void initDao() throws ApplicationContextException { initMappingSqlQueries(); }