Search in sources :

Example 1 with IdentityScope

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

the class Identity2Test method test_getScope.

/**
     * java.security.Identity#getScope()
     */
public void test_getScope() throws Exception {
    IdentityScope scope = new IdentityScopeSubclass();
    IdentitySubclass sub = new IdentitySubclass("test", scope);
    IdentityScope returnedScope = sub.getScope();
    assertEquals("Wrong Scope returned", scope, returnedScope);
}
Also used : IdentityScopeSubclass(org.apache.harmony.security.tests.java.security.IdentityScope2Test.IdentityScopeSubclass) IdentityScope(java.security.IdentityScope)

Example 2 with IdentityScope

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

the class IdentityScope2Test method test_getIdentity.

public void test_getIdentity() throws Exception {
    //Regression for HARMONY-1173
    IdentityScope scope = IdentityScope.getSystemScope();
    try {
        scope.getIdentity((String) null);
        fail();
    } catch (NullPointerException expected) {
    }
}
Also used : IdentityScope(java.security.IdentityScope)

Example 3 with IdentityScope

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

the class IdentityScopeTest method testIdentityScopeStringIdentityScope.

/**
     * check that void IdentityScope(String, IdentityScope) creates instance with given name and within given scope
     */
public final void testIdentityScopeStringIdentityScope() throws Exception {
    IdentityScope scope = new IdentityScopeStub("my scope");
    is = new IdentityScopeStub("Aleksei Semenov", scope);
    assertNotNull(is);
    assertEquals("Aleksei Semenov", is.getName());
    assertEquals(scope.getName(), is.getScope().getName());
}
Also used : IdentityScope(java.security.IdentityScope) IdentityScopeStub(org.apache.harmony.security.tests.support.IdentityScopeStub)

Example 4 with IdentityScope

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

the class IdentityScope2Test method test_ConstructorLjava_lang_StringLjava_security_IdentityScope.

/**
     * java.security.IdentityScope#IdentityScope(java.lang.String,
     *        java.security.IdentityScope)
     */
public void test_ConstructorLjava_lang_StringLjava_security_IdentityScope() {
    String nameNull = null;
    String[] str = { "test", "", "!@#$%^&*()", "identity name" };
    IdentityScope is;
    IdentityScope iss = new IdentityScopeSubclass("test scope");
    for (int i = 0; i < str.length; i++) {
        try {
            is = new IdentityScopeSubclass(str[i], new IdentityScopeSubclass());
            assertNotNull(is);
            assertTrue(is instanceof IdentityScope);
        } catch (Exception e) {
            fail("Unexpected exception for parameter " + str[i]);
        }
    }
    try {
        is = new IdentityScopeSubclass(nameNull, new IdentityScopeSubclass());
    } catch (NullPointerException npe) {
    } catch (Exception e) {
        fail("Incorrect exception " + e + " was thrown");
    }
    try {
        is = new IdentityScopeSubclass("test", iss);
        is = new IdentityScopeSubclass("test", iss);
        fail("KeyManagementException was not thrown");
    } catch (KeyManagementException npe) {
    //expected
    } catch (Exception e) {
        fail("Incorrect exception " + e + " was thrown instead of KeyManagementException");
    }
}
Also used : IdentityScope(java.security.IdentityScope) KeyManagementException(java.security.KeyManagementException) KeyManagementException(java.security.KeyManagementException)

Example 5 with IdentityScope

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

the class IdentityScopeTest method testSetSystemScope.

/**
     * check that if permission given - set/get works
     * if permission is denied than SecurityException is thrown
     *
     */
public final void testSetSystemScope() {
    //      default implementation is specified by security property system.scope
    IdentityScope systemScope = IdentityScope.getSystemScope();
    try {
        // all permissions are granted - sm is not installed
        is = new IdentityScopeStub("Aleksei Semenov");
        IdentityScopeStub.mySetSystemScope(is);
        assertSame(is, IdentityScope.getSystemScope());
    } finally {
        IdentityScopeStub.mySetSystemScope(systemScope);
    }
}
Also used : IdentityScope(java.security.IdentityScope) IdentityScopeStub(org.apache.harmony.security.tests.support.IdentityScopeStub)

Aggregations

IdentityScope (java.security.IdentityScope)8 Identity (java.security.Identity)2 IdentityScopeStub (org.apache.harmony.security.tests.support.IdentityScopeStub)2 IdentityStub (org.apache.harmony.security.tests.support.IdentityStub)2 KeyManagementException (java.security.KeyManagementException)1 IdentityScopeSubclass (org.apache.harmony.security.tests.java.security.IdentityScope2Test.IdentityScopeSubclass)1