Search in sources :

Example 21 with Identity

use of java.security.Identity in project robovm by robovm.

the class IdentityTest method testGetInfo.

public void testGetInfo() {
    Identity i = new IdentityStub("testGetInfo");
    i.setInfo("some info");
    assertEquals("some info", i.getInfo());
}
Also used : IdentityStub(org.apache.harmony.security.tests.support.IdentityStub) Identity(java.security.Identity)

Example 22 with Identity

use of java.security.Identity in project robovm by robovm.

the class IdentityTest method testCertificates.

//
//  Commented out since there will no be fix for the test failure
//    /**
//     * verify removeCertificate(Certificate certificate) removes certificate
//     */
//    public void testRemoveCertificate1() throws Exception{
//        Identity i = new IdentityStub("iii");
//        PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);
//        CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
//        i.addCertificate(c1);
//        assertSame(c1, i.certificates()[0]);
//        i.removeCertificate(c1);
//        assertEquals(0, i.certificates().length);
//        // throw KeyManagementException if certificate not found
//        try {
//            i.removeCertificate(c1);
//            fail("KeyManagementException should be thrown");
//        } catch (KeyManagementException ok) {
//        }
//        try {
//            i.removeCertificate(null);
//            fail("KeyManagementException should be thrown");
//        } catch (KeyManagementException ok) {
//
//        }
//    }
/**
     * verify certificates() returns a copy of all certificates for this identity
     */
public void testCertificates() throws Exception {
    Identity i = new IdentityStub("iii");
    PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);
    CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
    CertificateStub c2 = new CertificateStub("zzz", null, null, pk1);
    i.addCertificate(c1);
    i.addCertificate(c2);
    java.security.Certificate[] s = i.certificates();
    assertEquals(2, s.length);
    assertTrue(c1.equals(s[0]) || c2.equals(s[0]));
    assertTrue(c1.equals(s[1]) || c2.equals(s[1]));
    s[0] = null;
    s[1] = null;
    // check that the copy was modified
    s = i.certificates();
    assertEquals(2, s.length);
    assertTrue(c1.equals(s[0]) || c2.equals(s[0]));
    assertTrue(c1.equals(s[1]) || c2.equals(s[1]));
}
Also used : IdentityStub(org.apache.harmony.security.tests.support.IdentityStub) CertificateStub(org.apache.harmony.security.tests.support.CertificateStub) PublicKeyStub(org.apache.harmony.security.tests.support.PublicKeyStub) Identity(java.security.Identity)

Example 23 with Identity

use of java.security.Identity in project robovm by robovm.

the class IdentityTest method testIdentityString.

/*
     * verify Identity(String) creates instance with given name
     */
public void testIdentityString() {
    Identity i = new IdentityStub("iii");
    assertNotNull(i);
    assertEquals("iii", i.getName());
    i = new IdentityStub(null);
    assertNotNull(i);
    assertNull(i.getName());
}
Also used : IdentityStub(org.apache.harmony.security.tests.support.IdentityStub) Identity(java.security.Identity)

Aggregations

Identity (java.security.Identity)23 IdentityStub (org.apache.harmony.security.tests.support.IdentityStub)13 IdentitySubclass (org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass)8 PublicKeyStub (org.apache.harmony.security.tests.support.PublicKeyStub)7 KeyManagementException (java.security.KeyManagementException)5 CertificateStub (org.apache.harmony.security.tests.support.CertificateStub)4 PublicKey (java.security.PublicKey)3 IdentityScope (java.security.IdentityScope)2 FileInputStream (java.io.FileInputStream)1 Principal (java.security.Principal)1 Group (java.security.acl.Group)1 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 Vector (java.util.Vector)1 Subject (javax.security.auth.Subject)1 IdentityScopeSubclass (org.apache.harmony.security.tests.java.security.IdentityScope2Test.IdentityScopeSubclass)1 Test (org.junit.Test)1 Column (org.teiid.metadata.Column)1 MetadataFactory (org.teiid.metadata.MetadataFactory)1