code: public static GSIConstants.CertificateType getCertificateType(X509Certificate cert, CertStore trustedCerts)
      throws CertificateException {
          try {
              TBSCertificateStructure crt = getTBSCertificateStructure(cert);
              GSIConstants.CertificateType type = getCertificateType(crt);
  
              // check subject of the cert in trusted cert list
              // to make sure the cert is not a ca cert
              if (type == GSIConstants.CertificateType.EEC) {
                  X509CertSelector selector = new X509CertSelector();
                  selector.setSubject(cert.getSubjectX500Principal());
                  Collection c = trustedCerts.getCertificates(selector);
                  if (c != null && c.size() > 0) {
                      type = GSIConstants.CertificateType.CA;
                  }
              }
              return type;
          } catch (Exception e) {
              // but this should not happen
              throw new CertificateException("", e);
          }
      }
docs: Returns the certificate type of the given certificate.
  Please see {@link #getCertificateType(TBSCertificateStructure,
  TrustedCertificates) getCertificateType} for details for
  determining the certificate type.
  
  @param cert the certificate to get the type of.
  @param trustedCerts the trusted certificates to double check the
  {@link GSIConstants#EEC GSIConstants.EEC}
  certificate against.
  @return the certificate type as determined by
  {@link #getCertificateType(TBSCertificateStructure,
  TrustedCertificates) getCertificateType}.
  @exception CertificateException if something goes wrong.