use of org.orcid.jaxb.model.message.SecurityQuestionId 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);
}
}
use of org.orcid.jaxb.model.message.SecurityQuestionId in project ORCID-Source by ORCID.
the class OrcidProfileManagerBaseTest method createBasicProfile.
protected OrcidProfile createBasicProfile() {
OrcidProfile profile = new OrcidProfile();
profile.setPassword("password");
profile.setVerificationCode("1234");
profile.setSecurityQuestionAnswer("random answer");
profile.setOrcidIdentifier(TEST_ORCID);
OrcidBio bio = new OrcidBio();
ContactDetails contactDetails = new ContactDetails();
contactDetails.addOrReplacePrimaryEmail(new Email("will@semantico.com"));
bio.setContactDetails(contactDetails);
profile.setOrcidBio(bio);
PersonalDetails personalDetails = new PersonalDetails();
bio.setPersonalDetails(personalDetails);
personalDetails.setGivenNames(new GivenNames("Will"));
personalDetails.setFamilyName(new FamilyName("Simpson"));
bio.setBiography(new Biography("Will is a software developer"));
ResearcherUrls researcherUrls = new ResearcherUrls();
bio.setResearcherUrls(researcherUrls);
researcherUrls.getResearcherUrl().add(new ResearcherUrl(new Url("http://www.wjrs.co.uk"), null));
OrcidWorks orcidWorks = new OrcidWorks();
profile.setOrcidWorks(orcidWorks);
OrcidWork orcidWork = createWork1();
// TODO JB - needs test
// orcidWork.setAddedToProfileDate(new
// AddedToProfileDate(DateUtils.convertToXMLGregorianCalendar("2010-03-04")));
// orcidWork.setAddedToProfileDate(new
// AddedToProfileDate(DateUtils.convertToXMLGregorianCalendar("2010-03-04")));
orcidWorks.getOrcidWork().add(orcidWork);
OrcidInternal orcidInternal = new OrcidInternal();
profile.setOrcidInternal(orcidInternal);
SecurityDetails securityDetails = new SecurityDetails();
securityDetails.setSecurityQuestionId(new SecurityQuestionId(3));
orcidInternal.setSecurityDetails(securityDetails);
Preferences preferences = new Preferences();
orcidInternal.setPreferences(preferences);
return profile;
}
use of org.orcid.jaxb.model.message.SecurityQuestionId in project ORCID-Source by ORCID.
the class PasswordResetControllerTest method orcidWithSecurityQuestion.
private OrcidProfile orcidWithSecurityQuestion() {
OrcidProfile orcidProfile = new OrcidProfile();
orcidProfile.setSecurityQuestionAnswer("Answer");
OrcidInternal orcidInternal = new OrcidInternal();
SecurityDetails securityDetails = new SecurityDetails();
securityDetails.setSecurityQuestionId(new SecurityQuestionId(3));
orcidInternal.setSecurityDetails(securityDetails);
orcidProfile.setOrcidInternal(orcidInternal);
return orcidProfile;
}
Aggregations