use of ru.CryptoPro.JCP.ASN.PKIX1Explicit88.Name in project ORCID-Source by ORCID.
the class OrcidSecurityManager_generalTest method testName_CanRead_When_HaveReadScope_IsLimited.
@Test
public void testName_CanRead_When_HaveReadScope_IsLimited() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_READ_LIMITED);
Name name = createName(Visibility.LIMITED);
orcidSecurityManager.checkAndFilter(ORCID_1, name, ScopePathType.ORCID_BIO_READ_LIMITED);
}
use of ru.CryptoPro.JCP.ASN.PKIX1Explicit88.Name in project ORCID-Source by ORCID.
the class ValidateV2RC4SamplesTest method testUnmarshallName.
@Test
public void testUnmarshallName() throws SAXException, URISyntaxException {
Name name = (Name) unmarshallFromPath("/record_2.0_rc4/samples/name-2.0_rc4.xml", Name.class, "/record_2.0_rc4/personal-details-2.0_rc4.xsd");
assertNotNull(name);
assertNotNull(name.getCreditName());
assertEquals("credit-name", name.getCreditName().getContent());
assertNotNull(name.getFamilyName());
assertEquals("family-name", name.getFamilyName().getContent());
assertNotNull(name.getGivenNames());
assertEquals("given-names", name.getGivenNames().getContent());
assertNotNull(name.getVisibility());
assertEquals(Visibility.PUBLIC, name.getVisibility());
}
use of ru.CryptoPro.JCP.ASN.PKIX1Explicit88.Name in project ORCID-Source by ORCID.
the class ValidateV2SamplesTest method testUnmarshallName.
@Test
public void testUnmarshallName() throws SAXException, URISyntaxException {
Name name = (Name) unmarshallFromPath("/record_2.0/samples/read_samples/name-2.0.xml", Name.class, "/record_2.0/personal-details-2.0.xsd");
assertNotNull(name);
assertNotNull(name.getCreditName());
assertEquals("credit-name", name.getCreditName().getContent());
assertNotNull(name.getFamilyName());
assertEquals("family-name", name.getFamilyName().getContent());
assertNotNull(name.getGivenNames());
assertEquals("given-names", name.getGivenNames().getContent());
assertNotNull(name.getVisibility());
assertEquals(Visibility.PUBLIC, name.getVisibility());
}
use of ru.CryptoPro.JCP.ASN.PKIX1Explicit88.Name in project ORCID-Source by ORCID.
the class ProfileEntityManagerImpl method deprecateProfile.
/**
* Deprecates a profile
*
* @param deprecatedProfile
* The profile that want to be deprecated
* @param primaryProfile
* The primary profile for the deprecated profile
* @return true if the account was successfully deprecated, false otherwise
*/
@Override
@Transactional
public boolean deprecateProfile(String deprecatedOrcid, String primaryOrcid) {
boolean wasDeprecated = profileDao.deprecateProfile(deprecatedOrcid, primaryOrcid);
// If it was successfully deprecated
if (wasDeprecated) {
LOGGER.info("Account {} was deprecated to primary account: {}", deprecatedOrcid, primaryOrcid);
ProfileEntity deprecated = profileDao.find(deprecatedOrcid);
// Remove works
workManager.removeAllWorks(deprecatedOrcid);
// Remove funding
if (deprecated.getProfileFunding() != null) {
for (ProfileFundingEntity funding : deprecated.getProfileFunding()) {
fundingManager.removeProfileFunding(funding.getProfile().getId(), funding.getId());
}
}
// Remove affiliations
if (deprecated.getOrgAffiliationRelations() != null) {
for (OrgAffiliationRelationEntity affiliation : deprecated.getOrgAffiliationRelations()) {
orgAffiliationRelationDao.removeOrgAffiliationRelation(affiliation.getProfile().getId(), affiliation.getId());
}
}
// Remove external identifiers
if (deprecated.getExternalIdentifiers() != null) {
for (ExternalIdentifierEntity externalIdentifier : deprecated.getExternalIdentifiers()) {
externalIdentifierManager.deleteExternalIdentifier(deprecated.getId(), externalIdentifier.getId(), false);
}
}
// Remove researcher urls
if (deprecated.getResearcherUrls() != null) {
for (ResearcherUrlEntity rUrl : deprecated.getResearcherUrls()) {
researcherUrlManager.deleteResearcherUrl(deprecatedOrcid, rUrl.getId(), false);
}
}
// Remove other names
if (deprecated.getOtherNames() != null) {
for (OtherNameEntity otherName : deprecated.getOtherNames()) {
otherNamesManager.deleteOtherName(deprecatedOrcid, otherName.getId(), false);
}
}
// Remove keywords
if (deprecated.getKeywords() != null) {
for (ProfileKeywordEntity keyword : deprecated.getKeywords()) {
profileKeywordManager.deleteKeyword(deprecatedOrcid, keyword.getId(), false);
}
}
//Remove biography
if (biographyManager.exists(deprecatedOrcid)) {
Biography deprecatedBio = new Biography();
deprecatedBio.setContent(null);
deprecatedBio.setVisibility(Visibility.PRIVATE);
biographyManager.updateBiography(deprecatedOrcid, deprecatedBio);
}
//Set the deactivated names
if (recordNameManager.exists(deprecatedOrcid)) {
Name name = new Name();
name.setCreditName(new CreditName());
name.setGivenNames(new GivenNames("Given Names Deactivated"));
name.setFamilyName(new FamilyName("Family Name Deactivated"));
name.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
name.setPath(deprecatedOrcid);
recordNameManager.updateRecordName(deprecatedOrcid, name);
}
userConnectionDao.deleteByOrcid(deprecatedOrcid);
// Move all emails to the primary email
Set<EmailEntity> deprecatedAccountEmails = deprecated.getEmails();
if (deprecatedAccountEmails != null) {
// For each email in the deprecated profile
for (EmailEntity email : deprecatedAccountEmails) {
// Delete each email from the deprecated
// profile
LOGGER.info("About to move email {} from profile {} to profile {}", new Object[] { email.getId(), deprecatedOrcid, primaryOrcid });
emailManager.moveEmailToOtherAccount(email.getId(), deprecatedOrcid, primaryOrcid);
}
}
return true;
}
return false;
}
use of ru.CryptoPro.JCP.ASN.PKIX1Explicit88.Name in project ORCID-Source by ORCID.
the class OrcidSecurityManager_generalTest method testName_CanRead_When_DontHaveReadScope_IsPublic.
@Test
public void testName_CanRead_When_DontHaveReadScope_IsPublic() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_UPDATE);
Name name = createName(Visibility.PUBLIC);
orcidSecurityManager.checkAndFilter(ORCID_1, name, ScopePathType.ORCID_BIO_READ_LIMITED);
}
Aggregations