use of org.orcid.jaxb.model.message.EncryptedSecurityAnswer in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method updateSecurityQuestionInformation.
@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);
}
}
Aggregations