policies property

List<CertificatePolicy>? get policies

Implementation

List<CertificatePolicy>? get policies {
  if (valueAsBlock == null) {
    return null;
  }
  var subs = valueAsBlock!.subAtIndex(0)?.sub ?? <ASN1Object>[];

  List<CertificatePolicy> result = <CertificatePolicy>[];
  subs.forEach((sub) {
    var data = sub.subAtIndex(0)?.encoded;
    String? oid;
    if (data != null) {
      oid = ASN1DERDecoder.decodeOid(contentData: data.toList());
      if (oid == null) {
        return;
      }
    } else {
      return;
    }

    List<CertificatePolicyQualifier>? qualifiers;
    var subQualifiers = sub.subAtIndex(1);
    if (subQualifiers != null && subQualifiers.sub != null) {
      qualifiers = <CertificatePolicyQualifier>[];
      subQualifiers.sub!.forEach((sub) {
        var rawValue = sub.subAtIndex(0)?.encoded;
        String? oid;
        if (rawValue != null) {
          oid = ASN1DERDecoder.decodeOid(contentData: rawValue.toList());
          if (oid == null) {
            return;
          }
          var value = sub.subAtIndex(1)?.asString;
          qualifiers!.add(CertificatePolicyQualifier(oid: oid, value: value));
        }
      });
    }
    result.add(CertificatePolicy(oid: oid, qualifiers: qualifiers));
  });
  return result;
}