((LDAPUserDetailsService)getSecurityComponents().userDetails).authoritiesPopulator;
prefix = api.rolePrefix;
onlyUpperCase = api.convertToUpperCase;
} catch (Exception ignore) { }
if (onlyUpperCase && !groupname.equals(groupname.toUpperCase()))
throw new UsernameNotFoundException(groupname + " should be all uppercase");
if (!groupname.startsWith(prefix))
throw new UsernameNotFoundException(groupname + " is missing prefix: " + prefix);
groupname = groupname.substring(prefix.length());
// TODO: obtain a DN instead so that we can obtain multiple attributes later
String searchBase = groupSearchBase != null ? groupSearchBase : "";
final Set<String> groups = (Set<String>)ldapTemplate.searchForSingleAttributeValues(searchBase, GROUP_SEARCH,
new String[]{groupname}, "cn");
if(groups.isEmpty())
throw new UsernameNotFoundException(groupname);
return new GroupDetails() {
public String getName() {
return groups.iterator().next();
}