getSubjectCountry method

String getSubjectCountry()

Gets the the country (C) of the certificate subject.

return The country (C) of the certificate subject. throws BiosealException An error has occurred during Bioseal Library execution.

Implementation

String getSubjectCountry() {
  Pointer<Char> pSubjectCountry = nullptr;
  Pointer<Int> pSubjectCountrySize = calloc.allocate(1);
  pSubjectCountrySize[0] = -1;
  try {
    var err = biosealSDK.id3BiosealCertificateInformation_GetSubjectCountry(_pHandle.value, pSubjectCountry, pSubjectCountrySize);
    if (err == BiosealError.insufficientBuffer.value) {
      pSubjectCountry = calloc.allocate(pSubjectCountrySize.value);
      err = biosealSDK.id3BiosealCertificateInformation_GetSubjectCountry(_pHandle.value, pSubjectCountry, pSubjectCountrySize);
      if (err != BiosealError.success.value) {
        throw BiosealException(err);
      }
    }
    final vSubjectCountry = utf8.decode(Uint8List.fromList(pSubjectCountry.cast<Uint8>().asTypedList(pSubjectCountrySize.value)));
    return vSubjectCountry;
  } finally {
    calloc.free(pSubjectCountry);
    calloc.free(pSubjectCountrySize);
  }
}