Search in sources :

Example 11 with IdentityStub

use of org.apache.harmony.security.tests.support.IdentityStub in project robovm by robovm.

the class IdentityTest method testGetPublicKey.

/**
     * verify Identity.getPublicKey() returns public key
     */
public void testGetPublicKey() throws Exception {
    Identity i = new IdentityStub("testGetPublicKey");
    assertNull(i.getPublicKey());
    PublicKey pk = new PublicKeyStub("kkk", "Identity.testGetPublicKey", null);
    i.setPublicKey(pk);
    assertSame(pk, i.getPublicKey());
}
Also used : IdentityStub(org.apache.harmony.security.tests.support.IdentityStub) PublicKey(java.security.PublicKey) PublicKeyStub(org.apache.harmony.security.tests.support.PublicKeyStub) Identity(java.security.Identity)

Example 12 with IdentityStub

use of org.apache.harmony.security.tests.support.IdentityStub in project robovm by robovm.

the class IdentityTest method testIdentityStringIdentityScope.

/**
     * verify Identity(String, IdentityScope) creates instance with given name and in give scope
     */
public void testIdentityStringIdentityScope() throws Exception {
    IdentityScope s = IdentityScope.getSystemScope();
    Identity i = new IdentityStub("iii2", s);
    assertNotNull(i);
    assertEquals("iii2", i.getName());
    assertSame(s, i.getScope());
    assertSame(i, s.getIdentity(i.getName()));
}
Also used : IdentityScope(java.security.IdentityScope) IdentityStub(org.apache.harmony.security.tests.support.IdentityStub) Identity(java.security.Identity)

Example 13 with IdentityStub

use of org.apache.harmony.security.tests.support.IdentityStub 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 14 with IdentityStub

use of org.apache.harmony.security.tests.support.IdentityStub 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 15 with IdentityStub

use of org.apache.harmony.security.tests.support.IdentityStub 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

IdentityStub (org.apache.harmony.security.tests.support.IdentityStub)15 Identity (java.security.Identity)13 PublicKeyStub (org.apache.harmony.security.tests.support.PublicKeyStub)7 CertificateStub (org.apache.harmony.security.tests.support.CertificateStub)4 KeyManagementException (java.security.KeyManagementException)3 IdentityScope (java.security.IdentityScope)2 PublicKey (java.security.PublicKey)2