Search in sources :

Example 26 with Person

use of org.orcid.jaxb.model.record_v2.Person in project ORCID-Source by ORCID.

the class ValidateV2SamplesTest method testUnmarshallExternalIdentifiers.

@Test
public void testUnmarshallExternalIdentifiers() throws SAXException, URISyntaxException {
    PersonExternalIdentifiers externalIdentifiers = (PersonExternalIdentifiers) unmarshallFromPath("/record_2.0/samples/read_samples/external-identifiers-2.0.xml", PersonExternalIdentifiers.class, "/record_2.0/person-external-identifier-2.0.xsd");
    assertNotNull(externalIdentifiers);
    assertNotNull(externalIdentifiers.getExternalIdentifiers());
    assertEquals(2, externalIdentifiers.getExternalIdentifiers().size());
    for (PersonExternalIdentifier extId : externalIdentifiers.getExternalIdentifiers()) {
        assertThat(extId.getPutCode(), anyOf(is(1L), is(2L)));
        assertThat(extId.getType(), anyOf(is("common-name-1"), is("common-name-2")));
        assertThat(extId.getValue(), anyOf(is("id-reference-1"), is("id-reference-2")));
        assertNotNull(extId.getUrl());
        assertThat(extId.getUrl().getValue(), anyOf(is("http://url/1"), is("http://url/2")));
        assertNotNull(extId.getCreatedDate());
        assertNotNull(extId.getLastModifiedDate());
        assertNotNull(extId.getSource());
        assertEquals("8888-8888-8888-8880", extId.getSource().retrieveSourcePath());
    }
    PersonExternalIdentifier extId = (PersonExternalIdentifier) unmarshallFromPath("/record_2.0/samples/read_samples/external-identifier-2.0.xml", PersonExternalIdentifier.class);
    assertNotNull(extId);
    assertEquals("A-0003", extId.getType());
    assertEquals(Long.valueOf(1), extId.getPutCode());
    assertEquals("A-0003", extId.getValue());
    assertNotNull(extId.getUrl());
    assertEquals("http://ext-id/A-0003", extId.getUrl().getValue());
    assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
    assertNotNull(extId.getCreatedDate());
    assertNotNull(extId.getLastModifiedDate());
    assertNotNull(extId.getSource());
    assertEquals("8888-8888-8888-8880", extId.getSource().retrieveSourcePath());
}
Also used : PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Test(org.junit.Test)

Example 27 with Person

use of org.orcid.jaxb.model.record_v2.Person in project ORCID-Source by ORCID.

the class ValidateV2RC4SamplesTest method testMarshallPerson.

@Test
public void testMarshallPerson() throws JAXBException, SAXException, URISyntaxException {
    Person object = (Person) unmarshallFromPath("/record_2.0_rc4/samples/person-2.0_rc4.xml", Person.class);
    marshall(object, "/record_2.0_rc4/person-2.0_rc4.xsd");
}
Also used : Person(org.orcid.jaxb.model.record_rc4.Person) Test(org.junit.Test)

Example 28 with Person

use of org.orcid.jaxb.model.record_v2.Person in project ORCID-Source by ORCID.

the class ValidateV2_1SamplesTest method testMarshallPerson.

@Test
public void testMarshallPerson() throws JAXBException, SAXException, URISyntaxException {
    Person object = (Person) unmarshallFromPath("/record_2.1/samples/read_samples/person-2.1.xml", Person.class);
    marshall(object, "/record_2.1/person-2.1.xsd");
}
Also used : Person(org.orcid.jaxb.model.record_v2.Person) Test(org.junit.Test)

Example 29 with Person

use of org.orcid.jaxb.model.record_v2.Person in project ORCID-Source by ORCID.

the class ValidateV2SamplesTest method testMarshallPerson.

@Test
public void testMarshallPerson() throws JAXBException, SAXException, URISyntaxException {
    Person object = (Person) unmarshallFromPath("/record_2.0/samples/read_samples/person-2.0.xml", Person.class);
    marshall(object, "/record_2.0/person-2.0.xsd");
}
Also used : Person(org.orcid.jaxb.model.record_v2.Person) Test(org.junit.Test)

Example 30 with Person

use of org.orcid.jaxb.model.record_v2.Person in project ORCID-Source by ORCID.

the class OpenIDController method getUserInfo.

/** Manually checks bearer token, looks up user or throws 403.
     * 
     * @return
     */
@RequestMapping(value = "/oauth/userinfo", method = { RequestMethod.GET, RequestMethod.POST }, produces = "application/json")
@ResponseBody
public ResponseEntity<OpenIDConnectUserInfo> getUserInfo(HttpServletRequest request) {
    //note we do not support form post per https://tools.ietf.org/html/rfc6750 because it's a MAY and pointless
    String authHeader = request.getHeader("Authorization");
    if (authHeader != null) {
        //lookup token, check it's valid, check scope.
        String tokenValue = authHeader.replace("Bearer", "").trim();
        OAuth2AccessToken tok = tokenStore.readAccessToken(tokenValue);
        if (tok != null && !tok.isExpired()) {
            boolean hasScope = false;
            Set<ScopePathType> requestedScopes = ScopePathType.getScopesFromStrings(tok.getScope());
            for (ScopePathType scope : requestedScopes) {
                if (scope.hasScope(ScopePathType.OPENID)) {
                    hasScope = true;
                }
            }
            if (hasScope) {
                String orcid = tok.getAdditionalInformation().get("orcid").toString();
                Person person = personDetailsManagerReadOnly.getPublicPersonDetails(orcid);
                return ResponseEntity.ok(new OpenIDConnectUserInfo(orcid, person));
            }
        }
    }
    return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
}
Also used : ScopePathType(org.orcid.jaxb.model.message.ScopePathType) OAuth2AccessToken(org.springframework.security.oauth2.common.OAuth2AccessToken) OpenIDConnectUserInfo(org.orcid.core.oauth.openid.OpenIDConnectUserInfo) Person(org.orcid.jaxb.model.record_v2.Person) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Test (org.junit.Test)69 Person (org.orcid.jaxb.model.record_v2.Person)58 Email (org.orcid.jaxb.model.record_v2.Email)40 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)40 Address (org.orcid.jaxb.model.record_v2.Address)35 Keyword (org.orcid.jaxb.model.record_v2.Keyword)35 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)35 OtherName (org.orcid.jaxb.model.record_v2.OtherName)34 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)34 Emails (org.orcid.jaxb.model.record_v2.Emails)33 Biography (org.orcid.jaxb.model.record_v2.Biography)32 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)32 Addresses (org.orcid.jaxb.model.record_v2.Addresses)30 Keywords (org.orcid.jaxb.model.record_v2.Keywords)30 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)30 Name (org.orcid.jaxb.model.record_v2.Name)27 Record (org.orcid.jaxb.model.record_v2.Record)22 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)21 DBUnitTest (org.orcid.test.DBUnitTest)16 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)14