private void retriveSCIMUsers(List<Object> users, String[] userNames, List<String> requiredClaims, Map<String, String> scimToLocalClaimsMap) throws CharonException { for (String userName : userNames) { if (userName.contains(UserCoreConstants.NAME_COMBINER)) { userName = userName.split("\\" + UserCoreConstants.NAME_COMBINER)[0]; } User scimUser = this.getSCIMUser(userName, requiredClaims, scimToLocalClaimsMap); if (scimUser != null) { Map<String, Attribute> attrMap = scimUser.getAttributeList(); if (attrMap != null && !attrMap.isEmpty()) { users.add(scimUser); } } } }
/** * Sets the password for the user. * * @param user * @param password * @throws CharonException * @throws BadRequestException */ private void setPassword(User user, String password) throws CharonException, BadRequestException { if (user.isAttributeExist(SCIMConstants.UserSchemaConstants.PASSWORD)) { ((SimpleAttribute) user.getAttributeList().get(SCIMConstants.UserSchemaConstants.PASSWORD)). updateValue(password); } else { SimpleAttribute simpleAttribute = new SimpleAttribute(SCIMConstants.UserSchemaConstants.PASSWORD, password); simpleAttribute = (SimpleAttribute) DefaultAttributeFactory. createAttribute(SCIMSchemaDefinitions.SCIMUserSchemaDefinition.PASSWORD, simpleAttribute); user.getAttributeList().put(SCIMConstants.UserSchemaConstants.PASSWORD, simpleAttribute); } }
/** * Retrieve user attribute for given introspect response * * @param introspectionResponse Introspect response * @return Map of user attributes * @throws UserInfoException If failed to retrieve user attributes */ public static Map<String, Attribute> getUserAttributes(IntrospectionResponse introspectionResponse) throws UserInfoException { Map<String, Attribute> userAttributes = new HashMap<>(); try { User user = getUserManager().getMe(introspectionResponse.getUsername(), null); if (user != null) { userAttributes = user.getAttributeList(); } } catch (CharonException | BadRequestException | NotFoundException e) { String errorMsg = "Error while retrieving user attributes."; throw new UserInfoException(errorMsg, e, ExceptionCodes.INTERNAL_ERROR); } return userAttributes; }