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