iosWebViewFix/lib/src/X509Certificate/key_usage.dart

57 lines
1.6 KiB
Dart
Raw Normal View History

2020-06-15 22:25:29 +00:00
class KeyUsage {
final int _value;
const KeyUsage._internal(this._value);
static final Set<KeyUsage> values = [
2020-06-15 22:25:29 +00:00
KeyUsage.digitalSignature,
KeyUsage.nonRepudiation,
KeyUsage.keyEncipherment,
KeyUsage.dataEncipherment,
KeyUsage.keyAgreement,
KeyUsage.keyCertSign,
KeyUsage.cRLSign,
KeyUsage.encipherOnly,
KeyUsage.decipherOnly,
].toSet();
2020-06-15 22:25:29 +00:00
static KeyUsage fromIndex(int value) {
2020-06-21 22:09:35 +00:00
return KeyUsage.values.firstWhere((element) => element.toValue() == value,
orElse: () => null);
2020-06-15 22:25:29 +00:00
}
int toValue() => _value;
String name() => _KeyUsageMapName[this._value];
@override
String toString() => "($_value, ${name()})";
static const digitalSignature = const KeyUsage._internal(0);
static const nonRepudiation = const KeyUsage._internal(1);
static const keyEncipherment = const KeyUsage._internal(2);
static const dataEncipherment = const KeyUsage._internal(3);
static const keyAgreement = const KeyUsage._internal(4);
static const keyCertSign = const KeyUsage._internal(5);
static const cRLSign = const KeyUsage._internal(6);
static const encipherOnly = const KeyUsage._internal(7);
static const decipherOnly = const KeyUsage._internal(8);
bool operator ==(value) => value == _value;
@override
int get hashCode => _value.hashCode;
static const Map<int, String> _KeyUsageMapName = {
0: "digitalSignature",
1: "nonRepudiation",
2: "keyEncipherment",
3: "dataEncipherment",
4: "keyAgreement",
5: "keyCertSign",
6: "cRLSign",
7: "encipherOnly",
8: "decipherOnly",
};
}