Search in sources :

Example 1 with SecurityQuestionId

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);
    }
}
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)

Example 2 with SecurityQuestionId

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;
}
Also used : Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) FamilyName(org.orcid.jaxb.model.message.FamilyName) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Url(org.orcid.jaxb.model.message.Url) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) SecurityQuestionId(org.orcid.jaxb.model.message.SecurityQuestionId) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) GivenNames(org.orcid.jaxb.model.message.GivenNames) Biography(org.orcid.jaxb.model.message.Biography) ResearcherUrls(org.orcid.jaxb.model.message.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) SecurityDetails(org.orcid.jaxb.model.message.SecurityDetails) Preferences(org.orcid.jaxb.model.message.Preferences)

Example 3 with SecurityQuestionId

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

Aggregations

OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)3 SecurityDetails (org.orcid.jaxb.model.message.SecurityDetails)3 SecurityQuestionId (org.orcid.jaxb.model.message.SecurityQuestionId)3 OrcidInternal (org.orcid.jaxb.model.message.OrcidInternal)2 Biography (org.orcid.jaxb.model.message.Biography)1 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)1 Email (org.orcid.jaxb.model.message.Email)1 EncryptedSecurityAnswer (org.orcid.jaxb.model.message.EncryptedSecurityAnswer)1 FamilyName (org.orcid.jaxb.model.message.FamilyName)1 GivenNames (org.orcid.jaxb.model.message.GivenNames)1 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)1 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)1 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)1 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)1 Preferences (org.orcid.jaxb.model.message.Preferences)1 ResearcherUrl (org.orcid.jaxb.model.message.ResearcherUrl)1 ResearcherUrls (org.orcid.jaxb.model.message.ResearcherUrls)1 Url (org.orcid.jaxb.model.message.Url)1