Search in sources :

Example 96 with Name

use of org.orcid.jaxb.model.record_rc4.Name in project XobotOS by xamarin.

the class X509CRLSelector method setIssuerNames.

/**
     * <b>Do not use:</b> use {@link #setIssuers(Collection)} or one of
     * {@link #addIssuerName} instead. Sets the criterion for the issuer
     * distinguished names.
     * <p>
     * The CRL issuer must match at least one of the specified distinguished
     * names.
     * <p>
     * The specified parameter {@code names} is a collection with an entry for
     * each name to be included in the criterion. The name is specified as a
     * {@code String} or a byte array specifying the name (in RFC 2253 or ASN.1
     * DER encoded form)
     *
     * @param names
     *            the list of issuer distinguished names to match, or {@code
     *            null} if any issuer distinguished name will do.
     * @throws IOException
     *             if parsing fails.
     */
public void setIssuerNames(Collection<?> names) throws IOException {
    if (names == null) {
        issuerNames = null;
        issuerPrincipals = null;
        return;
    }
    if (names.size() == 0) {
        return;
    }
    issuerNames = new ArrayList<String>(names.size());
    for (Object name : names) {
        if (name instanceof String) {
            issuerNames.add(new Name((String) name).getName(X500Principal.CANONICAL));
        } else if (name instanceof byte[]) {
            issuerNames.add(new Name((byte[]) name).getName(X500Principal.CANONICAL));
        } else {
            throw new IOException("name neither a String nor a byte[]");
        }
    }
}
Also used : ASN1OctetString(org.apache.harmony.security.asn1.ASN1OctetString) IOException(java.io.IOException) Name(org.apache.harmony.security.x501.Name)

Example 97 with Name

use of org.orcid.jaxb.model.record_rc4.Name in project ORCID-Source by ORCID.

the class SetUpClientsAndUsers method clearRegistry.

