Search in sources :

Example 1 with EncryptedSecurityAnswer

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);
    }
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) EncryptedSecurityAnswer(org.orcid.jaxb.model.message.EncryptedSecurityAnswer) SecurityDetails(org.orcid.jaxb.model.message.SecurityDetails) SecurityQuestionId(org.orcid.jaxb.model.message.SecurityQuestionId)

Aggregations

EncryptedSecurityAnswer (org.orcid.jaxb.model.message.EncryptedSecurityAnswer)1 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)1 SecurityDetails (org.orcid.jaxb.model.message.SecurityDetails)1 SecurityQuestionId (org.orcid.jaxb.model.message.SecurityQuestionId)1