code: public int getBasicConstraints() {
          try {
              String extAlias = OIDMap.getName(PKIXExtensions.BasicConstraints_Id);
              if (extAlias == null)
                  return -1;
              BasicConstraintsExtension certExt =
                          (BasicConstraintsExtension)this.get(extAlias);
              if (certExt == null)
                  return -1;
  
              if (((Boolean)certExt.get(BasicConstraintsExtension.IS_CA)
                   ).booleanValue() == true)
                  return ((Integer)certExt.get(
                          BasicConstraintsExtension.PATH_LEN)).intValue();
              else
                  return -1;
          } catch (Exception e) {
              return -1;
          }
      }
docs: Get the certificate constraints path length from the
  the critical BasicConstraints extension, (oid = 2.5.29.19).
  @return the length of the constraint.