Ejemplo n.º 1
0
 /** verify Identity(String, IdentityScope) creates instance with given name and in give scope */
 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()));
 }
Ejemplo n.º 2
0
 /**
  * Sets the specified {@code PublicKey} to this {@code Identity}.
  *
  * @param key the {@code PublicKey} to be set.
  * @throws KeyManagementException if another {@code Identity} in the same scope as this {@code
  *     Identity} already has the same {@code PublicKey}.
  */
 public void setPublicKey(PublicKey key) throws KeyManagementException {
   // this check does not always work
   if ((scope != null) && (key != null)) {
     Identity i = scope.getIdentity(key);
     // System.out.println("###DEBUG## Identity: "+i);
     if ((i != null) && (i != this)) {
       throw new KeyManagementException("key already used in scope");
     }
   }
   this.publicKey = key;
   certificates = null;
 }