/** * Determines the certificate, from the collection, associated with the private key. * * @param certs certificates to check * @param privateKey entity's private key * * @return the certificate associated with entity's private key or null if not certificate in the collection is * associated with the given private key * * @throws SecurityException thrown if the public or private keys checked are of an unsupported type * * @since 1.2 */ public static X509Certificate determineEntityCertificate(Collection<X509Certificate> certs, PrivateKey privateKey) throws SecurityException { if (certs == null || privateKey == null) { return null; } for (X509Certificate certificate : certs) { try { if (SecurityHelper.matchKeyPair(certificate.getPublicKey(), privateKey)) { return certificate; } } catch (SecurityException e) { // An exception here is just a false match. // Java 7 apparently throws in this case. } } return null; }
/** * Determines the certificate, from the collection, associated with the private key. * * @param certs certificates to check * @param privateKey entity's private key * * @return the certificate associated with entity's private key or null if not certificate in the collection is * associated with the given private key * * @throws SecurityException thrown if the public or private keys checked are of an unsupported type * * @since 1.2 */ public static X509Certificate determineEntityCertificate(Collection<X509Certificate> certs, PrivateKey privateKey) throws SecurityException { if (certs == null || privateKey == null) { return null; } for (X509Certificate certificate : certs) { try { if (SecurityHelper.matchKeyPair(certificate.getPublicKey(), privateKey)) { return certificate; } } catch (SecurityException e) { // An exception here is just a false match. // Java 7 apparently throws in this case. } } return null; }
boolean matched = false; try { matched = SecurityHelper.matchKeyPair(credential.getPublicKey(), credential.getPrivateKey()); } catch (SecurityException e) { log.warn("Could not perform sanity check against credential public and private key: {}",
boolean matched = false; try { matched = SecurityHelper.matchKeyPair(credential.getPublicKey(), credential.getPrivateKey()); } catch (SecurityException e) { log.warn("Could not perform sanity check against credential public and private key: {}",