Code example for X500Principal

Methods: getEncoded, toString

0
     * @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) {
            if (SecurityHelper.matchKeyPair(certificate.getPublicKey(), privateKey)) {
                return certificate;
            } 
        }