@Override public String getUserIdentifier() { return user.getUniqueUserId(); } }
private void validateUser(User user) throws IdentityRecoveryException { if (user == null || StringUtils.isBlank(user.getUniqueUserId())) { throw Utils.handleClientException( IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_INVALID_USER, "Invalid User Data provided."); } }
public List<String> getUserChallengeQuestionIds(User user) throws IdentityRecoveryException { validateUser(user); if (log.isDebugEnabled()) { log.debug("Retrieving answered Challenge question set ids from the user profile."); } List<String> challengesUris = getChallengeQuestionUris(user.getUniqueUserId()); if (challengesUris.isEmpty()) { String msg = "No associated challenge question found for the user : " + user.getUniqueUserId(); if (log.isDebugEnabled()) { log.debug(msg); } } return challengesUris; }
private String getLocaleOfUser(User user) throws IdentityRecoveryException { String locale = IdentityRecoveryConstants.LOCALE_EN_US; try { String userLocale = Utils.getClaimFromIdentityStore(user.getUniqueUserId(), IdentityRecoveryConstants.Questions .LOCALE_CLAIM); if (StringUtils.isNotBlank(userLocale)) { locale = userLocale; } } catch (IdentityStoreException e) { String errorMsg = String.format("Error when retrieving the locale claim of user '%s'.", user.getUniqueUserId()); log.error(errorMsg); throw new IdentityRecoveryServerException(errorMsg, e); } catch (UserNotFoundException e) { String errorMsg = String.format("Error when retrieving the locale claim of user '%s'.", user.getUniqueUserId()); log.error(errorMsg); throw new IdentityRecoveryServerException(errorMsg, e); } return locale; }
triggerNotification(user.getUniqueUserId(), IdentityRecoveryConstants.NOTIFICATION_ACCOUNT_ID_RECOVERY, user); joiner.add(user1.getUniqueUserId()); });
private User doGetUser(String uniqueUserId, String domainName) throws IdentityStoreException, UserNotFoundException { Cache<String, User> userCache = cacheManager.getCache(UNIQUE_USER_CACHE, String.class, User.class); User user = userCache.get(uniqueUserId.hashCode() + ":" + domainName.hashCode()); if (user == null) { user = identityStore.getUser(uniqueUserId); userCache.put(user.getUniqueUserId().hashCode() + ":" + user.getDomainName().hashCode(), user); user.setIdentityStore(this); return user; } user.setIdentityStore(this); return user; }
@Override public UUFUser addUser(Map<String, String> userClaims, Map<String, String> credentials) throws UserPortalUIException { UserBean userBean = new UserBean(); List<Claim> claimsList = new ArrayList<>(); List<Callback> credentialsList = new ArrayList<>(); User identityUser; for (Map.Entry<String, String> credential : credentials.entrySet()) { PasswordCallback passwordCallback = new PasswordCallback("password", false); passwordCallback.setPassword(credential.getValue().toCharArray()); credentialsList.add(passwordCallback); } for (Map.Entry<String, String> entry : userClaims.entrySet()) { Claim claim = new Claim(); claim.setClaimUri(entry.getKey()); claim.setValue(entry.getValue()); claimsList.add(claim); } userBean.setClaims(claimsList); userBean.setCredentials(credentialsList); try { identityUser = getRealmService().getIdentityStore().addUser(userBean); } catch (IdentityStoreException e) { String error = "Error while adding user."; LOGGER.error(error, e); throw new UserPortalUIException(error); } return new UUFUser(null, identityUser.getUniqueUserId(), identityUser.getDomainName()); }
@Override public UUFUser addUser(Map<String, String> userClaims, Map<String, String> credentials, String domainName) throws UserPortalUIException { UserBean userBean = new UserBean(); List<Claim> claimsList = new ArrayList<>(); List<Callback> credentialsList = new ArrayList<>(); User identityUser; for (Map.Entry<String, String> credential : credentials.entrySet()) { PasswordCallback passwordCallback = new PasswordCallback("password", false); passwordCallback.setPassword(credential.getValue().toCharArray()); credentialsList.add(passwordCallback); } for (Map.Entry<String, String> entry : userClaims.entrySet()) { Claim claim = new Claim(); claim.setClaimUri(entry.getKey()); claim.setValue(entry.getValue()); claimsList.add(claim); } userBean.setClaims(claimsList); userBean.setCredentials(credentialsList); try { identityUser = getRealmService().getIdentityStore().addUser(userBean, domainName); } catch (IdentityStoreException e) { String error = "Error while adding user."; LOGGER.error(error, e); throw new UserPortalUIException(error); } return new UUFUser(null, identityUser.getUniqueUserId(), identityUser.getDomainName()); }
List<Claim> claimsList = identityStore.getClaimsOfUser(user.getUniqueUserId()); claim.setDialectUri(dialectUri); claimsList.add(claim); identityStore.updateUserClaims(user.getUniqueUserId(), claimsList);
@Override public UUFUser authenticate(String username, char[] password, String domain) throws UserPortalUIException { try { //TODO if different claim is used, need identify that claim. Claim usernameClaim = new Claim(IdentityMgtConstants.CLAIM_ROOT_DIALECT, IdentityMgtConstants.USERNAME_CLAIM, username); PasswordCallback passwordCallback = new PasswordCallback("password", false); passwordCallback.setPassword(password); AuthenticationContext authenticationContext = getRealmService().getIdentityStore() .authenticate(usernameClaim, new Callback[]{passwordCallback}, domain); User identityUser = authenticationContext.getUser(); //TODO if another claim used, need to load username claim return new UUFUser(username, identityUser.getUniqueUserId(), identityUser.getDomainName()); } catch (AuthenticationFailure e) { String error = "Invalid credentials."; if (LOGGER.isDebugEnabled()) { LOGGER.debug(error, e); } throw new UserPortalUIException("Invalid credentials."); } catch (IdentityStoreException e) { String error = "Failed to authenticate user."; LOGGER.error(error, e); throw new UserPortalUIException(error); } }
identityStore.getGroupsOfUser(userStoreUser.getUniqueUserId()); scimUser.setId(userStoreUser.getUniqueUserId()); scimUser.setLocation(SCIMCommonConstants.USERS_LOCATION + "/" + userStoreUser.getUniqueUserId());
String uniqueUserID = user.getUniqueUserId(); .getUniqueUserId(), id))).collect(Collectors.toList());
.getQuestion().getQuestion() != null && userChallengeAnswer.getAnswer() != null) { String oldValue = Utils.getClaimFromIdentityStore(user.getUniqueUserId(), userChallengeAnswer.getQuestion().getQuestionSetId().trim()); IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_QUESTION_OF_USER, user.getUniqueUserId(), e);
String uniqueUserId = user.getUniqueUserId(); userRecoveryDataStore.invalidateByUserUniqueId(uniqueUserId);
List<Claim> claimValueList = identityStore.getUser(user.getUniqueUserId()).getClaims(metaClaimList); scimGroup.setMember(user.getUniqueUserId(), claimValueList.get(0).getValue());
identityStore.updateGroupsOfUser(userStoreUser.getUniqueUserId(), groupIds); return this.getUser(userStoreUser.getUniqueUserId(), requiredAttributes);