andrea-patricelli commented on a change in pull request #319: URL: https://github.com/apache/syncope/pull/319#discussion_r818759453
########## File path: core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/UserDataBinderImpl.java ########## @@ -144,17 +135,42 @@ public UserTO getAuthenticatedUserTO() { private void setPassword(final User user, final String password, final SyncopeClientCompositeException scce) { try { - String algorithm = confDAO.find("password.cipher.algorithm", CipherAlgorithm.AES.name()); - user.setPassword(password, CipherAlgorithm.valueOf(algorithm)); + setCipherAlgorithm(user); + user.setPassword(password); } catch (IllegalArgumentException e) { - SyncopeClientException invalidCiperAlgorithm = SyncopeClientException.build(ClientExceptionType.NotFound); - invalidCiperAlgorithm.getElements().add(e.getMessage()); - scce.addException(invalidCiperAlgorithm); + throw aggregateException(scce, e, ClientExceptionType.NotFound); + } + } - throw scce; + private void setSecurityAnswer( + final User user, + final String securityAnswer, + final SyncopeClientCompositeException scce) { + try { + setCipherAlgorithm(user); + user.setSecurityAnswer(securityAnswer); + } catch (IllegalArgumentException e) { + throw aggregateException(scce, e, ClientExceptionType.NotFound); } } + private void setCipherAlgorithm(final Account account) { + if (account.getCipherAlgorithm() == null) { + account.setCipherAlgorithm( + CipherAlgorithm.valueOf(confDAO.find("password.cipher.algorithm", CipherAlgorithm.AES.name()))); + } + } + + private RuntimeException aggregateException( Review comment: I would keep it since it's used by `setPassword` and `setSecurityAnswer`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@syncope.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org