Search in sources :

Example 1 with Identity

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

the class IdentityScope2Test method test_removeIdentityLjava_security_Identity.

/**
     * java.security.IdentityScope#removeIdentity(java.security.Identity)
     */
public void test_removeIdentityLjava_security_Identity() throws Exception {
    IdentityScopeSubclass sub = new IdentityScopeSubclass("test", new IdentityScopeSubclass());
    Identity id = new IdentitySubclass();
    id.setPublicKey(getPubKey());
    sub.addIdentity(id);
    sub.removeIdentity(id);
    try {
        sub.removeIdentity(id);
        fail("KeyManagementException should have been thrown");
    } catch (KeyManagementException expected) {
    }
}
Also used : IdentitySubclass(org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass) Identity(java.security.Identity) KeyManagementException(java.security.KeyManagementException)

Example 2 with Identity

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

the class IdentityScope2Test method test_toString.

/**
     * java.security.IdentityScope#toString()
     */
public void test_toString() throws Exception {
    IdentityScopeSubclass sub = new IdentityScopeSubclass("test", new IdentityScopeSubclass());
    Identity id = new IdentitySubclass();
    id.setPublicKey(getPubKey());
    sub.addIdentity(id);
    assertNotNull("toString returned a null", sub.toString());
    assertTrue("Not a valid String ", sub.toString().length() > 0);
}
Also used : IdentitySubclass(org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass) Identity(java.security.Identity)

Example 3 with Identity

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

the class IdentityScope2Test method test_identities.

/**
     * java.security.IdentityScope#identities()
     */
public void test_identities() throws Exception {
    IdentityScopeSubclass sub = new IdentityScopeSubclass("test", new IdentityScopeSubclass());
    Identity id = new IdentitySubclass();
    id.setPublicKey(getPubKey());
    sub.addIdentity(id);
    Enumeration<Identity> en = sub.identities();
    assertEquals("Wrong object contained in identities", en.nextElement(), id);
    assertFalse("Contains too many elements", en.hasMoreElements());
}
Also used : IdentitySubclass(org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass) Identity(java.security.Identity)

Example 4 with Identity

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

the class IdentityScope2Test method test_getIdentityLjava_security_PublicKey.

/**
     * java.security.IdentityScope#getIdentity(java.security.PublicKey)
     */
public void test_getIdentityLjava_security_PublicKey() throws Exception {
    IdentityScopeSubclass sub = new IdentityScopeSubclass("test", new IdentityScopeSubclass());
    Identity id = new IdentitySubclass();
    id.setPublicKey(getPubKey());
    sub.addIdentity(id);
    Identity returnedId = sub.getIdentity(getPubKey());
    assertEquals("Test 1: Returned Identity not the same as the added one;", id, returnedId);
    assertNull("Test 2: Null value expected.", sub.getIdentity((PublicKey) null));
    PublicKey anotherKey = KeyPairGenerator.getInstance("DSA").genKeyPair().getPublic();
    assertNull("Test 3: Null value expected.", sub.getIdentity(anotherKey));
}
Also used : IdentitySubclass(org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass) PublicKey(java.security.PublicKey) Identity(java.security.Identity)

Example 5 with Identity

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

the class IdentityTest method testGetName.

public void testGetName() {
    Identity i = new IdentityStub("testGetName");
    assertEquals("testGetName", 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