Java 类java.security.IdentityScope 实例源码

项目:In-the-Box-Fork    文件:IdentityScope2Test.java   
/**
 * @tests java.security.IdentityScope#IdentityScope(java.lang.String)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "IdentityScope",
    args = {java.lang.String.class}
)
public void test_ConstructorLjava_lang_String() {
    String[] str = {"test", "", null};
    IdentityScopeSubclass iss;

    for (int i = 0; i < str.length; i++) {
        try {
            iss = new IdentityScopeSubclass(str[i]);
            assertNotNull(iss);
            assertTrue(iss instanceof IdentityScope);
        } catch (Exception e) {
            fail("Unexpected exception for parameter " + str[i]);
        }
    }
}
项目:In-the-Box-Fork    文件:SignerTest.java   
/**
 * @tests java.security.Signer#toString()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "toString",
    args = {}
)
public void test_toString() throws Exception {
    Signer s1 = new SignerStub("testToString1");
    assertEquals("[Signer]testToString1", s1.toString());

    Signer s2 = new SignerStub("testToString2", IdentityScope.getSystemScope());
    s2.toString();

    KeyPair kp = new KeyPair(new PublicKeyStub("public", "SignerTest.testToString", null),
            new PrivateKeyStub("private", "SignerTest.testToString", null));
    s1.setKeyPair(kp);
    s1.toString();

    s2.setKeyPair(kp);
    s2.toString();
}
项目:In-the-Box-Fork    文件:IdentityTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "equals",
    args = {java.lang.Object.class}
)
public void testEquals() throws Exception {
    IdentityStub i1 = new IdentityStub("testEquals");
    Object value[] =  {
            null, Boolean.FALSE,
            new Object(), Boolean.FALSE,
            i1, Boolean.TRUE,
            new IdentityStub(i1.getName()), Boolean.TRUE
    };

    for (int k=0; k<value.length; k+=2) {
        assertEquals(value[k+1], new Boolean(i1.equals(value[k])));
        if (Boolean.TRUE.equals(value[k+1])) assertEquals(i1.hashCode(), value[k].hashCode());
    }
    // check other cases
    Identity i2 = new IdentityStub("testEquals", IdentityScope.getSystemScope());
    assertEquals(i1.identityEquals(i2), i1.equals(i2));
    Identity i3 = new IdentityStub("testEquals3");
    assertEquals(i1.identityEquals(i3), i1.equals(i3));

}
项目:In-the-Box-Fork    文件:IdentityTest.java   
/**
 * verify Identity.getScope() returns identity's scope
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getScope",
    args = {}
)
public void testGetScope() throws Exception {
   Identity i = new IdentityStub("testGetScope");
   assertNull(i.getScope());
   IdentityScope s = IdentityScope.getSystemScope();

   Identity i2 = new IdentityStub("testGetScope2", s);
   assertSame(s, i2.getScope());

}
项目:In-the-Box-Fork    文件:IdentityScope2Test.java   
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Regression test",
    method = "getIdentity",
    args = {java.lang.String.class}
)
public void test_getIdentity() throws Exception {
    //Regression for HARMONY-1173
    IdentityScope scope = IdentityScope.getSystemScope();
    try {
        scope.getIdentity((String) null);
        fail("NPE expected");
    } catch (NullPointerException npe) {}
}
项目:In-the-Box-Fork    文件:Identity2Test.java   
/**
 * @tests java.security.Identity#getScope()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getScope",
    args = {}
)
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);
}
项目:In-the-Box-Fork    文件:IdentityScopeTest.java   
/**
 * check that void IdentityScope(String, IdentityScope) creates instance with given name and within given scope
 */
@TestTargetNew(
    level = TestLevel.PARTIAL,
    notes = "Verifies just positive test with both non null parameters",
    method = "IdentityScope",
    args = {java.lang.String.class, java.security.IdentityScope.class}
)
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());
}
项目:In-the-Box-Fork    文件:IdentityScopeTest.java   
/**
 * just call IdentityScope.getSystemScope()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getSystemScope",
    args = {}
)
public final void testGetSystemScope() {
    String name = Security.getProperty("system.scope");
    assertNotNull(name);
    IdentityScope scope = IdentityScope.getSystemScope();
    assertNotNull(scope);
    assertEquals(name, scope.getClass().getName());
}
项目:In-the-Box-Fork    文件:IdentityScopeTest.java   
/**
     * check that if permission given - set/get works
     * if permission is denied than SecurityException is thrown
     *
     */
    @TestTargets({
        @TestTargetNew(
            level = TestLevel.COMPLETE,
            notes = "",
            method = "setSystemScope",
            args = {java.security.IdentityScope.class}
        ),
        @TestTargetNew(
            level = TestLevel.COMPLETE,
            notes = "",
            method = "getSystemScope",
            args = {}
        )
    })
    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);
        }
    }
