Code example for KeyManagementException

0
     */ 
    public synchronized void addIdentity(Identity identity)
            throws KeyManagementException { 
        if (identity == null) {
            throw new NullPointerException(Messages.getString("security.92")); //$NON-NLS-1$
        } 
 
        String name = identity.getName();
        if (names.containsKey(name)) {
            throw new KeyManagementException(Messages.getString("security.93", name)); //$NON-NLS-1$
        } 
 
        PublicKey key = identity.getPublicKey();
        if (key != null && keys.containsKey(key)) {
            throw new KeyManagementException(Messages.getString("security.94", key)); //$NON-NLS-1$
        } 
 
        names.put(name, identity);
        if (key != null) {
            keys.put(key, identity);
        }