use of org.orcid.jaxb.model.record_rc2.OtherName in project ORCID-Source by ORCID.
the class OrcidSecurityManager_generalTest method testCollection_When_SourceOfLimitedAndPrivate_ReadPublicScope.
@Test
public void testCollection_When_SourceOfLimitedAndPrivate_ReadPublicScope() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_PUBLIC);
List<OtherName> list = new ArrayList<OtherName>();
OtherName o1 = createOtherName(Visibility.PUBLIC, CLIENT_2);
OtherName o2 = createOtherName(Visibility.LIMITED, CLIENT_1);
OtherName o3 = createOtherName(Visibility.PRIVATE, CLIENT_1);
list.add(o1);
list.add(o2);
list.add(o3);
orcidSecurityManager.checkAndFilter(ORCID_1, list, ScopePathType.ORCID_BIO_READ_LIMITED);
assertEquals(3, list.size());
assertTrue(list.contains(o1));
assertTrue(list.contains(o2));
assertTrue(list.contains(o3));
}
use of org.orcid.jaxb.model.record_rc2.OtherName in project ORCID-Source by ORCID.
the class OrcidSecurityManager_generalTest method testCollection_When_NotSource_ReadPublicScope.
@Test
public void testCollection_When_NotSource_ReadPublicScope() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_PUBLIC);
List<OtherName> list = new ArrayList<OtherName>();
OtherName o1 = createOtherName(Visibility.PUBLIC, CLIENT_2);
OtherName o2 = createOtherName(Visibility.LIMITED, CLIENT_2);
OtherName o3 = createOtherName(Visibility.PRIVATE, CLIENT_2);
list.add(o1);
list.add(o2);
list.add(o3);
orcidSecurityManager.checkAndFilter(ORCID_1, list, ScopePathType.ORCID_BIO_READ_LIMITED);
assertEquals(1, list.size());
assertTrue(list.contains(o1));
assertFalse(list.contains(o2));
assertFalse(list.contains(o3));
}
use of org.orcid.jaxb.model.record_rc2.OtherName in project ORCID-Source by ORCID.
the class OrcidSecurityManager_generalTest method testCollection_When_SourceOfPrivate_ReadPublicScope.
@Test
public void testCollection_When_SourceOfPrivate_ReadPublicScope() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_PUBLIC);
List<OtherName> list = new ArrayList<OtherName>();
OtherName o1 = createOtherName(Visibility.PUBLIC, CLIENT_2);
OtherName o2 = createOtherName(Visibility.LIMITED, CLIENT_2);
OtherName o3 = createOtherName(Visibility.PRIVATE, CLIENT_1);
list.add(o1);
list.add(o2);
list.add(o3);
orcidSecurityManager.checkAndFilter(ORCID_1, list, ScopePathType.ORCID_BIO_READ_LIMITED);
assertEquals(2, list.size());
assertTrue(list.contains(o1));
assertFalse(list.contains(o2));
assertTrue(list.contains(o3));
}
use of org.orcid.jaxb.model.record_rc2.OtherName in project certmgr by hdecarne.
the class ASN1DataTest method testGeneralNames.
/**
* Test encoding & decoding of {@link GeneralNames} object.
*/
@Test
public void testGeneralNames() {
try {
GeneralNames in = new GeneralNames();
DirectoryName inNameA = new DirectoryName(new X500Principal("CN=localhost"));
GenericName inNameB = new GenericName(GeneralNameType.X400_ADDRESS, new DEROctetString("test".getBytes()).getEncoded());
IPAddressName inNameC = new IPAddressName(InetAddress.getByName("127.0.0.1"), null);
IPAddressName inNameD = new IPAddressName(InetAddress.getByName("127.0.0.1"), InetAddress.getByName("255.255.255.255"));
IPAddressName inNameE = new IPAddressName(InetAddress.getByName("::1"), null);
IPAddressName inNameF = new IPAddressName(InetAddress.getByName("::1"), InetAddress.getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
OtherName inNameG = new OtherName("1.2.3.4", new DEROctetString("test".getBytes()).getEncoded());
RegisteredIDName inNameH = new RegisteredIDName("1.2.3.4");
StringName inNameI = new StringName(GeneralNameType.UNIFORM_RESOURCE_IDENTIFIER, "https://localhost/test.crl");
in.addName(inNameA);
in.addName(inNameB);
in.addName(inNameC);
in.addName(inNameD);
in.addName(inNameE);
in.addName(inNameF);
in.addName(inNameG);
in.addName(inNameH);
in.addName(inNameI);
byte[] inEncoded = in.getEncoded();
GeneralNames out = GeneralNames.decode(decodeBytes(inEncoded));
byte[] outEncoded = out.getEncoded();
Assert.assertArrayEquals(inEncoded, outEncoded);
} catch (IOException e) {
e.printStackTrace();
Assert.fail(e.getLocalizedMessage());
}
}
use of org.orcid.jaxb.model.record_rc2.OtherName in project signer by demoiselle.
the class OIDGeneric method getInstance.
/**
* @param der
* Content of Certificate on sun.security.util.DerValue format
* @return OIDGenerico current instance
* @throws IOException input/output exception
* @throws Exception general exception
*/
public static OIDGeneric getInstance(DerValue der) throws IOException, Exception {
OtherName on = new OtherName(der);
String className = getPackageName() + on.getOID().toString().replaceAll("[.]", "_");
OIDGeneric oidGenerico;
try {
oidGenerico = (OIDGeneric) Class.forName(className).newInstance();
} catch (InstantiationException e) {
throw new Exception(coreMessagesBundle.getString("error.class.instance", className), e);
} catch (IllegalAccessException e) {
throw new Exception(coreMessagesBundle.getString("error.class.illegal.access", className), e);
} catch (ClassNotFoundException e) {
oidGenerico = new OIDGeneric();
}
oidGenerico.oid = on.getOID().toString();
oidGenerico.data = new String(on.getNameValue()).substring(6);
oidGenerico.initialize();
return oidGenerico;
}
Aggregations