Search in sources :

Example 1 with SecurityDetails

use of org.orcid.jaxb.model.message.SecurityDetails 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 SecurityDetails

use of org.orcid.jaxb.model.message.SecurityDetails in project ORCID-Source by ORCID.

the class OrcidProfileManagerImpl method initSecurityDetails.

private SecurityDetails initSecurityDetails(OrcidProfile cachedProfile) {
    OrcidInternal internal = cachedProfile.getOrcidInternal();
    if (internal == null) {
        internal = new OrcidInternal();
        cachedProfile.setOrcidInternal(internal);
    }
    SecurityDetails securityDetails = internal.getSecurityDetails();
    if (securityDetails == null) {
        securityDetails = new SecurityDetails();
        internal.setSecurityDetails(securityDetails);
    }
    return securityDetails;
}
Also used : OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) SecurityDetails(org.orcid.jaxb.model.message.SecurityDetails)

Example 3 with SecurityDetails

use of org.orcid.jaxb.model.message.SecurityDetails in project ORCID-Source by ORCID.

the class OrcidProfileManagerImpl method updatePasswordInformation.

@Override
@Transactional
public void updatePasswordInformation(OrcidProfile updatedOrcidProfile) {
    String orcid = updatedOrcidProfile.getOrcidIdentifier().getPath();
    String hashedPassword = hash(updatedOrcidProfile.getPassword());
    profileDao.updateEncryptedPassword(orcid, hashedPassword);
    OrcidProfile cachedProfile = orcidProfileCacheManager.retrieve(orcid);
    if (cachedProfile != null) {
        profileDao.flush();
        SecurityDetails securityDetails = initSecurityDetails(cachedProfile);
        securityDetails.setEncryptedPassword(new EncryptedPassword(hashedPassword));
        cachedProfile.setPassword(hashedPassword);
        orcidProfileCacheManager.put(cachedProfile);
    }
    updateSecurityQuestionInformation(updatedOrcidProfile);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) SecurityDetails(org.orcid.jaxb.model.message.SecurityDetails) EncryptedPassword(org.orcid.jaxb.model.message.EncryptedPassword) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with SecurityDetails

use of org.orcid.jaxb.model.message.SecurityDetails in project ORCID-Source by ORCID.

the class Jaxb2JpaAdapterImpl method setInternalDetails.

private void setInternalDetails(ProfileEntity profileEntity, OrcidInternal orcidInternal) {
    if (orcidInternal != null) {
        SecurityDetails securityDetails = orcidInternal.getSecurityDetails();
        if (securityDetails != null) {
            String encryptedPassword = securityDetails.getEncryptedPassword() != null ? securityDetails.getEncryptedPassword().getContent() : null;
            profileEntity.setEncryptedPassword(encryptedPassword);
            profileEntity.setSecurityQuestion(securityDetails.getSecurityQuestionId() == null ? null : securityQuestionDao.find((int) securityDetails.getSecurityQuestionId().getValue()));
            String encryptedAnswer = securityDetails.getEncryptedSecurityAnswer() != null ? securityDetails.getEncryptedSecurityAnswer().getContent() : null;
            profileEntity.setEncryptedSecurityAnswer(encryptedAnswer);
            String verificationCode = securityDetails.getEncryptedVerificationCode() != null ? securityDetails.getEncryptedVerificationCode().getContent() : null;
            profileEntity.setEncryptedVerificationCode(verificationCode);
        }
        if (orcidInternal.getReferredBy() != null) {
            profileEntity.setReferredBy(orcidInternal.getReferredBy().getPath());
        }
        Preferences preferences = orcidInternal.getPreferences();
        if (preferences != null) {
            String sendEmailFrequencyDays = preferences.getSendEmailFrequencyDays();
            profileEntity.setSendEmailFrequencyDays(Float.valueOf(sendEmailFrequencyDays == null ? DefaultPreferences.SEND_EMAIL_FREQUENCY_DAYS : sendEmailFrequencyDays));
            profileEntity.setSendChangeNotifications(preferences.getSendChangeNotifications() == null ? null : preferences.getSendChangeNotifications().isValue());
            profileEntity.setSendOrcidNews(preferences.getSendOrcidNews() == null ? null : preferences.getSendOrcidNews().isValue());
            profileEntity.setSendMemberUpdateRequests(preferences.getSendMemberUpdateRequests() == null ? null : preferences.getSendMemberUpdateRequests());
            // ActivitiesVisibilityDefault default is WorkVisibilityDefault
            if (preferences.getActivitiesVisibilityDefault() != null && preferences.getActivitiesVisibilityDefault().getValue() != null) {
                profileEntity.setActivitiesVisibilityDefault(org.orcid.jaxb.model.common_v2.Visibility.fromValue(preferences.getActivitiesVisibilityDefault().getValue().value()));
            }
            if (preferences.getDeveloperToolsEnabled() != null) {
                profileEntity.setEnableDeveloperTools(preferences.getDeveloperToolsEnabled().isValue());
            }
            profileEntity.setEnableNotifications(preferences.getNotificationsEnabled() == null ? DefaultPreferences.NOTIFICATIONS_ENABLED : preferences.getNotificationsEnabled());
        }
        if (orcidInternal.getSalesforceId() != null) {
            profileEntity.setSalesforeId(orcidInternal.getSalesforceId().getContent());
        }
    }
}
Also used : SecurityDetails(org.orcid.jaxb.model.message.SecurityDetails) Preferences(org.orcid.jaxb.model.message.Preferences) OrcidPreferences(org.orcid.jaxb.model.message.OrcidPreferences) DefaultPreferences(org.orcid.core.constants.DefaultPreferences)

