Code example for KeyManagementException

0
            throw new NullPointerException("identity == null");
        } 
 
        String name = identity.getName();
        if (names.containsKey(name)) {
            throw new KeyManagementException("name '" + name + "' is already used");
        } 
 
        PublicKey key = identity.getPublicKey();
        if (key != null && keys.containsKey(key)) {
            throw new KeyManagementException("key '" + key + "' is already used");
        } 
 
        names.put(name, identity);
        if (key != null) {
            keys.put(key, identity);
        } 
    } 
 
    /** 
     * @see java.security.IdentityScope#removeIdentity(java.security.Identity)