fromMap static method
- Map<
String, dynamic> ? map, { - EnumMethod? enumMethod,
Gets a possible SslCertificate instance from a Map value.
Implementation
static SslCertificate? fromMap(
Map<String, dynamic>? map, {
EnumMethod? enumMethod,
}) {
if (map == null) {
return null;
}
X509Certificate? x509Certificate;
try {
x509Certificate = X509Certificate.fromData(data: map["x509Certificate"]);
} catch (e, stacktrace) {
print(e);
print(stacktrace);
}
SslCertificateDName? issuedBy = SslCertificateDName.fromMap(
map["issuedBy"]?.cast<String, dynamic>(),
enumMethod: enumMethod,
);
if (issuedBy == null && x509Certificate != null) {
issuedBy = SslCertificateDName(
CName:
x509Certificate.issuer(dn: ASN1DistinguishedNames.COMMON_NAME) ??
"",
DName: x509Certificate.issuerDistinguishedName ?? "",
OName:
x509Certificate.issuer(
dn: ASN1DistinguishedNames.ORGANIZATION_NAME,
) ??
"",
UName:
x509Certificate.issuer(
dn: ASN1DistinguishedNames.ORGANIZATIONAL_UNIT_NAME,
) ??
"",
);
}
SslCertificateDName? issuedTo = SslCertificateDName.fromMap(
map["issuedTo"]?.cast<String, dynamic>(),
enumMethod: enumMethod,
);
if (issuedTo == null && x509Certificate != null) {
issuedTo = SslCertificateDName(
CName:
x509Certificate.subject(dn: ASN1DistinguishedNames.COMMON_NAME) ??
"",
DName: x509Certificate.subjectDistinguishedName ?? "",
OName:
x509Certificate.subject(
dn: ASN1DistinguishedNames.ORGANIZATION_NAME,
) ??
"",
UName:
x509Certificate.subject(
dn: ASN1DistinguishedNames.ORGANIZATIONAL_UNIT_NAME,
) ??
"",
);
}
DateTime? validNotAfterDate = map["validNotAfterDate"] != null
? DateTime.fromMillisecondsSinceEpoch(map["validNotAfterDate"])
: x509Certificate?.notAfter;
DateTime? validNotBeforeDate = map["validNotBeforeDate"] != null
? DateTime.fromMillisecondsSinceEpoch(map["validNotBeforeDate"])
: x509Certificate?.notBefore;
return SslCertificate(
issuedBy: issuedBy,
issuedTo: issuedTo,
validNotAfterDate: validNotAfterDate,
validNotBeforeDate: validNotBeforeDate,
x509Certificate: x509Certificate,
);
}