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());
}
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");
}
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");
}
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");
}
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();
}
Aggregations