Search in sources :

Example 36 with OtherName

use of de.carne.certmgr.certs.x509.OtherName in project ORCID-Source by ORCID.

the class ValidateV2RC3SamplesTest method testUnmarshallPerson.

@Test
public void testUnmarshallPerson() throws SAXException, URISyntaxException {
    Person person = (Person) unmarshallFromPath("/record_2.0_rc3/samples/person-2.0_rc3.xml", Person.class, "/record_2.0_rc3/person-2.0_rc3.xsd");
    assertNotNull(person);
    assertNotNull(person.getName());
    assertEquals("give-names", person.getName().getGivenNames().getContent());
    assertEquals("family-name", person.getName().getFamilyName().getContent());
    assertEquals("credit-name", person.getName().getCreditName().getContent());
    assertEquals(Visibility.PUBLIC, person.getName().getVisibility());
    assertNotNull(person.getOtherNames());
    assertNotNull(person.getOtherNames().getOtherNames());
    assertEquals(1, person.getOtherNames().getOtherNames().size());
    OtherName otherName = person.getOtherNames().getOtherNames().get(0);
    assertEquals("other-name-1", otherName.getContent());
    assertNotNull(otherName.getCreatedDate());
    assertNotNull(otherName.getCreatedDate().getValue());
    assertEquals(2001, otherName.getCreatedDate().getValue().getYear());
    assertEquals(12, otherName.getCreatedDate().getValue().getMonth());
    assertEquals(31, otherName.getCreatedDate().getValue().getDay());
    assertNotNull(otherName.getLastModifiedDate().getValue());
    assertEquals(2001, otherName.getLastModifiedDate().getValue().getYear());
    assertEquals(12, otherName.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, otherName.getLastModifiedDate().getValue().getDay());
    assertNotNull(otherName.getSource());
    assertEquals("8888-8888-8888-8880", otherName.getSource().retrieveSourcePath());
    assertNotNull(person.getBiography());
    assertEquals(Visibility.PUBLIC, person.getBiography().getVisibility());
    assertEquals("biography", person.getBiography().getContent());
    assertNotNull(person.getResearcherUrls());
    assertNotNull(person.getResearcherUrls().getResearcherUrls());
    assertEquals(1, person.getResearcherUrls().getResearcherUrls().size());
    ResearcherUrl rUrl = person.getResearcherUrls().getResearcherUrls().get(0);
    assertEquals(Visibility.PUBLIC, rUrl.getVisibility());
    assertEquals(Long.valueOf(1248), rUrl.getPutCode());
    assertEquals("url-name-1", rUrl.getUrlName());
    assertNotNull(rUrl.getUrl());
    assertEquals("http://url.com/", rUrl.getUrl().getValue());
    assertNotNull(rUrl.getCreatedDate());
    assertEquals(2001, rUrl.getCreatedDate().getValue().getYear());
    assertEquals(12, rUrl.getCreatedDate().getValue().getMonth());
    assertEquals(31, rUrl.getCreatedDate().getValue().getDay());
    assertNotNull(rUrl.getLastModifiedDate());
    assertEquals(2001, rUrl.getLastModifiedDate().getValue().getYear());
    assertEquals(12, rUrl.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, rUrl.getLastModifiedDate().getValue().getDay());
    assertNotNull(rUrl.getSource());
    assertEquals("8888-8888-8888-8880", rUrl.getSource().retrieveSourcePath());
    assertNotNull(person.getEmails());
    assertNotNull(person.getEmails().getEmails());
    assertEquals(1, person.getEmails().getEmails().size());
    Email email = person.getEmails().getEmails().get(0);
    assertEquals(Visibility.PUBLIC, email.getVisibility());
    assertEquals("user1@email.com", email.getEmail());
    assertNotNull(email.getCreatedDate());
    assertNotNull(email.getCreatedDate().getValue());
    assertEquals(2001, email.getCreatedDate().getValue().getYear());
    assertEquals(12, email.getCreatedDate().getValue().getMonth());
    assertEquals(31, email.getCreatedDate().getValue().getDay());
    assertNotNull(email.getLastModifiedDate());
    assertNotNull(email.getLastModifiedDate().getValue());
    assertEquals(2001, email.getLastModifiedDate().getValue().getYear());
    assertEquals(12, email.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, email.getLastModifiedDate().getValue().getDay());
    assertNotNull(email.getSource());
    assertEquals("8888-8888-8888-8880", email.retrieveSourcePath());
    assertNotNull(person.getAddresses());
    assertNotNull(person.getAddresses().getAddress());
    assertEquals(1, person.getAddresses().getAddress().size());
    Address address = person.getAddresses().getAddress().get(0);
    assertEquals(Visibility.PUBLIC, address.getVisibility());
    assertEquals(Long.valueOf(1), address.getPutCode());
    assertNotNull(address.getCountry());
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertNotNull(address.getCreatedDate());
    assertNotNull(address.getCreatedDate().getValue());
    assertEquals(2001, address.getCreatedDate().getValue().getYear());
    assertEquals(12, address.getCreatedDate().getValue().getMonth());
    assertEquals(31, address.getCreatedDate().getValue().getDay());
    assertNotNull(address.getLastModifiedDate());
    assertNotNull(address.getLastModifiedDate().getValue());
    assertEquals(2001, address.getLastModifiedDate().getValue().getYear());
    assertEquals(12, address.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, address.getLastModifiedDate().getValue().getDay());
    assertNotNull(address.getSource());
    assertEquals("8888-8888-8888-8880", address.getSource().retrieveSourcePath());
    assertNotNull(person.getKeywords());
    assertNotNull(person.getKeywords().getKeywords());
    assertEquals(1, person.getKeywords().getKeywords().size());
    Keyword keyword = person.getKeywords().getKeywords().get(0);
    assertEquals(Visibility.PUBLIC, keyword.getVisibility());
    assertEquals(Long.valueOf(1), keyword.getPutCode());
    assertEquals("keyword1", keyword.getContent());
    assertNotNull(keyword.getCreatedDate());
    assertNotNull(keyword.getCreatedDate().getValue());
    assertEquals(2001, keyword.getCreatedDate().getValue().getYear());
    assertEquals(12, keyword.getCreatedDate().getValue().getMonth());
    assertEquals(31, keyword.getCreatedDate().getValue().getDay());
    assertNotNull(keyword.getLastModifiedDate());
    assertNotNull(keyword.getLastModifiedDate().getValue());
    assertEquals(2001, keyword.getLastModifiedDate().getValue().getYear());
    assertEquals(12, keyword.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, keyword.getLastModifiedDate().getValue().getDay());
    assertNotNull(keyword.getSource());
    assertEquals("8888-8888-8888-8880", keyword.getSource().retrieveSourcePath());
    assertNotNull(person.getExternalIdentifiers());
    assertNotNull(person.getExternalIdentifiers().getExternalIdentifiers());
    assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
    PersonExternalIdentifier extId = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
    assertEquals(Visibility.PUBLIC, extId.getVisibility());
    assertEquals(Long.valueOf(1), extId.getPutCode());
    assertEquals("type-1", extId.getType());
    assertEquals("value-1", extId.getValue());
    assertNotNull(extId.getUrl());
    assertEquals("http://url.com/1", extId.getUrl().getValue());
    assertNotNull(extId.getCreatedDate());
    assertNotNull(extId.getCreatedDate().getValue());
    assertEquals(2001, extId.getCreatedDate().getValue().getYear());
    assertEquals(12, extId.getCreatedDate().getValue().getMonth());
    assertEquals(31, extId.getCreatedDate().getValue().getDay());
    assertNotNull(extId.getLastModifiedDate());
    assertNotNull(extId.getLastModifiedDate().getValue());
    assertEquals(2001, extId.getLastModifiedDate().getValue().getYear());
    assertEquals(12, extId.getLastModifiedDate().getValue().getMonth());
    assertEquals(31, extId.getLastModifiedDate().getValue().getDay());
    assertNotNull(extId.getSource());
    assertEquals("8888-8888-8888-8880", extId.getSource().retrieveSourcePath());
}
Also used : Email(org.orcid.jaxb.model.record_rc3.Email) Address(org.orcid.jaxb.model.record_rc3.Address) Keyword(org.orcid.jaxb.model.record_rc3.Keyword) OtherName(org.orcid.jaxb.model.record_rc3.OtherName) ResearcherUrl(org.orcid.jaxb.model.record_rc3.ResearcherUrl) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc3.PersonExternalIdentifier) Person(org.orcid.jaxb.model.record_rc3.Person) Test(org.junit.Test)

