public UserAttributeRef getUserAttributeRef(String name) { for (UserAttributeRef uar : getUserAttributeRefs()) { if (uar.getName().equals(name)) { return uar; } } return null; }
public Map<String, String> getUserAttributeMap(Subject subject, Collection<UserAttributeRef> userAttributeRefs, RequestContext context) { Map<String,String> userAttributeMap = new HashMap<String,String>(); Principal userPrincipal = SubjectHelper.getPrincipal(subject, User.class); if (null != userPrincipal) { log.debug("Got user principal: " + userPrincipal.getName()); Map<String, String> userInfo = ((User)userPrincipal).getInfoMap(); if (userAttributeRefs != null) { for (UserAttributeRef currentAttributeRef : userAttributeRefs) { String key = currentAttributeRef.getNameLink(); String name = currentAttributeRef.getName(); if (key == null) { key = name; } if (userInfo.containsKey(key)) { userAttributeMap.put(name, userInfo.get(key)); } } } } return userAttributeMap; } }