@Override public void updateSecurityQuestionInformation(OrcidProfile updatedOrcidProfile) { String orcid = updatedOrcidProfile.getOrcidIdentifier().getPath(); SecurityQuestionId securityQuestionId = updatedOrcidProfile.getOrcidInternal().getSecurityDetails().getSecurityQuestionId(); Integer questionId = null; if (securityQuestionId != null) { questionId = new Long(securityQuestionId.getValue()).intValue(); } String unencryptedAnswer = updatedOrcidProfile.getSecurityQuestionAnswer(); String encryptedAnswer = encrypt(unencryptedAnswer); profileDao.updateSecurityQuestion(orcid, questionId, questionId != null ? encryptedAnswer : null); OrcidProfile cachedProfile = orcidProfileCacheManager.retrieve(orcid); if (cachedProfile != null) { profileDao.flush(); SecurityDetails securityDetails = initSecurityDetails(cachedProfile); securityDetails.setSecurityQuestionId(questionId != null ? new SecurityQuestionId(questionId) : null); securityDetails.setEncryptedSecurityAnswer(encryptedAnswer != null ? new EncryptedSecurityAnswer(encryptedAnswer) : null); cachedProfile.setSecurityQuestionAnswer(encryptedAnswer != null ? unencryptedAnswer : null); orcidProfileCacheManager.put(cachedProfile); } }
profileEntity.setEncryptedPassword(encryptedPassword); profileEntity.setSecurityQuestion(securityDetails.getSecurityQuestionId() == null ? null : securityQuestionDao.find((int) securityDetails .getSecurityQuestionId().getValue()));