Example 37 with OtherName

use of de.carne.certmgr.certs.x509.OtherName in project ORCID-Source by ORCID.

the class ValidateV2RC3SamplesTest method testUnmarshallOtherNames.

@Test
public void testUnmarshallOtherNames() throws SAXException, URISyntaxException {
    OtherNames otherNames = (OtherNames) unmarshallFromPath("/record_2.0_rc3/samples/other-names-2.0_rc3.xml", OtherNames.class, "/record_2.0_rc3/personal-details-2.0_rc3.xsd");
    assertNotNull(otherNames);
    assertNotNull(otherNames.getOtherNames());
    assertEquals(2, otherNames.getOtherNames().size());
    for (OtherName otherName : otherNames.getOtherNames()) {
        assertThat(otherName.getContent(), anyOf(is("Other Name #1"), is("Other Name #2")));
        assertThat(otherName.getPutCode(), anyOf(is(1L), is(2L)));
        assertEquals(Visibility.PUBLIC.value(), otherName.getVisibility().value());
        assertNotNull(otherName.getCreatedDate());
        assertNotNull(otherName.getLastModifiedDate());
        assertNotNull(otherName.getSource());
        assertEquals("8888-8888-8888-8880", otherName.getSource().retrieveSourcePath());
    }
    OtherName otherName = (OtherName) unmarshallFromPath("/record_2.0_rc3/samples/other-name-2.0_rc3.xml", OtherName.class);
    assertNotNull(otherName);
    assertEquals("Other Name #1", otherName.getContent());
    assertEquals(Long.valueOf(1), otherName.getPutCode());
    assertEquals(Visibility.PUBLIC.value(), otherName.getVisibility().value());
    assertNotNull(otherName.getCreatedDate());
    assertNotNull(otherName.getLastModifiedDate());
    assertNotNull(otherName.getSource());
    assertEquals("8888-8888-8888-8880", otherName.getSource().retrieveSourcePath());
}
Also used : OtherNames(org.orcid.jaxb.model.record_rc3.OtherNames) OtherName(org.orcid.jaxb.model.record_rc3.OtherName) Test(org.junit.Test)

