use of org.orcid.persistence.jpa.entities.EmailEntity in project ORCID-Source by ORCID.
the class EmailDaoTest method testVerifyCaseSensitive.
@Test
public void testVerifyCaseSensitive() {
EmailEntity email = emailDao.find("teddybass3public@semantico.com");
assertNotNull(email);
assertFalse(email.getVerified());
emailDao.verifyEmail("TeDdYbAsS3PuBlIc@semantico.com");
email = emailDao.find("teddybass3public@semantico.com");
assertNotNull(email);
assertTrue(email.getVerified());
}
use of org.orcid.persistence.jpa.entities.EmailEntity in project ORCID-Source by ORCID.
the class ManageProfileController method searchForDelegateByEmail.
@RequestMapping(value = "/search-for-delegate-by-email/{email}/")
@ResponseBody
public Map<String, Boolean> searchForDelegateByEmail(@PathVariable String email) {
Map<String, Boolean> map = new HashMap<>();
EmailEntity emailEntity = emailManager.findCaseInsensitive(email);
if (emailEntity == null) {
map.put(FOUND, Boolean.FALSE);
return map;
} else {
map.put(FOUND, Boolean.TRUE);
map.put(IS_SELF, emailEntity.getProfile().getId().equals(getCurrentUserOrcid()));
return map;
}
}
use of org.orcid.persistence.jpa.entities.EmailEntity in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method retrieveOrcidProfileByEmail.
@Override
@Transactional
public OrcidProfile retrieveOrcidProfileByEmail(String email, LoadOptions loadOptions) {
EmailEntity emailEntity = emailDao.findCaseInsensitive(email);
if (emailEntity != null) {
ProfileEntity profileEntity = emailEntity.getProfile();
OrcidProfile orcidProfile = adapter.toOrcidProfile(profileEntity, loadOptions);
String verificationCode = profileEntity.getEncryptedVerificationCode();
String securityAnswer = profileEntity.getEncryptedSecurityAnswer();
orcidProfile.setVerificationCode(decrypt(verificationCode));
orcidProfile.setSecurityQuestionAnswer(decrypt(securityAnswer));
return orcidProfile;
} else {
return null;
}
}
use of org.orcid.persistence.jpa.entities.EmailEntity in project ORCID-Source by ORCID.
the class Jpa2JaxbAdapterImpl method toOrcidClientGroup.
@Override
public OrcidClientGroup toOrcidClientGroup(ProfileEntity profileEntity) {
OrcidClientGroup group = new OrcidClientGroup();
group.setGroupOrcid(profileEntity.getId());
if (profileEntity.getRecordNameEntity() != null) {
group.setGroupName(profileEntity.getRecordNameEntity().getCreditName());
}
group.setType(profileEntity.getGroupType());
Set<EmailEntity> emailEntities = profileEntity.getEmails();
for (EmailEntity emailEntity : emailEntities) {
group.setEmail(emailEntity.getId());
}
for (ClientDetailsEntity clientDetailsEntity : profileEntity.getClients()) {
OrcidClient client = toOrcidClient(clientDetailsEntity);
group.getOrcidClient().add(client);
}
return group;
}
use of org.orcid.persistence.jpa.entities.EmailEntity in project ORCID-Source by ORCID.
the class RegistrationController method verifyEmail.
@RequestMapping(value = "/verify-email/{encryptedEmail}", method = RequestMethod.GET)
public ModelAndView verifyEmail(HttpServletRequest request, @PathVariable("encryptedEmail") String encryptedEmail, RedirectAttributes redirectAttributes) throws UnsupportedEncodingException {
try {
String decryptedEmail = encryptionManager.decryptForExternalUse(new String(Base64.decodeBase64(encryptedEmail), "UTF-8"));
EmailEntity emailEntity = emailManager.find(decryptedEmail);
String emailOrcid = emailEntity.getProfile().getId();
if (!getCurrentUserOrcid().equals(emailOrcid)) {
return new ModelAndView("wrong_user");
}
emailEntity.setVerified(true);
emailEntity.setCurrent(true);
emailManager.update(emailEntity);
profileEntityManager.updateLocale(emailOrcid, org.orcid.jaxb.model.common_v2.Locale.fromValue(RequestContextUtils.getLocale(request).toString()));
redirectAttributes.addFlashAttribute("emailVerified", true);
} catch (EncryptionOperationNotPossibleException eonpe) {
LOGGER.warn("Error decypting verify email from the verify email link");
redirectAttributes.addFlashAttribute("invalidVerifyUrl", true);
}
return new ModelAndView("redirect:/my-orcid");
}
Aggregations