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);
}
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) {
}
}
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());
}
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");
}
}
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);
}
}
Aggregations