Example 38 with OtherName

use of de.carne.certmgr.certs.x509.OtherName in project OpenAM by OpenRock.

the class Cert method getTokenFromSubjectAltExt.

private void getTokenFromSubjectAltExt(X509Certificate cert) throws AuthLoginException {
    try {
        X509CertImpl certImpl = new X509CertImpl(cert.getEncoded());
        X509CertInfo cinfo = new X509CertInfo(certImpl.getTBSCertificate());
        CertificateExtensions exts = (CertificateExtensions) cinfo.get(X509CertInfo.EXTENSIONS);
        SubjectAlternativeNameExtension altNameExt = (SubjectAlternativeNameExtension) exts.get(SubjectAlternativeNameExtension.NAME);
        if (altNameExt != null) {
            GeneralNames names = (GeneralNames) altNameExt.get(SubjectAlternativeNameExtension.SUBJECT_NAME);
            GeneralName generalname = null;
            ObjectIdentifier upnoid = new ObjectIdentifier(UPNOID);
            Iterator itr = (Iterator) names.iterator();
            while ((userTokenId == null) && itr.hasNext()) {
                generalname = (GeneralName) itr.next();
                if (generalname != null) {
                    if (amAuthCert_subjectAltExtMapper.equalsIgnoreCase("UPN") && (generalname.getType() == GeneralNameInterface.NAME_ANY)) {
                        OtherName othername = (OtherName) generalname.getName();
                        if (upnoid.equals((Object) (othername.getOID()))) {
                            byte[] nval = othername.getNameValue();
                            DerValue derValue = new DerValue(nval);
                            userTokenId = derValue.getData().getUTF8String();
                        }
                    } else if (amAuthCert_subjectAltExtMapper.equalsIgnoreCase("RFC822Name") && (generalname.getType() == GeneralNameInterface.NAME_RFC822)) {
                        RFC822Name email = (RFC822Name) generalname.getName();
                        userTokenId = email.getName();
                    }
                }
            }
        }
    } catch (Exception e) {
        debug.error("Certificate - " + "Error in getTokenFromSubjectAltExt = ", e);
        throw new AuthLoginException(amAuthCert, "CertNoReg", null);
    }
}
Also used : X509CertInfo(sun.security.x509.X509CertInfo) SubjectAlternativeNameExtension(sun.security.x509.SubjectAlternativeNameExtension) OtherName(sun.security.x509.OtherName) AuthLoginException(com.sun.identity.authentication.spi.AuthLoginException) CertificateExtensions(sun.security.x509.CertificateExtensions) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) AuthLoginException(com.sun.identity.authentication.spi.AuthLoginException) GeneralNames(sun.security.x509.GeneralNames) RFC822Name(sun.security.x509.RFC822Name) X509CertImpl(sun.security.x509.X509CertImpl) DerValue(sun.security.util.DerValue) Iterator(java.util.Iterator) GeneralName(sun.security.x509.GeneralName) ObjectIdentifier(sun.security.util.ObjectIdentifier)

