ASN1AttributeTypeAndValue.fromSequence constructor
ASN1AttributeTypeAndValue.fromSequence(
- ASN1Sequence seq
Implementation
ASN1AttributeTypeAndValue.fromSequence(ASN1Sequence seq) {
if (seq.elements == null || seq.elements!.length != 2) {
throw ArgumentError('');
}
if (seq.elements!.elementAt(0) is! ASN1ObjectIdentifier) {
throw ArgumentError('Element at index 0 has to be ASN1ObjectIdentifier');
}
if (seq.elements!.elementAt(1) is ASN1TeletextString ||
seq.elements!.elementAt(1) is ASN1TeletextString ||
seq.elements!.elementAt(1) is ASN1UTF8String ||
seq.elements!.elementAt(1) is ASN1BMPString) {
// VALID TYPES
} else {
throw ArgumentError(
'Element at index 1 has to be ASN1TeletextString, ASN1TeletextString, ASN1UTF8String or ASN1BMPString');
}
type = seq.elements!.elementAt(0) as ASN1ObjectIdentifier;
value = seq.elements!.elementAt(1);
}