use of org.apache.harmony.security.x509.OtherName in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegatorImpl method viewOtherName.
@Override
public Response viewOtherName(String orcid, Long putCode) {
OtherName otherName = otherNameManagerReadOnly.getOtherName(orcid, putCode);
orcidSecurityManager.checkAndFilter(orcid, otherName, ScopePathType.ORCID_BIO_READ_LIMITED);
ElementUtils.setPathToOtherName(otherName, orcid);
sourceUtils.setSourceName(otherName);
return Response.ok(otherName).build();
}
use of org.apache.harmony.security.x509.OtherName in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_OtherNamesTest method testUpdateOtherNameLeavingVisibilityNullTest.
@Test
public void testUpdateOtherNameLeavingVisibilityNullTest() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewOtherName("4444-4444-4444-4443", 1L);
assertNotNull(response);
OtherName otherName = (OtherName) response.getEntity();
assertNotNull(otherName);
assertEquals(Visibility.PUBLIC, otherName.getVisibility());
otherName.setVisibility(null);
response = serviceDelegator.updateOtherName("4444-4444-4444-4443", 1L, otherName);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
otherName = (OtherName) response.getEntity();
assertNotNull(otherName);
assertEquals(Visibility.PUBLIC, otherName.getVisibility());
}
use of org.apache.harmony.security.x509.OtherName in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_OtherNamesTest method testUpdateOtherNameYouAreNotTheSourceOf.
@Test(expected = WrongSourceException.class)
public void testUpdateOtherNameYouAreNotTheSourceOf() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewOtherName("4444-4444-4444-4443", 2L);
assertNotNull(response);
OtherName otherName = (OtherName) response.getEntity();
assertNotNull(otherName);
assertEquals("Flibberdy Flabinah", otherName.getContent());
assertEquals(Visibility.PUBLIC, otherName.getVisibility());
otherName.setContent("Updated Other Name " + System.currentTimeMillis());
serviceDelegator.updateOtherName("4444-4444-4444-4443", 2L, otherName);
fail();
}
use of org.apache.harmony.security.x509.OtherName in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_OtherNamesTest method testViewLimitedOtherName.
@Test
public void testViewLimitedOtherName() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewOtherName("4444-4444-4444-4446", 6L);
assertNotNull(response);
OtherName otherName = (OtherName) response.getEntity();
assertNotNull(otherName);
assertEquals("/4444-4444-4444-4446/other-names/6", otherName.getPath());
Utils.verifyLastModified(otherName.getLastModifiedDate());
assertEquals("Other Name # 2", otherName.getContent());
assertEquals(Visibility.LIMITED, otherName.getVisibility());
assertEquals("4444-4444-4444-4446", otherName.getSource().retrieveSourcePath());
}
use of org.apache.harmony.security.x509.OtherName in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_OtherNamesTest method testViewPrivateOtherName.
@Test
public void testViewPrivateOtherName() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewOtherName("4444-4444-4444-4446", 8L);
assertNotNull(response);
OtherName otherName = (OtherName) response.getEntity();
assertNotNull(otherName);
assertEquals("/4444-4444-4444-4446/other-names/8", otherName.getPath());
Utils.verifyLastModified(otherName.getLastModifiedDate());
assertEquals("Other Name # 4", otherName.getContent());
assertEquals(Visibility.PRIVATE, otherName.getVisibility());
assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
}
Aggregations