项目:In-the-Box-Fork    文件:IdentityTest.java   
/**
 * verify Identity(String, IdentityScope) creates instance with given name and in give scope
 */
@TestTargetNew(
    level = TestLevel.PARTIAL,
    notes = "KeyManagementException checking missed. Null parameters are not checked.",
    method = "Identity",
    args = {java.lang.String.class, java.security.IdentityScope.class}
)
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()));
}
项目:In-the-Box-Fork    文件:IdentityTest.java   
/**
 * verify Identity.identityEquals(Identity) return true, only if names and public keys are equal
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "identityEquals",
    args = {java.security.Identity.class}
)
public void testIdentityEquals() throws Exception {
    String name = "nnn";
    PublicKey pk = new PublicKeyStub("aaa", "fff", new byte[]{1,2,3,4,5});
    IdentityStub i = new IdentityStub(name);
    i.setPublicKey(pk);
    Object[] value = {
            //null, Boolean.FALSE,
            //new Object(), Boolean.FALSE,
            new IdentityStub("111"), Boolean.FALSE,
            new IdentityStub(name), Boolean.FALSE,
            new IdentityStub(name, IdentityScope.getSystemScope()), Boolean.FALSE,
            i, Boolean.TRUE,
            new IdentityStub(name, pk), Boolean.TRUE
    };
    for (int k=0; k<value.length; k+=2){
        assertEquals(value[k+1], new Boolean(i.identityEquals((Identity)value[k])));
        if (Boolean.TRUE.equals(value[k+1])) assertEquals(i.hashCode(), value[k].hashCode());
    }
    Identity i2 = IdentityScope.getSystemScope().getIdentity(name);
    i2.setPublicKey(pk);
    assertTrue(i.identityEquals(i2));
}
项目:In-the-Box-Fork    文件:IdentityTest.java   
/**
 * verify Identity.toString(boolean) return string representation of identity
 */
@TestTargetNew(
    level = TestLevel.PARTIAL,
    notes = "Method's returned value is not checked. SecurityException checking missed.",
    method = "toString",
    args = {boolean.class}
)
public void testToStringboolean() throws Exception {
    new IdentityStub("aaa").toString(false);
    new IdentityStub("aaa2", IdentityScope.getSystemScope()).toString(false);
    new IdentityStub("bbb").toString(true);
    new IdentityStub("bbb2", IdentityScope.getSystemScope()).toString(true);
}
项目:In-the-Box-Fork    文件:IdentityTest.java   
/**
 *
 * verify Identity.setPublicKey() throws KeyManagementException if key is invalid
 *
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "",
    method = "setPublicKey",
    args = {java.security.PublicKey.class}
)
public void testSetPublicKey2() throws Exception {
    Identity i2 = new IdentityStub("testSetPublicKey2_2", IdentityScope.getSystemScope());
    new PublicKeyStub("kkk", "testSetPublicKey2", new byte[]{1,2,3,4,5});
    try {
        i2.setPublicKey(null);
        //fail("KeyManagementException should be thrown - key is null");
    } catch (KeyManagementException ok) {}
}
项目:cn1    文件:IdentityScope2Test.java   
public void test_getIdentity() throws Exception {
    //Regression for HARMONY-1173
    IdentityScope scope = IdentityScope.getSystemScope(); 
    try {
        scope.getIdentity((String) null);
        fail("NPE expected");
    } catch (NullPointerException npe) {}
}
项目:cn1    文件:Identity2Test.java   
/**
 * @tests 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);
}
项目:cn1    文件:SystemScopeTest.java   
protected void setUp() throws Exception {
    super.setUp();
    if (mode) ss = new SystemScope("SystemScope");
    else {
        ss = IdentityScope.getSystemScope();
        Enumeration e = ss.identities();
        while (e.hasMoreElements()) ss.removeIdentity((Identity)e.nextElement());
    }
}
项目:freeVM    文件:IdentityScope2Test.java   
public void test_getIdentity() throws Exception {
    //Regression for HARMONY-1173
    IdentityScope scope = IdentityScope.getSystemScope(); 
    try {
        scope.getIdentity((String) null);
        fail("NPE expected");
    } catch (NullPointerException npe) {}
}
项目:freeVM    文件:Identity2Test.java   
/**
 * @tests 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);
}
项目:freeVM    文件:SystemScopeTest.java   
protected void setUp() throws Exception {
    super.setUp();
    if (mode) ss = new SystemScope("SystemScope");
    else {
        ss = IdentityScope.getSystemScope();
        Enumeration e = ss.identities();
        while (e.hasMoreElements()) ss.removeIdentity((Identity)e.nextElement());
    }
}
项目:freeVM    文件:IdentityScope2Test.java   
public void test_getIdentity() throws Exception {
    //Regression for HARMONY-1173
    IdentityScope scope = IdentityScope.getSystemScope(); 
    try {
        scope.getIdentity((String) null);
        fail("NPE expected");
    } catch (NullPointerException npe) {}
}
项目:freeVM    文件:Identity2Test.java   
/**
 * @tests 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);
}
项目:freeVM    文件:SystemScopeTest.java   
protected void setUp() throws Exception {
    super.setUp();
    if (mode) ss = new SystemScope("SystemScope");
    else {
        ss = IdentityScope.getSystemScope();
        Enumeration e = ss.identities();
        while (e.hasMoreElements()) ss.removeIdentity((Identity)e.nextElement());
    }
}
项目:In-the-Box-Fork    文件:IdentityScopeStub.java   
/**
 * Sets the system's identity scope
 * @param scope
 */
