code: @SuppressWarnings("unchecked")
          public CertPathValidatorResult engineValidate(CertPath certPath, CertPathParameters params)
              throws CertPathValidatorException, InvalidAlgorithmParameterException {
  
          if (certPath == null) {
              throw new IllegalArgumentException(
                      "Certificate path cannot be null");
          }
  
                  List list = certPath.getCertificates();
          if (list.size() < 1) {
              throw new IllegalArgumentException(
                      "Certificate path cannot be empty");
          }
  
          parseParameters(params);
  
          // find the root trust anchor. Validate signatures and see if the
          // chain ends in one of the trust root certificates
          CertPath trustedCertPath = TrustedCertPathFinder.findTrustedCertPath(this.keyStore, certPath);
  
          // rest of the validation
          return validate(trustedCertPath);
      }
docs: Validates the specified certification path using the specified algorithm parameter set.
  <p>
  The <code>CertPath</code> specified must be of a type that is supported by the validation algorithm, otherwise
  an <code>InvalidAlgorithmParameterException</code> will be thrown. For example, a <code>CertPathValidator</code>
  that implements the PKIX algorithm validates <code>CertPath</code> objects of type X.509.
  
  @param certPath the <code>CertPath</code> to be validated
  @param params   the algorithm parameters
  @return the result of the validation algorithm
  @throws java.security.cert.CertPathValidatorException
  if the <code>CertPath</code> does not validate
  @throws java.security.InvalidAlgorithmParameterException
  if the specified parameters or the type of the
  specified <code>CertPath</code> are inappropriate for this <code>CertPathValidator</code>