private boolean clearRegistry(OrcidProfile existingProfile, Map<String, String> params) {
    if (existingProfile != null) {
        String orcid = params.get(ORCID);
        String email = params.get(EMAIL);
        // exception
        if (existingProfile.getOrcidBio() == null || existingProfile.getOrcidBio().getContactDetails() == null || existingProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail() == null || !email.equals(existingProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue())) {
            throw new ApplicationException("User with email " + params.get(EMAIL) + " must have orcid id '" + orcid + "' but it is '" + existingProfile.getOrcidId() + "'");
        }
        // Check if the profile have the same password, if not, update the
        // password
        String encryptedPassword = encryptionManager.hashForInternalUse(params.get(PASSWORD));
        if (!encryptedPassword.equals(existingProfile.getPassword())) {
            existingProfile.setPassword(params.get(PASSWORD));
            orcidProfileManager.updatePasswordInformation(existingProfile);
        }
        // Set default names
        Name name = new Name();
        name.setCreditName(new CreditName(params.get(CREDIT_NAME)));
        name.setGivenNames(new GivenNames(params.get(GIVEN_NAMES)));
        name.setFamilyName(new FamilyName(params.get(FAMILY_NAMES)));
        name.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility().value()));
        if (recordNameManager.exists(orcid)) {
            recordNameManager.updateRecordName(orcid, name);
        } else {
            recordNameManager.createRecordName(orcid, name);
        }
        profileDao.updatePreferences(orcid, true, true, true, true, org.orcid.jaxb.model.common_v2.Visibility.PUBLIC, true, 1f);
        // Set default bio
        org.orcid.jaxb.model.record_v2.Biography bio = biographyManager.getBiography(orcid, 0L);
        if (bio == null || bio.getContent() == null) {
            bio = new org.orcid.jaxb.model.record_v2.Biography(params.get(BIO));
            bio.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.BIOGRAPHY_DEFAULT.getVisibility().value()));
            biographyManager.createBiography(orcid, bio);
        } else {
            bio.setContent(params.get(BIO));
            bio.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.BIOGRAPHY_DEFAULT.getVisibility().value()));
            biographyManager.updateBiography(orcid, bio);
        }
        // Remove other names
        List<OtherNameEntity> otherNames = otherNameDao.getOtherNames(orcid, 0L);
        if (otherNames != null && !otherNames.isEmpty()) {
            for (OtherNameEntity otherName : otherNames) {
                otherNameDao.deleteOtherName(otherName);
            }
        }
        // Remove keywords
        List<ProfileKeywordEntity> keywords = profileKeywordDao.getProfileKeywors(orcid, 0L);
        if (keywords != null && !keywords.isEmpty()) {
            for (ProfileKeywordEntity keyword : keywords) {
                profileKeywordDao.deleteProfileKeyword(keyword);
            }
        }
        //Remove researcher urls
        List<ResearcherUrlEntity> rUrls = researcherUrlDao.getResearcherUrls(orcid, 0L);
        if (rUrls != null && !rUrls.isEmpty()) {
            for (ResearcherUrlEntity rUrl : rUrls) {
                researcherUrlDao.deleteResearcherUrl(orcid, rUrl.getId());
            }
        }
        // Remove external ids
        List<ExternalIdentifierEntity> extIds = externalIdentifierDao.getExternalIdentifiers(orcid, System.currentTimeMillis());
        if (extIds != null && !extIds.isEmpty()) {
            for (ExternalIdentifierEntity extId : extIds) {
                externalIdentifierDao.removeExternalIdentifier(orcid, extId.getId());
            }
        }
        // Remove addresses
        List<AddressEntity> addresses = addressDao.getAddresses(orcid, 0L);
        if (addresses != null && !addresses.isEmpty()) {
            for (AddressEntity address : addresses) {
                addressDao.deleteAddress(orcid, address.getId());
            }
        }
        // Remove emails
        List<EmailEntity> emails = emailDao.findByOrcid(orcid);
        if (emails != null && !emails.isEmpty()) {
            for (EmailEntity rc2Email : emails) {
                if (!params.get(EMAIL).equals(rc2Email.getId())) {
                    emailDao.removeEmail(orcid, rc2Email.getId());
                }
            }
        }
        // Remove notifications
        List<NotificationEntity> notifications = notificationDao.findByOrcid(orcid, true, 0, 10000);
        if (notifications != null && !notifications.isEmpty()) {
            for (NotificationEntity notification : notifications) {
                notificationDao.deleteNotificationItemByNotificationId(notification.getId());
                notificationDao.deleteNotificationWorkByNotificationId(notification.getId());
                notificationDao.deleteNotificationById(notification.getId());
            }
        }
        // Remove works
        List<MinimizedWorkEntity> works = workDao.findWorks(orcid, 0L);
        if (works != null && !works.isEmpty()) {
            for (MinimizedWorkEntity work : works) {
                workDao.removeWork(orcid, work.getId());
            }
        }
        // Remove affiliations
        List<OrgAffiliationRelationEntity> affiliations = orgAffiliationRelationDao.getByUser(orcid);
        if (affiliations != null && !affiliations.isEmpty()) {
            for (OrgAffiliationRelationEntity affiliation : affiliations) {
                orgAffiliationRelationDao.remove(affiliation.getId());
            }
        }
        // Remove fundings
        List<ProfileFundingEntity> fundings = profileFundingDao.getByUser(orcid);
        if (fundings != null && !fundings.isEmpty()) {
            for (ProfileFundingEntity funding : fundings) {
                profileFundingDao.removeProfileFunding(orcid, funding.getId());
            }
        }
        // Remove peer reviews
        List<PeerReviewEntity> peerReviews = peerReviewDao.getByUser(orcid);
        if (peerReviews != null && !peerReviews.isEmpty()) {
            for (PeerReviewEntity peerReview : peerReviews) {
                peerReviewDao.removePeerReview(orcid, peerReview.getId());
            }
        }
        // Remove 3d party links
        List<OrcidOauth2TokenDetail> tokenDetails = orcidOauth2TokenDetailDao.findByUserName(orcid);
        if (tokenDetails != null && !tokenDetails.isEmpty()) {
            for (OrcidOauth2TokenDetail token : tokenDetails) {
                orcidOauth2TokenDetailDao.remove(token.getId());
            }
        }
        //Unlock just in case it is locked
        profileDao.unlockProfile(orcid);
        return true;
    }
    return false;
}
Also used : ProfileKeywordEntity(org.orcid.persistence.jpa.entities.ProfileKeywordEntity) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) ExternalIdentifierEntity(org.orcid.persistence.jpa.entities.ExternalIdentifierEntity) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) CreditName(org.orcid.jaxb.model.common_v2.CreditName) Name(org.orcid.jaxb.model.record_v2.Name) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) GivenNames(org.orcid.jaxb.model.record_v2.GivenNames) MinimizedWorkEntity(org.orcid.persistence.jpa.entities.MinimizedWorkEntity) PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) NotificationEntity(org.orcid.persistence.jpa.entities.NotificationEntity) AddressEntity(org.orcid.persistence.jpa.entities.AddressEntity) OrcidOauth2TokenDetail(org.orcid.persistence.jpa.entities.OrcidOauth2TokenDetail) ResearcherUrlEntity(org.orcid.persistence.jpa.entities.ResearcherUrlEntity) CreditName(org.orcid.jaxb.model.common_v2.CreditName) EmailEntity(org.orcid.persistence.jpa.entities.EmailEntity) ApplicationException(org.orcid.core.exception.ApplicationException) OtherNameEntity(org.orcid.persistence.jpa.entities.OtherNameEntity) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)

