/** * Check if a {@link PublicKey} is trusted. * * @param publicKey the key to check. * @return {@code true} if this instance trusts the specified public key. */ public boolean isTrusted(PublicKey publicKey) { synchronized (publicKeys) { for (PublicKey k : publicKeys) { if (KeyUtils.equals(publicKey, k)) { return true; } } return false; } }
/** * Adds a trusted {@link PublicKey}. * * @param publicKey the key to trust. * @return {@code true} if this instance did not already trust the specified public key */ public boolean add(@Nonnull PublicKey publicKey) { synchronized (publicKeys) { for (PublicKey k : publicKeys) { if (KeyUtils.equals(publicKey, k)) { return false; } } publicKeys.add(publicKey); return true; } }
/** * Removes a trusted {@link PublicKey}. * * @param publicKey the key to trust. * @return {@code true} if this instance trusted the specified public key */ public boolean remove(PublicKey publicKey) { synchronized (publicKeys) { for (Iterator<PublicKey> iterator = publicKeys.iterator(); iterator.hasNext(); ) { PublicKey k = iterator.next(); if (KeyUtils.equals(publicKey, k)) { iterator.remove(); return true; } } return false; } }
return false; if (!KeyUtils.equals(publicKey, that.publicKey)) { return false;
@Override public void beforeProperties(@Nonnull JnlpConnectionState event) { if (event instanceof Jnlp4ConnectionState) { X509Certificate certificate = ((Jnlp4ConnectionState) event).getCertificate(); if (certificate != null) { String fingerprint = KeyUtils .fingerprint(certificate.getPublicKey()); if (!KeyUtils.equals(endpoint.getPublicKey(), certificate.getPublicKey())) { event.reject(new ConnectionRefusalException( "Expecting identity " + fingerprint)); } events.status("Remote identity confirmed: " + fingerprint); } } }