private void addSCIMUsers(List<Object> filteredUsers, String[] userNames, List<String> requiredClaims, Map<String, String> scimToLocalClaimsMap) throws CharonException { User scimUser; for (String userName : userNames) { if (CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(userName)) { continue; } scimUser = this.getSCIMUser(userName, requiredClaims, scimToLocalClaimsMap); //if SCIM-ID is not present in the attributes, skip if (scimUser != null && StringUtils.isBlank(scimUser.getId())) { continue; } filteredUsers.add(scimUser); } }
@Override public User updateUser(User user, Map<String, Boolean> requiredAttributes) throws NotImplementedException, CharonException, BadRequestException, NotFoundException { log.debug("Updating user: {}", user); Map<String, String> attributesMap = SCIMClaimResolver.getClaimsMap(user); // need to populate the supported claims/attributes. Then filter out // user attributes against the supported list ? List<Attribute> attributeList = getAttributeListFromMap(attributesMap); try { userStoreConnector.updateUserAttributes(user.getId(), attributeList); //handle password if (user.getAttribute(SCIMConstants.UserSchemaConstants.PASSWORD) != null) { char[] password = ((SimpleAttribute) (user.getAttribute(SCIMConstants.UserSchemaConstants.PASSWORD))) .getStringValue().toCharArray(); PasswordCallback passwordCallback = new PasswordCallback(SCIMConstants.UserSchemaConstants.PASSWORD, false); passwordCallback.setPassword(password); userStoreConnector.updateCredentials(user.getId(), passwordCallback); } // get the updated user from the user core and sent it to client. return this.getUser(user.getId(), requiredAttributes); } catch (UserStoreConnectorException e) { //Charon wrap exception to SCIMResponse and does not log exceptions log.error("Error occurred while updating user: " + user + " to user store", e); handleUserStoreExceptionWhenUpdating(e); } return null; }
@Override public User updateUser(User user, Map<String, Boolean> requiredAttributes) throws NotImplementedException, CharonException, BadRequestException, NotFoundException { try { if (log.isDebugEnabled()) { log.debug("Updating user: " + user.toString()); } //get the claims map from the new scim user object. Map<String, String> claims = SCIMClaimResolver.getClaimsMap(user); //get the claim list to be updated. List<Claim> claimList = getUserBeanFromClaims(claims).getClaims(); //TODO this is a temporary method. need to remove this once the claim management is completed. claimList = ClaimMapper.getInstance().convertMetaToWso2Dialect(claimList); //set user updated claim values identityStore.updateUserClaims(user.getId(), claimList); if (log.isDebugEnabled()) { log.debug("User: " + user.getUserName() + " updated through SCIM."); } //get the updated user from the user core and sent it to client. return this.getUser(user.getId(), requiredAttributes); } catch (UserNotFoundException | NotFoundException e) { throw new NotFoundException("No such user with the user id : " + user.getId()); } catch (IdentityStoreException e) { throw new CharonException("Error in updating the user", e); } }
String userId = user.getId(); if (userId == null) { logger.error("Trying to delete a user entry which doesn't support SCIM. " +
Group group = (Group) SCIMClaimResolver.constructSCIMObjectFromAttributes(attributes, SCIMCommonConstants.GROUP); group.setMember(addedUser.getId(), username); group.setId(UUID.randomUUID().toString()); Group newGroup = userManager.createGroup(group, requiredGroupAttributes);
Optional<User> user = Optional.ofNullable(getSCIMUser(userId, requiredUserClaims, false)); if (user.isPresent()) { scimGroup.setMember(user.get().getId(), user.get().getUserName()); } else { log.warn("User " + userId + " recorded as member of group " + groupId + " but user "
String userStoreDomainFromSP = getUserStoreDomainFromSP(); SCIMResourceTypeSchema schema = SCIMResourceSchemaManager.getInstance().getUserResourceSchema(); User oldUser = this.getUser(user.getId(), ResourceManagerUtil.getAllAttributeURIs(schema)); if (userStoreDomainFromSP != null && !userStoreDomainFromSP .equalsIgnoreCase(IdentityUtil.extractDomainFromName(oldUser.getUserName()))) { return getUser(user.getId(),requiredAttributes); } catch (UserStoreException e) { handleErrorsOnUserNameAndPasswordPolicy(e);
if (users != null && users.size() > 0) { user = users.get(0); String userId = user.getId(); if (userId == null) { logger.error("Trying to update a user entry which doesn't support SCIM. " +
String userId = null; for (SCIMObject filteredUser : filteredUsers) { userId = ((User) filteredUser).getId();