/// <summary> /// Initializes a new instance of <see cref="JwtVerifier"/>. /// </summary> /// <param name="accessTokenSigner">An instance of <see cref="IAccessTokenSigner"/> that is used to /// verify token signature.</param> /// <param name="apiPublicKey">Public Key which should be used to verify signatures</param> /// <param name="apiPublicKeyId">Id of public key which should be used to verify signatures</param> public JwtVerifier(IAccessTokenSigner accessTokenSigner, IPublicKey apiPublicKey, string apiPublicKeyId) { this.AccessTokenSigner = accessTokenSigner ?? throw new ArgumentNullException(nameof(accessTokenSigner)); this.ApiPublicKey = apiPublicKey ?? throw new ArgumentNullException(nameof(apiPublicKey)); if (string.IsNullOrWhiteSpace(apiPublicKeyId)) { throw new ArgumentNullException(nameof(apiPublicKeyId)); } this.ApiPublicKeyId = apiPublicKeyId; }
/// <summary> /// Initializes a new instance of <see cref="JwtGenerator"/>. /// </summary> /// <param name="appId">Application id. Take it on /// <see cref="https://dashboard.virgilsecurity.com"/></param> /// <param name="apiKey">Private Key which will be used for signing /// enerated access tokens. Take it on /// <see cref="https://dashboard.virgilsecurity.com/api-keys"/></param> /// <param name="apiPublicKeyId">Key Id of <see cref="apiKey"/>. /// Take it on <see cref="https://dashboard.virgilsecurity.com/api-keys"/> /// </param> /// <param name="lifeTime">Lifetime of generated tokens.</param> /// <param name="accessTokenSigner"> /// An instance of <see cref="IAccessTokenSigner"/> that is used to /// generate token signature using <see cref="apiKey"/>.</param> public JwtGenerator( string appId, IPrivateKey apiKey, string apiPublicKeyId, TimeSpan lifeTime, IAccessTokenSigner accessTokenSigner ) { this.AppId = appId; this.ApiKey = apiKey; this.LifeTime = lifeTime; this.ApiPublicKeyId = apiPublicKeyId; this.AccessTokenSigner = accessTokenSigner; }