コード例 #1
0
  public x509certificateobject(org.ripple.bouncycastle.asn1.x509.certificate c)
      throws certificateparsingexception {
    this.c = c;

    try {
      byte[] bytes = this.getextensionbytes("2.5.29.19");

      if (bytes != null) {
        basicconstraints = basicconstraints.getinstance(asn1primitive.frombytearray(bytes));
      }
    } catch (exception e) {
      throw new certificateparsingexception("cannot construct basicconstraints: " + e);
    }

    try {
      byte[] bytes = this.getextensionbytes("2.5.29.15");
      if (bytes != null) {
        derbitstring bits = derbitstring.getinstance(asn1primitive.frombytearray(bytes));

        bytes = bits.getbytes();
        int length = (bytes.length * 8) - bits.getpadbits();

        keyusage = new boolean[(length < 9) ? 9 : length];

        for (int i = 0; i != length; i++) {
          keyusage[i] = (bytes[i / 8] & (0x80 >>> (i % 8))) != 0;
        }
      } else {
        keyusage = null;
      }
    } catch (exception e) {
      throw new certificateparsingexception("cannot construct keyusage: " + e);
    }
  }
コード例 #2
0
  public boolean[] getsubjectuniqueid() {
    derbitstring id = c.gettbscertificate().getsubjectuniqueid();

    if (id != null) {
      byte[] bytes = id.getbytes();
      boolean[] boolid = new boolean[bytes.length * 8 - id.getpadbits()];

      for (int i = 0; i != boolid.length; i++) {
        boolid[i] = (bytes[i / 8] & (0x80 >>> (i % 8))) != 0;
      }

      return boolid;
    }

    return null;
  }