getSubjectDistinguishedName method

String getSubjectDistinguishedName()

Gets the the subject distinguished (DN) name of the certificate.

return The subject distinguished (DN) name of the certificate. throws BiosealException An error has occurred during Bioseal Library execution.

Implementation

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