byte[] rbytes = roleblob.getBytes(1, (int) roleblob.length());
String s1 = new String(rbytes);
String[] roles = s1.split(",");
for (String role : roles) {
System.out.println("Found role " + role + " for " + rs.getString("username"));
GrantedAuthorityImpl authority = new GrantedAuthorityImpl(role);
roleList.add(authority);
}
}
else {
System.out.println("Cannot process user login - cannot extract roles from database");
}
}
try {
if (rs.getBoolean("admin")) roleList.add(new GrantedAuthorityImpl("ROLE_ADMIN"));
if (rs.getBoolean("external")) roleList.add(new GrantedAuthorityImpl("ROLE_EXTERNAL"));
if (rs.getBoolean("internal")) roleList.add(new GrantedAuthorityImpl("ROLE_INTERNAL"));
}
catch (SQLException e) {
e.printStackTrace();
log.warn("Couldn't retrieve a user property to convert to a role: " + e.getMessage());
}