JsonWebKey.fromJson constructor

JsonWebKey.fromJson(
  1. Map<String, dynamic> json
)

Constructs a JsonWebKey from its JSON representation

Implementation

JsonWebKey.fromJson(Map<String, dynamic> json)
    : _keyPair = KeyPair.fromJwk(json),
      super.from(json) {
  if (json['kty'] == null) throw ArgumentError.notNull('keyType');
  if (x509CertificateChain != null && x509CertificateChain!.isNotEmpty) {
    var cert = x509CertificateChain!.first;

    if (_keyPair.publicKey != cert.publicKey) {
      throw ArgumentError("The public key in 'x5c' does not match this key.");
    }
  }
}