Code example for IdentityScope

Methods: addIdentity, getIdentity

0
         
    } 
 
    /* 
     * verify  getIdentity(PublicKey) returns requested identity or null if not found 
     */ 
    public void testGetIdentityPublicKey() throws Exception { 
        //SystemScope ss = new SystemScope("SystemScope"); 
        java.security.PublicKey kkk = new PublicKeyStub("kkk", "fff", null);
        assertNull(ss.getIdentity(kkk));
        java.security.Identity aaa = new IdentityScopeStub("aaa");
        aaa.setPublicKey(kkk);
        ss.addIdentity(aaa);
         
        assertSame(aaa, ss.getIdentity(kkk));                
    } 
 
    /** 
     * verify that only one identity with given name or public key can be added 
     * i.e. KeyManagementException is thrown 
     */