use of test1.Person in project ORCID-Source by ORCID.
the class ValidateV2RC3Identifiers method testPerson.
/**
* <external-identifier:external-identifiers>
* <external-identifier:external-identifier visibility="public" put-code="1">
* <common:external-id-type>type-1</common:external-id-type>
* <common:external-id-value>value-1</common:external-id-value>
* <common:external-id-url>http://url.com/1</common:external-id-url>
* <common:created-date>2001-12-31T12:00:00</common:created-date>
* <common:last-modified-date>2001-12-31T12:00:00</common:last-modified-date>
* <common:source>
* <common:source-orcid>
* <common:uri>http://orcid.org/8888-8888-8888-8880</common:uri>
* <common:path>8888-8888-8888-8880</common:path>
* <common:host>orcid.org</common:host>
* </common:source-orcid>
* <common:source-name />
* </common:source>
* </external-identifier:external-identifier>
* </external-identifier:external-identifiers>
*
* @throws SAXException
* @throws IOException
* @throws JAXBException
* @throws ParserConfigurationException
*/
@Test
public void testPerson() throws SAXException, IOException, JAXBException, ParserConfigurationException {
Person person = unmarshallFromPath("/record_2.0_rc3/samples/person-2.0_rc3.xml", Person.class);
assertEquals("credit-name", person.getName().getCreditName().getContent());
assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
PersonExternalIdentifier id = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
assertEquals("type-1", id.getType());
assertEquals("value-1", id.getValue());
assertEquals(new Url("http://url.com/1"), id.getUrl());
assertNull(id.getRelationship());
assertNotNull(id.getCreatedDate().getValue());
assertNotNull(id.getLastModifiedDate().getValue());
assertEquals(new Long(1), id.getPutCode());
assertEquals(Visibility.PUBLIC, id.getVisibility());
Validator validator = getValidator("person");
validator.validate(marshall(Person.class, person));
validator.validate(marshallToDOM(Person.class, person));
}
use of test1.Person in project ORCID-Source by ORCID.
the class OpenIDConnectTokenEnhancer method enhance.
@Override
public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
// We check for a nonce and max_age which are added back into request by
// OrcidClientCredentialEndPointDelegatorImpl
Map<String, String> params = authentication.getOAuth2Request().getRequestParameters();
// only add if we're using openid scope.
// only add in implicit flow if response_type id_token is present
String scopes = params.get(OrcidOauth2Constants.SCOPE_PARAM);
if (PojoUtil.isEmpty(scopes) || !ScopePathType.getScopesFromSpaceSeparatedString(scopes).contains(ScopePathType.OPENID)) {
return accessToken;
}
// purposes. Some APIs support it, but it is not part of the spec.
try {
String orcid = authentication.getName();
Builder claims = new JWTClaimsSet.Builder();
claims.audience(params.get(OrcidOauth2Constants.CLIENT_ID_PARAM));
claims.issuer("https://orcid.org");
claims.subject("https://orcid.org" + "/" + orcid);
claims.claim("id_path", orcid);
claims.claim("at_hash", createAccessTokenHash(accessToken.getValue()));
Date now = new Date();
claims.expirationTime(new Date(now.getTime() + 600000));
claims.issueTime(now);
claims.jwtID(UUID.randomUUID().toString());
if (params.get(OrcidOauth2Constants.NONCE) != null)
claims.claim(OrcidOauth2Constants.NONCE, params.get(OrcidOauth2Constants.NONCE));
claims.claim(OrcidOauth2Constants.AUTH_TIME, profileEntityManager.getLastLogin(orcid));
Person person = personDetailsManagerReadOnly.getPublicPersonDetails(orcid);
if (person.getName() != null) {
if (person.getName().getCreditName() != null) {
claims.claim("name", person.getName().getCreditName().getContent());
}
if (person.getName().getFamilyName() != null) {
claims.claim("family_name", person.getName().getFamilyName().getContent());
}
if (person.getName().getGivenNames() != null) {
claims.claim("given_name", person.getName().getGivenNames().getContent());
}
}
SignedJWT signedJWT = keyManager.sign(claims.build());
String idTok = signedJWT.serialize();
accessToken.getAdditionalInformation().put(OrcidOauth2Constants.ID_TOKEN, idTok);
} catch (JOSEException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return accessToken;
}
use of test1.Person in project ORCID-Source by ORCID.
the class RDFWriterTest method fakeBio.
private Record fakeBio() throws DatatypeConfigurationException {
Record r = new Record();
r.setOrcidIdentifier(new OrcidIdentifier());
r.getOrcidIdentifier().setPath("000-1337");
r.getOrcidIdentifier().setUri("http://orcid.example.com/000-1337");
r.setHistory(new History());
r.getHistory().setCreationMethod(CreationMethod.WEBSITE);
XMLGregorianCalendar value = dataTypeFactory.newXMLGregorianCalendar(1980, 12, 31, 23, 29, 29, 999, 0);
r.getHistory().setLastModifiedDate(new LastModifiedDate(value));
r.getHistory().setClaimed(true);
r.setPerson(new Person());
r.getPerson().setBiography(new Biography());
r.getPerson().setName(new Name());
r.getPerson().getName().setFamilyName(new FamilyName("Doe"));
r.getPerson().getName().setCreditName(new CreditName("John F Doe"));
r.getPerson().getName().setGivenNames(new GivenNames("John"));
r.getPerson().setOtherNames(new OtherNames());
r.getPerson().getOtherNames().setOtherNames(new ArrayList<OtherName>());
OtherName n = new OtherName();
n.setContent("Johnny");
n.setVisibility(Visibility.PUBLIC);
OtherName n1 = new OtherName();
n1.setContent("Mr Doe");
n1.setVisibility(Visibility.PUBLIC);
r.getPerson().getOtherNames().getOtherNames().add(n);
r.getPerson().getOtherNames().getOtherNames().add(n1);
r.getPerson().setResearcherUrls(new ResearcherUrls());
r.getPerson().getResearcherUrls().setResearcherUrls(new ArrayList<ResearcherUrl>());
ResearcherUrl anonymous = new ResearcherUrl();
anonymous.setUrl(new Url("http://example.com/anon"));
anonymous.setVisibility(Visibility.PUBLIC);
r.getPerson().getResearcherUrls().getResearcherUrls().add(anonymous);
r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/myPage", "homePage"));
r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/foaf#me", "FOAF"));
r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/webId", "webID"));
r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/other", "other"));
r.getPerson().setAddresses(new Addresses());
r.getPerson().getAddresses().setAddress(new ArrayList<Address>());
Address a = new Address();
a.setCountry(new Country());
a.getCountry().setValue(Iso3166Country.GB);
r.getPerson().getAddresses().getAddress().add(a);
r.getPerson().setEmails(new Emails());
r.getPerson().getEmails().setEmails(new ArrayList<Email>());
Email e = new Email();
e.setEmail("john@example.org");
e.setCurrent(true);
Email e1 = new Email();
e1.setEmail("doe@example.com");
e1.setCurrent(true);
r.getPerson().getEmails().getEmails().add(e);
r.getPerson().getEmails().getEmails().add(e1);
return r;
}
use of test1.Person in project webofneeds by researchstudio-sat.
the class GeneratedSourcesTests method test1Generated_rdfgen002.
@Test
public void test1Generated_rdfgen002() throws IOException {
Shapes shapes = loadShapes(testBaseFolder.createRelative("test1/shapes.ttl"));
Person bob = new Person("http://example.com/ns#Bob");
bob.setNode(NodeFactory.createURI("http://example.com/ns#Bob"));
bob.addFirstName("Bob");
bob.setLastName("The Builder");
Address address = new Address();
address.setPostalCode("1234");
bob.addAddress(address);
Graph graph = test1.RdfOutput.toGraph(bob);
Model expected = loadData(new ClassPathResource("won/shacl2java/test1/expected-rdfgen002.ttl"));
Assert.assertTrue("generated graph differs from expected", graph.isIsomorphicWith(expected.getGraph()));
}
Aggregations