Example 98 with Name

use of org.orcid.jaxb.model.record_rc4.Name in project ORCID-Source by ORCID.

the class ManageProfileController method getNameForm.

@RequestMapping(value = "/nameForm.json", method = RequestMethod.GET)
@ResponseBody
public NamesForm getNameForm() throws NoSuchRequestHandlingMethodException {
    String currentOrcid = getCurrentUserOrcid();
    Name name = recordNameManager.getRecordName(currentOrcid, profileEntityManager.getLastModified(currentOrcid));
    return NamesForm.valueOf(name);
}
Also used : Name(org.orcid.jaxb.model.record_v2.Name) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 99 with Name

use of org.orcid.jaxb.model.record_rc4.Name in project ORCID-Source by ORCID.

the class OrcidSecurityManager_generalTest method testName_ThrowException_When_TokenIsForOtherUser.

@Test(expected = OrcidUnauthorizedException.class)
public void testName_ThrowException_When_TokenIsForOtherUser() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_UPDATE);
    Name name = createName(Visibility.PUBLIC);
    orcidSecurityManager.checkAndFilter(ORCID_2, name, ScopePathType.ORCID_BIO_READ_LIMITED);
    fail();
}
Also used : OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Test(org.junit.Test)

Example 100 with Name

use of org.orcid.jaxb.model.record_rc4.Name in project ORCID-Source by ORCID.

the class OrcidSecurityManager_generalTest method testPersonalDetails_When_AllPrivate_NoSource_ReadLimitedToken.

@Test
public void testPersonalDetails_When_AllPrivate_NoSource_ReadLimitedToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_READ_LIMITED);
    Name name = createName(Visibility.PRIVATE);
    Biography bio = createBiography(Visibility.PRIVATE);
    OtherName o1 = createOtherName(Visibility.PRIVATE, CLIENT_2);
    OtherName o2 = createOtherName(Visibility.PRIVATE, CLIENT_2);
    OtherName o3 = createOtherName(Visibility.PRIVATE, CLIENT_2);
    OtherNames otherNames = new OtherNames();
    otherNames.setOtherNames(new ArrayList<OtherName>(Arrays.asList(o1, o2, o3)));
    PersonalDetails p = new PersonalDetails();
    p.setBiography(bio);
    p.setName(name);
    p.setOtherNames(otherNames);
    orcidSecurityManager.checkAndFilter(ORCID_1, p);
    assertNotNull(p);
    assertNull(p.getName());
    assertNull(p.getBiography());
    assertNotNull(p.getOtherNames());
    assertNotNull(p.getOtherNames().getOtherNames());
    assertTrue(p.getOtherNames().getOtherNames().isEmpty());
}
Also used : OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) Biography(org.orcid.jaxb.model.record_v2.Biography) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)92 Name (org.orcid.jaxb.model.record_v2.Name)75 OtherName (org.orcid.jaxb.model.record_v2.OtherName)61 Biography (org.orcid.jaxb.model.record_v2.Biography)45 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)40 Address (org.orcid.jaxb.model.record_v2.Address)30 Email (org.orcid.jaxb.model.record_v2.Email)30 Emails (org.orcid.jaxb.model.record_v2.Emails)29 Keyword (org.orcid.jaxb.model.record_v2.Keyword)29 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)29 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)29 Addresses (org.orcid.jaxb.model.record_v2.Addresses)28 Keywords (org.orcid.jaxb.model.record_v2.Keywords)28 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)28 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)28 Person (org.orcid.jaxb.model.record_v2.Person)26 ClientResponse (com.sun.jersey.api.client.ClientResponse)17 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)17 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)17 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)17