예제 #1
0
  /**
   * Gets a boolean array representing bits of the KeyUsage extension.
   *
   * @throws IOException if failed to extract the KeyUsage extension value.
   * @see java.security.cert.X509Certificate#getKeyUsage
   */
  public static boolean[] getKeyUsage(X509Extension ext) throws IOException {
    DERBitString bits = (DERBitString) getExtensionObject(ext);

    // copied from X509CertificateObject
    byte[] bytes = bits.getBytes();
    int length = (bytes.length * 8) - bits.getPadBits();

    boolean[] keyUsage =
        new boolean[(length < DEFAULT_USAGE_LENGTH) ? DEFAULT_USAGE_LENGTH : length];

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

    return keyUsage;
  }
  public boolean[] getIssuerUniqueID() {
    DERBitString id = cert.getAcinfo().getIssuerUniqueID();

    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;
  }
 public ReasonFlags(DERBitString reasons) {
   super(reasons.getBytes(), reasons.getPadBits());
 }
예제 #4
0
 public boolean isSet(DERBitString bits) {
   byte[] bytes = bits.getBytes();
   int length = (bytes.length * 8) - bits.getPadBits();
   return (bit < length && ((bytes[bit / 8] & (0x80 >>> (bit % 8))) != 0));
 }