/** * Helper method to get the user information of an user as Map. * * @param username Name of the user of request * @return Map containing the user information keyed by the name of the attribute. * @throws SecurityException */ private Map<String, String> getUserInfo(String username) throws SecurityException { User user = userManager.getUser(username); if(user != null) { return user.getInfoMap(); } return new HashMap<String, String>(); }
public Map<String,String> getUserAttributes(RequestContext rc) { Map<String,String> map = null; Principal principal = rc.getRequest().getUserPrincipal(); if (principal instanceof UserSubjectPrincipal) { UserSubjectPrincipal jp = (UserSubjectPrincipal)principal; map = jp.getUser().getInfoMap(); } return map; }
public Map<String,String> getUserAttributes() { RequestContext rc = getRequestContext(); Map<String,String> map = null; Principal principal = rc.getRequest().getUserPrincipal(); if (principal instanceof UserSubjectPrincipal) { UserSubjectPrincipal jp = (UserSubjectPrincipal)principal; map = jp.getUser().getInfoMap(); } return map; }
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; } }
if(user != null) Map<String, String> userInfo = user.getInfoMap(); resultMap.put(USERINFO, userInfo);
public String resolve(RequestContext context, RuleCriterion criterion) { if (context.getUserPrincipal() instanceof User) { User user = (User)context.getUserPrincipal(); if (user != null) { Map<String, String> map = user.getInfoMap(); String attribute = (String)map.get(criterion.getName()); if (attribute != null) { return attribute; } return criterion.getValue(); } } return null; }
public UserDetailBean(User user, PasswordCredential credential, List<Role> roles, List<Group> groups, List<String> allRoles, List<String> allGroups, String rule, List<String> profilingRules) { this.name = user.getName(); this.infoMap = user.getInfoMap(); this.creationDate = user.getCreationDate(); this.modifiedDate = user.getModifiedDate(); this.enabled = user.isEnabled(); this.availableRoles = allRoles; this.availableGroups = allGroups; this.availableRules = profilingRules; this.rule = rule; this.credentialUpdateRequired = credential.isUpdateRequired(); for (Role role : roles) { this.roles = (this.roles == null ? new ArrayList<String>() : this.roles); this.roles.add(role.getName()); if (availableRoles.contains(role.getName())) { availableRoles.remove(role.getName()); } } for (Group group : groups) { this.groups = (this.groups == null ? new ArrayList<String>() : this.groups); this.groups.add(group.getName()); if (availableGroups.contains(group.getName())) { availableGroups.remove(group.getName()); } } }