/** * The userId needs to be passed explicitly. It can be the email, but also the external id when eg LDAP is being used. */ public FlowableAppUser(org.flowable.idm.api.User user, String userId, Collection<? extends GrantedAuthority> authorities) { super(userId, user.getPassword() != null ? user.getPassword() : "", authorities); // password needs to be non null this.userObject = user; }
@Override public Boolean checkPassword(String userId, String password, PasswordEncoder passwordEncoder, PasswordSalt salt) { User user = null; if (userId != null) { user = findById(userId); } return (user != null) && (password != null) && passwordEncoder.isMatches(password, user.getPassword(), salt); }
public void changePassword(String originalPassword, String newPassword) { User user = identityService.createUserQuery().userId(SecurityUtils.getCurrentUserId()).singleResult(); if (!user.getPassword().equals(originalPassword)) { throw new NotFoundException(); } user.setPassword(newPassword); identityService.updateUserPassword(user); }
@Override public User execute(CommandContext commandContext) { if (!CommandContextUtil.getUserEntityManager(commandContext).isNewUser(user)) { PasswordEncoder passwordEncoder = CommandContextUtil.getIdmEngineConfiguration().getPasswordEncoder(); PasswordSalt passwordSalt = CommandContextUtil.getIdmEngineConfiguration().getPasswordSalt(); user.setPassword(passwordEncoder.encode(user.getPassword(), passwordSalt)); CommandContextUtil.getUserEntityManager(commandContext).updateUser(user); } return user; } }
public UserResponse createUserResponse(User user, boolean incudePassword, RestUrlBuilder urlBuilder) { UserResponse response = new UserResponse(); response.setFirstName(user.getFirstName()); response.setLastName(user.getLastName()); response.setDisplayName(user.getDisplayName()); response.setId(user.getId()); response.setEmail(user.getEmail()); if (incudePassword) { response.setPassword(user.getPassword()); } return response; }
@Override public Void execute(CommandContext commandContext) { if (user == null) { throw new FlowableIllegalArgumentException("user is null"); } if (CommandContextUtil.getUserEntityManager(commandContext).isNewUser(user)) { if (user.getPassword() != null) { PasswordEncoder passwordEncoder = CommandContextUtil.getIdmEngineConfiguration().getPasswordEncoder(); PasswordSalt passwordSalt = CommandContextUtil.getIdmEngineConfiguration().getPasswordSalt(); user.setPassword(passwordEncoder.encode(user.getPassword(), passwordSalt)); } if (user instanceof UserEntity) { CommandContextUtil.getUserEntityManager(commandContext).insert((UserEntity) user, true); } else { CommandContextUtil.getDbSqlSession(commandContext).insert((Entity) user); } } else { UserEntity dbUser = CommandContextUtil.getUserEntityManager().findById(user.getId()); user.setPassword(dbUser.getPassword()); CommandContextUtil.getUserEntityManager().updateUser(user); } return null; } }