Search in sources :

Example 66 with OtherName

use of de.carne.certmgr.certs.x509.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));
}
Also used : OtherName(org.orcid.jaxb.model.record_v2.OtherName) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 67 with OtherName

use of de.carne.certmgr.certs.x509.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));
}
Also used : OtherName(org.orcid.jaxb.model.record_v2.OtherName) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 68 with OtherName

use of de.carne.certmgr.certs.x509.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());
    }
}
Also used : GenericName(de.carne.certmgr.certs.x509.GenericName) GeneralNames(de.carne.certmgr.certs.x509.GeneralNames) IPAddressName(de.carne.certmgr.certs.x509.IPAddressName) RegisteredIDName(de.carne.certmgr.certs.x509.RegisteredIDName) StringName(de.carne.certmgr.certs.x509.StringName) OtherName(de.carne.certmgr.certs.x509.OtherName) X500Principal(javax.security.auth.x500.X500Principal) IOException(java.io.IOException) DirectoryName(de.carne.certmgr.certs.x509.DirectoryName) DEROctetString(org.bouncycastle.asn1.DEROctetString) Test(org.junit.Test)

Example 69 with OtherName

use of de.carne.certmgr.certs.x509.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;
}
Also used : OtherName(sun.security.x509.OtherName) DERIA5String(org.bouncycastle.asn1.DERIA5String) DERUTF8String(org.bouncycastle.asn1.DERUTF8String) DEROctetString(org.bouncycastle.asn1.DEROctetString) DERPrintableString(org.bouncycastle.asn1.DERPrintableString) IOException(java.io.IOException)

Example 70 with OtherName

use of de.carne.certmgr.certs.x509.OtherName in project ORCID-Source by ORCID.

the class OtherNameManagerTest method testAddOtherNameToUnclaimedRecordPreserveOtherNameVisibility.

@Test
public void testAddOtherNameToUnclaimedRecordPreserveOtherNameVisibility() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    OtherName otherName = getOtherName();
    otherName = otherNameManager.createOtherName(unclaimedOrcid, otherName, true);
    otherName = otherNameManager.getOtherName(unclaimedOrcid, otherName.getPutCode());
    assertNotNull(otherName);
    assertEquals(Visibility.PUBLIC, otherName.getVisibility());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

OtherName (org.orcid.jaxb.model.record_v2.OtherName)110 Test (org.junit.Test)98 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)55 Biography (org.orcid.jaxb.model.record_v2.Biography)44 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)44 Name (org.orcid.jaxb.model.record_v2.Name)43 Address (org.orcid.jaxb.model.record_v2.Address)42 Keyword (org.orcid.jaxb.model.record_v2.Keyword)40 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)40 Email (org.orcid.jaxb.model.record_v2.Email)38 Addresses (org.orcid.jaxb.model.record_v2.Addresses)33 Emails (org.orcid.jaxb.model.record_v2.Emails)33 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)33 Keywords (org.orcid.jaxb.model.record_v2.Keywords)32 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)32 Person (org.orcid.jaxb.model.record_v2.Person)31 ArrayList (java.util.ArrayList)21 Response (javax.ws.rs.core.Response)20 DBUnitTest (org.orcid.test.DBUnitTest)20 Record (org.orcid.jaxb.model.record_v2.Record)19