Пример #1
0
        /// <summary>
        /// Create a <see cref="YotiClient"/>
        /// </summary>
        /// <param name="sdkId">The client SDK ID provided on the Yoti dashboard.</param>
        /// <param name="privateStreamKey">The private key file provided on the Yoti dashboard as a <see cref="StreamReader"/>.</param>
        public YotiClient(string sdkId, StreamReader privateStreamKey)
        {
            if (string.IsNullOrEmpty(sdkId))
            {
                throw new ArgumentNullException("sdkId");
            }

            if (privateStreamKey == null)
            {
                throw new ArgumentNullException("privateStreamKey");
            }

            _sdkId = sdkId;

            try
            {
                _keyPair = CryptoEngine.LoadRsaKey(privateStreamKey);
            }
            catch (Exception e)
            {
                throw new ArgumentException("Could not read private key file: Are you sure it is valid", e);
            }

            _yotiClientEngine = new YotiClientEngine(new HttpRequester());
        }
Пример #2
0
        /// <summary>
        /// Create a <see cref="YotiClient"/> with a specified <see cref="HttpClient"/>
        /// </summary>
        /// <param name="httpClient">Allows the specification of a HttpClient</param>
        /// <param name="sdkId">The client SDK ID provided on the Yoti Hub.</param>
        /// <param name="keyPair">The key pair from the Yoti Hub.</param>
        public YotiClient(HttpClient httpClient, string sdkId, AsymmetricCipherKeyPair keyPair)
        {
            Validation.NotNullOrEmpty(sdkId, nameof(sdkId));
            Validation.NotNull(keyPair, nameof(keyPair));

            _sdkId   = sdkId;
            _keyPair = keyPair;

            SetYotiApiUri();

            _yotiClientEngine = new YotiClientEngine(httpClient);
        }