code: public static int decodeInteger(ByteBuffer buf) {
          DerId id = DerId.decode(buf);
          if (!id.matches(DerId.TagClass.UNIVERSAL, DerId.EncodingType.PRIMITIVE, ASN1_INTEGER_TAG_NUM)) {
              throw new IllegalArgumentException("Expected INTEGER identifier, received " + id);
          }
          int len = DerUtils.decodeLength(buf);
          if (buf.remaining() < len) {
              throw new IllegalArgumentException("Insufficient content for INTEGER");
          }
          int value = 0;
          for (int i = 0; i < len; i++) {
              value = (value << 8) + (0xff & buf.get());
          }
          return value;
      }
docs: Decode an ASN.1 INTEGER.
  
  @param buf
  the buffer containing the DER-encoded INTEGER
  @return the value of the INTEGER