public static void mySetSystemScope(IdentityScope scope) {

    IdentityScope.setSystemScope(scope);
}
项目:In-the-Box-Fork    文件:SystemScope.java   
/**
 * @see java.security.IdentityScope#IdentityScope(String, IdentityScope)
 */
public SystemScope(String name, IdentityScope scope)
        throws KeyManagementException {
    super(name, scope);
}
项目:In-the-Box-Fork    文件:IdentityScope2Test.java   
public IdentityScopeSubclass(String name, IdentityScope scope)
        throws KeyManagementException {
    super(name, scope);
    identities = new Hashtable<Identity, Identity>();
}
项目:In-the-Box-Fork    文件:Identity2Test.java   
public IdentitySubclass(String name, IdentityScope scope)
        throws KeyManagementException {
    super(name, scope);
}
项目:cn1    文件:SystemScope.java   
/**
 * @see java.security.IdentityScope#IdentityScope(String, IdentityScope)
 */
public SystemScope(String name, IdentityScope scope)
        throws KeyManagementException {
    super(name, scope);
}
项目:cn1    文件:IdentityScope2Test.java   
public IdentityScopeSubclass(String name, IdentityScope scope)
        throws KeyManagementException {
    super(name, scope);
    identities = new Hashtable();
}
项目:cn1    文件:Identity2Test.java   
public IdentitySubclass(String name, IdentityScope scope)
        throws KeyManagementException {
    super(name, scope);
}
项目:cn1    文件:IdentityScopeStub.java   
/**
 * Sets the system's identity scope
 * @param scope
 */
public static void mySetSystemScope(IdentityScope scope) {

    IdentityScope.setSystemScope(scope);
}
项目:nextop-client    文件:SystemScope.java   
/**
 * @see IdentityScope#IdentityScope(String, IdentityScope)
 */
public SystemScope(String name, IdentityScope scope)
        throws KeyManagementException {
    super(name, scope);
}
项目:freeVM    文件:SystemScope.java   
/**
 * @see java.security.IdentityScope#IdentityScope(String, IdentityScope)
 */
public SystemScope(String name, IdentityScope scope)
        throws KeyManagementException {
    super(name, scope);
}
项目:freeVM    文件:IdentityScope2Test.java   
public IdentityScopeSubclass(String name, IdentityScope scope)
        throws KeyManagementException {
    super(name, scope);
    identities = new Hashtable();
}
项目:freeVM    文件:Identity2Test.java   
public IdentitySubclass(String name, IdentityScope scope)
        throws KeyManagementException {
    super(name, scope);
}
项目:freeVM    文件:IdentityScopeStub.java   
/**
 * Sets the system's identity scope
 * @param scope
 */
public static void mySetSystemScope(IdentityScope scope) {

    IdentityScope.setSystemScope(scope);
}
项目:freeVM    文件:SystemScope.java   
/**
 * @see java.security.IdentityScope#IdentityScope(String, IdentityScope)
 */
public SystemScope(String name, IdentityScope scope)
        throws KeyManagementException {
    super(name, scope);
}
项目:freeVM    文件:IdentityScope2Test.java   
public IdentityScopeSubclass(String name, IdentityScope scope)
        throws KeyManagementException {
    super(name, scope);
    identities = new Hashtable();
}
项目:freeVM    文件:Identity2Test.java   
public IdentitySubclass(String name, IdentityScope scope)
        throws KeyManagementException {
    super(name, scope);
}
项目:freeVM    文件:IdentityScopeStub.java   
/**
 * Sets the system's identity scope
 * @param scope
 */
public static void mySetSystemScope(IdentityScope scope) {

    IdentityScope.setSystemScope(scope);
}
项目:In-the-Box-Fork    文件:IdentityStub.java   
/**
 * TODO Put ctor description here
 *
 * @param name
 * @param scope
 * @throws KeyManagementException
 */
@SuppressWarnings("deprecation")
public IdentityStub(String name, IdentityScope scope)
        throws KeyManagementException {
    super(name, scope);
}