code: private void verifyNameChaining(X509Certificate cert)
          throws CertPathValidatorException
      {
          if (prevSubject != null) {
  
              String msg = "subject/issuer name chaining";
              if (debug != null)
                  debug.println("---checking " + msg + "...");
  
              X500Principal currIssuer = cert.getIssuerX500Principal();
  
              // reject null or empty issuer DNs
              if (X500Name.asX500Name(currIssuer).isEmpty()) {
                  throw new CertPathValidatorException
                      (msg + " check failed: " +
                       "empty/null issuer DN in certificate is invalid", null,
                       null, -1, PKIXReason.NAME_CHAINING);
              }
  
              if (!(currIssuer.equals(prevSubject))) {
                  throw new CertPathValidatorException
                      (msg + " check failed", null, null, -1,
                       PKIXReason.NAME_CHAINING);
              }
  
              if (debug != null)
                  debug.println(msg + " verified.");
          }
      }
docs: Internal method to check that cert has a valid DN to be next in a chain