Example 5 with SecurityDetails

use of org.orcid.jaxb.model.message.SecurityDetails in project ORCID-Source by ORCID.

the class JpaJaxbEntityAdapterToOrcidProfileTest method checkOrcidInternal.

private void checkOrcidInternal(OrcidInternal orcidInternal) {
    SecurityDetails securityDetails = orcidInternal.getSecurityDetails();
    assertNotNull(securityDetails);
    assertEquals("e9adO9I4UpBwqI5tGR+qDodvAZ7mlcISn+T+kyqXPf2Z6PPevg7JijqYr6KGO8VOskOYqVOEK2FEDwebxWKGDrV/TQ9gRfKWZlzxssxsOnA=", securityDetails.getEncryptedPassword().getContent());
    assertEquals(1, securityDetails.getSecurityQuestionId().getValue());
    assertEquals("iTlIoR2JsFl5guE56cazmg==", securityDetails.getEncryptedSecurityAnswer().getContent());
    assertEquals("1vLkD2Lm8c24TyALcW0Brg==", securityDetails.getEncryptedVerificationCode().getContent());
    Preferences preferences = orcidInternal.getPreferences();
    assertNotNull(preferences);
    assertTrue(preferences.getSendChangeNotifications().isValue());
    assertFalse(preferences.getSendOrcidNews().isValue());
}
Also used : SecurityDetails(org.orcid.jaxb.model.message.SecurityDetails) Preferences(org.orcid.jaxb.model.message.Preferences)

Aggregations

SecurityDetails (org.orcid.jaxb.model.message.SecurityDetails)7 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)4 OrcidInternal (org.orcid.jaxb.model.message.OrcidInternal)3 Preferences (org.orcid.jaxb.model.message.Preferences)3 SecurityQuestionId (org.orcid.jaxb.model.message.SecurityQuestionId)3 DefaultPreferences (org.orcid.core.constants.DefaultPreferences)1 Biography (org.orcid.jaxb.model.message.Biography)1 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)1 Email (org.orcid.jaxb.model.message.Email)1 EncryptedPassword (org.orcid.jaxb.model.message.EncryptedPassword)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 OrcidPreferences (org.orcid.jaxb.model.message.OrcidPreferences)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 ResearcherUrl (org.orcid.jaxb.model.message.ResearcherUrl)1 ResearcherUrls (org.orcid.jaxb.model.message.ResearcherUrls)1