Example 39 with OtherName

use of de.carne.certmgr.certs.x509.OtherName in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_PersonalDetailsTest method testReadPublicScope_PersonalDetails.

@Test
public void testReadPublicScope_PersonalDetails() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewPersonalDetails(ORCID);
    assertNotNull(r);
    assertEquals(PersonalDetails.class.getName(), r.getEntity().getClass().getName());
    PersonalDetails p = (PersonalDetails) r.getEntity();
    assertEquals("/0000-0000-0000-0003/personal-details", p.getPath());
    Utils.verifyLastModified(p.getLastModifiedDate());
    Utils.verifyLastModified(p.getBiography().getLastModifiedDate());
    Utils.verifyLastModified(p.getName().getLastModifiedDate());
    Utils.verifyLastModified(p.getOtherNames().getLastModifiedDate());
    assertEquals("Biography for 0000-0000-0000-0003", p.getBiography().getContent());
    assertEquals("Credit Name", p.getName().getCreditName().getContent());
    assertEquals("Given Names", p.getName().getGivenNames().getContent());
    assertEquals("Family Name", p.getName().getFamilyName().getContent());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    boolean found13 = false, found14 = false, found15 = false;
    for (OtherName element : p.getOtherNames().getOtherNames()) {
        if (element.getPutCode() == 13) {
            found13 = true;
        } else if (element.getPutCode() == 14) {
            found14 = true;
        } else if (element.getPutCode() == 15) {
            found15 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found13);
    assertTrue(found14);
    assertTrue(found15);
    String otherOrcid = "0000-0000-0000-0002";
    SecurityContextTestUtils.setUpSecurityContext(otherOrcid, ScopePathType.READ_PUBLIC);
    r = serviceDelegator.viewPersonalDetails(otherOrcid);
    assertNotNull(r);
    assertEquals(PersonalDetails.class.getName(), r.getEntity().getClass().getName());
    p = (PersonalDetails) r.getEntity();
    assertNull(p.getBiography());
    assertNull(p.getName());
    assertNotNull(p.getOtherNames());
    assertTrue(p.getOtherNames().getOtherNames().isEmpty());
}
Also used : Response(javax.ws.rs.core.Response) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 40 with OtherName

use of de.carne.certmgr.certs.x509.OtherName in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_PersonalDetailsTest method testViewPersonalDetails.

