public boolean match(Certificate cert) {
    if (!(cert instanceof X509Certificate)) {
      return false;
    }

    X509Certificate x509Cert = (X509Certificate) cert;

    try {
      if (holder.getBaseCertificateID() != null) {
        return holder
                .getBaseCertificateID()
                .getSerial()
                .getValue()
                .equals(x509Cert.getSerialNumber())
            && matchesDN(
                PrincipalUtil.getIssuerX509Principal(x509Cert),
                holder.getBaseCertificateID().getIssuer());
      }

      if (holder.getEntityName() != null) {
        if (matchesDN(PrincipalUtil.getSubjectX509Principal(x509Cert), holder.getEntityName())) {
          return true;
        }
      }
      if (holder.getObjectDigestInfo() != null) {
        MessageDigest md = null;
        try {
          md = MessageDigest.getInstance(getDigestAlgorithm(), "DFBC");

        } catch (Exception e) {
          return false;
        }
        switch (getDigestedObjectType()) {
          case ObjectDigestInfo.publicKey:
            // TODO: DSA Dss-parms
            md.update(cert.getPublicKey().getEncoded());
            break;
          case ObjectDigestInfo.publicKeyCert:
            md.update(cert.getEncoded());
            break;
        }
        if (!Arrays.areEqual(md.digest(), getObjectDigest())) {
          return false;
        }
      }
    } catch (CertificateEncodingException e) {
      return false;
    }

    return false;
  }
  public AttributeCertificateHolder(X509Certificate cert) throws CertificateParsingException {
    X509Principal name;

    try {
      name = PrincipalUtil.getIssuerX509Principal(cert);
    } catch (Exception e) {
      throw new CertificateParsingException(e.getMessage());
    }

    holder =
        new Holder(
            new IssuerSerial(generateGeneralNames(name), new DERInteger(cert.getSerialNumber())));
  }