/** * @see SSOService#resetAndSendOTPTable(String, String) */ @Override public void resetAndSendOTPTable(String subsystemIdentifier, String username) throws UserNotFoundException, MessageSendException { UserForDescription user = internalSSOService.getUserDescription(username); if (user == null) { throw new UserNotFoundException(username); } hotpService.sendTableIfSupported(obtainSubsystemIdentifier(subsystemIdentifier), user.getUserId()); }
private void doResetPassword(String username, String newPassword, boolean sendPasswordByEmail) throws UserNotFoundException { UserForDescription user = internalSSOService.getUserDescription(username); if (user == null) { throw new UserNotFoundException(username); } resetPasswordStrategy.resetPassword(user.getUserId(), username, newPassword); if (sendPasswordByEmail && user.getPublicKey() != null) { // TODO: we could factor this code out to some // service method to use it also when resetting password // using Superfly UI and other means, but it's not clear // how to get SMTP server when subsystem is not known // This is to be resolved later String subsystemIdentifier = obtainSubsystemIdentifier(null); // TODO: take default from API? ByteArrayOutputStream baos = new ByteArrayOutputStream(); final String fileName = "password.txt"; try { publicKeyCrypto.encrypt(getStringBytes(newPassword), fileName, user.getPublicKey(), baos); } catch (IOException e) { // should not happen as we encrypt in memory throw new IllegalStateException("Should not happen", e); } emailService.sendPassword(subsystemIdentifier, user.getEmail(), fileName, baos.toByteArray()); } }
/** * @see SSOService#updateUserDescription(UserDescription) */ @Override public void updateUserDescription(UserDescription user) throws UserNotFoundException, BadPublicKeyException { UserForDescription userForDescription = internalSSOService.getUserDescription(user.getUsername()); if (userForDescription == null) { throw new UserNotFoundException(user.getUsername()); } userForDescription.setEmail(user.getEmail()); userForDescription.setName(user.getFirstName()); userForDescription.setSurname(user.getLastName()); userForDescription.setSecretQuestion(user.getSecretQuestion()); userForDescription.setSecretAnswer(user.getSecretAnswer()); userForDescription.setPublicKey(user.getPublicKey()); userForDescription.setOrganization(user.getOrganization()); internalSSOService.updateUserForDescription(userForDescription); }