Esempio n. 1
0
        /// <inheritdoc/>
        public Task <IFactor> AddFactorAsync(string userId, AddHardwareFactorOptions hardwareFactorOptions, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (hardwareFactorOptions == null)
            {
                throw new ArgumentNullException(nameof(hardwareFactorOptions));
            }

            if (hardwareFactorOptions.Provider == null)
            {
                throw new ArgumentNullException(nameof(hardwareFactorOptions.Provider));
            }

            var verify = new VerifyFactorRequest
            {
                PassCode = hardwareFactorOptions.PassCode
            };

            var factor = new HardwareFactor
            {
                FactorType = FactorType.TokenHardware,
                Provider   = hardwareFactorOptions.Provider,
                Verify     = verify
            };

            return(AddFactorAsync(factor, userId, cancellationToken: cancellationToken));
        }
Esempio n. 2
0
        /// <inheritdoc/>
        public Task <IFactor> AddFactorAsync(string userId, AddTokenFactorOptions tokenFactorOptions, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (tokenFactorOptions == null)
            {
                throw new ArgumentNullException(nameof(tokenFactorOptions));
            }

            if (tokenFactorOptions.Provider == null)
            {
                throw new ArgumentNullException(nameof(tokenFactorOptions.Provider));
            }

            var profile = new TokenFactorProfile
            {
                CredentialId = tokenFactorOptions.CredentialId
            };

            var verify = new VerifyFactorRequest
            {
                PassCode     = tokenFactorOptions.PassCode,
                NextPassCode = tokenFactorOptions.NextPassCode
            };

            var factor = new TokenFactor
            {
                FactorType = FactorType.Token,
                Provider   = tokenFactorOptions.Provider,
                Profile    = profile,
                Verify     = verify
            };

            return(AddFactorAsync(factor, userId, cancellationToken: cancellationToken));
        }