if (LOG.isLoggable(Level.FINEST)) {
LOG.finest("Retrieve claims for user " + user);
}
}
AndFilter filter = new AndFilter();
filter.and(
new EqualsFilter("objectclass", this.getObjectClass())).and(
new EqualsFilter(this.getUserNameAttribute(), user));
List<String> searchAttributeList = new ArrayList<String>();
for (RequestClaim claim : claims) {
if (getClaimsLdapAttributeMapping().keySet().contains(claim.getClaimType().toString())) {
searchAttributeList.add(
getClaimsLdapAttributeMapping().get(claim.getClaimType().toString())
);
} else {
if (LOG.isLoggable(Level.FINER)) {
LOG.finer("Unsupported claim: " + claim.getClaimType());
}
}
}
String[] searchAttributes = null;
searchAttributes = searchAttributeList.toArray(new String[] {});
AttributesMapper mapper =
new AttributesMapper() {
public Object mapFromAttributes(Attributes attrs) throws NamingException {
Map<String, Attribute> map = new HashMap<String, Attribute>();
NamingEnumeration<? extends Attribute> attrEnum = attrs.getAll();
while (attrEnum.hasMore()) {
Attribute att = attrEnum.next();
map.put(att.getID(), att);
}
return map;
}
};
List<?> result = ldap.search((this.userBaseDn == null) ? "" : this.userBaseDn, filter.toString(),
SearchControls.SUBTREE_SCOPE, searchAttributes, mapper);
Map<String, Attribute> ldapAttributes = null;
if (result != null && result.size() > 0) {
ldapAttributes = CastUtils.cast((Map<?, ?>)result.get(0));