@Test
public void testViewPersonalDetails() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewPersonalDetails(ORCID);
    assertNotNull(response);
    PersonalDetails personalDetails = (PersonalDetails) response.getEntity();
    assertNotNull(personalDetails);
    assertEquals("/0000-0000-0000-0003/personal-details", personalDetails.getPath());
    Utils.verifyLastModified(personalDetails.getLastModifiedDate());
    assertNotNull(personalDetails.getBiography());
    Utils.verifyLastModified(personalDetails.getBiography().getLastModifiedDate());
    assertEquals("Biography for 0000-0000-0000-0003", personalDetails.getBiography().getContent());
    assertEquals(Visibility.PUBLIC.value(), personalDetails.getBiography().getVisibility().value());
    assertEquals("/0000-0000-0000-0003/biography", personalDetails.getBiography().getPath());
    assertNotNull(personalDetails.getName());
    Utils.verifyLastModified(personalDetails.getName().getLastModifiedDate());
    assertNotNull(personalDetails.getName().getCreatedDate().getValue());
    assertEquals("Credit Name", personalDetails.getName().getCreditName().getContent());
    assertEquals("Family Name", personalDetails.getName().getFamilyName().getContent());
    assertEquals("Given Names", personalDetails.getName().getGivenNames().getContent());
    assertEquals(Visibility.PUBLIC.value(), personalDetails.getName().getVisibility().value());
    assertNotNull(personalDetails.getOtherNames());
    Utils.verifyLastModified(personalDetails.getOtherNames().getLastModifiedDate());
    assertEquals(4, personalDetails.getOtherNames().getOtherNames().size());
    for (OtherName otherName : personalDetails.getOtherNames().getOtherNames()) {
        Utils.verifyLastModified(otherName.getLastModifiedDate());
        if (otherName.getPutCode().equals(Long.valueOf(13))) {
            assertEquals("Other Name PUBLIC", otherName.getContent());
            assertEquals(Long.valueOf(0), otherName.getDisplayIndex());
            assertEquals("/0000-0000-0000-0003/other-names/13", otherName.getPath());
            assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
            assertEquals(Visibility.PUBLIC.value(), otherName.getVisibility().value());
        } else if (otherName.getPutCode().equals(Long.valueOf(14))) {
            assertEquals("Other Name LIMITED", otherName.getContent());
            assertEquals(Long.valueOf(1), otherName.getDisplayIndex());
            assertEquals("/0000-0000-0000-0003/other-names/14", otherName.getPath());
            assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
            assertEquals(Visibility.LIMITED.value(), otherName.getVisibility().value());
        } else if (otherName.getPutCode().equals(Long.valueOf(15))) {
            assertEquals("Other Name PRIVATE", otherName.getContent());
            assertEquals(Long.valueOf(2), otherName.getDisplayIndex());
            assertEquals("/0000-0000-0000-0003/other-names/15", otherName.getPath());
            assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
            assertEquals(Visibility.PRIVATE.value(), otherName.getVisibility().value());
        } else if (otherName.getPutCode().equals(Long.valueOf(16))) {
            assertEquals("Other Name SELF LIMITED", otherName.getContent());
            assertEquals(Long.valueOf(3), otherName.getDisplayIndex());
            assertEquals("/0000-0000-0000-0003/other-names/16", otherName.getPath());
            assertEquals("0000-0000-0000-0003", otherName.getSource().retrieveSourcePath());
            assertEquals(Visibility.LIMITED.value(), otherName.getVisibility().value());
        } else {
            fail("Invalid put code found: " + otherName.getPutCode());
        }
    }
    assertEquals("/0000-0000-0000-0003/other-names", personalDetails.getOtherNames().getPath());
    assertEquals("/0000-0000-0000-0003/personal-details", personalDetails.getPath());
}
Also used : Response(javax.ws.rs.core.Response) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

OtherName (org.orcid.jaxb.model.record_v2.OtherName)110 Test (org.junit.Test)98 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)55 Biography (org.orcid.jaxb.model.record_v2.Biography)44 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)44 Name (org.orcid.jaxb.model.record_v2.Name)43 Address (org.orcid.jaxb.model.record_v2.Address)42 Keyword (org.orcid.jaxb.model.record_v2.Keyword)40 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)40 Email (org.orcid.jaxb.model.record_v2.Email)38 Addresses (org.orcid.jaxb.model.record_v2.Addresses)33 Emails (org.orcid.jaxb.model.record_v2.Emails)33 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)33 Keywords (org.orcid.jaxb.model.record_v2.Keywords)32 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)32 Person (org.orcid.jaxb.model.record_v2.Person)31 ArrayList (java.util.ArrayList)21 Response (javax.ws.rs.core.Response)20 DBUnitTest (org.orcid.test.DBUnitTest)20 Record (org.orcid.jaxb.model.record_v2.Record)19