/// <summary> /// Intializes a new instance of the <see cref="TwoFactorAuth"/> class. /// </summary> /// <param name="issuer">The issuer of the TOTP authentication token.</param> /// <param name="digits">The number of digits to be displayed to the user / required for verification.</param> /// <param name="period">The period, specified in seconds, a TOTP is valid.</param> /// <param name="algorithm">The algorithm to use when generating TOTP codes.</param> /// <param name="qrcodeprovider">The <see cref="IQrCodeProvider"/> to use for generating QR codes.</param> /// <param name="rngprovider">The <see cref="IRngProvider"/> to use for generating sequences of random numbers.</param> /// <param name="timeprovider">The <see cref="ITimeProvider"/> to use for generating sequences of random numbers.</param> /// <exception cref="ArgumentOutOfRangeException"> /// Thrown when <paramref name="digits"/> or <paramref name="period"/> are less than 0 or the specified /// <paramref name="algorithm"/> is invalid. /// </exception> public TwoFactorAuth( string issuer = null, int digits = DEFAULTDIGITS, int period = DEFAULTPERIOD, Algorithm algorithm = Algorithm.SHA1, IQrCodeProvider qrcodeprovider = null, IRngProvider rngprovider = null, ITimeProvider timeprovider = null) { Issuer = issuer; if (digits <= 0) { throw new ArgumentOutOfRangeException(nameof(digits)); } Digits = digits; if (period <= 0) { throw new ArgumentOutOfRangeException(nameof(period)); } Period = period; if (!Enum.IsDefined(typeof(Algorithm), algorithm)) { throw new ArgumentOutOfRangeException(nameof(algorithm)); } Algorithm = algorithm; QrCodeProvider = qrcodeprovider ?? DefaultProviders.DefaultQrCodeProvider; RngProvider = rngprovider ?? DefaultProviders.DefaultRngProvider; TimeProvider = timeprovider ?? DefaultProviders.DefaultTimeProvider; }
/// <summary> /// Intializes a new instance of the <see cref="TwoFactorAuth"/> class. /// </summary> /// <param name="issuer">The issuer of the TOTP authentication token.</param> /// <param name="digits">The number of digits to be displayed to the user / required for verification.</param> /// <param name="period">The period, specified in seconds, a TOTP is valid.</param> /// <param name="algorithm">The algorithm to use when generating TOTP codes.</param> /// <param name="qrcodeprovider">The <see cref="IQrCodeProvider"/> to use for generating QR codes.</param> /// <param name="rngprovider">The <see cref="IRngProvider"/> to use for generating sequences of random numbers.</param> /// <exception cref="ArgumentOutOfRangeException"> /// Thrown when <paramref name="digits"/> or <paramref name="period"/> are less than 0 or the specified /// <paramref name="algorithm"/> is invalid. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when the specified <paramref name="qrcodeprovider"/> or <paramref name="rngprovider"/> is null. /// </exception> public TwoFactorAuth(string issuer, int digits, int period, Algorithm algorithm, IQrCodeProvider qrcodeprovider, IRngProvider rngprovider) { this.Issuer = issuer; if (digits <= 0) { throw new ArgumentOutOfRangeException("digits"); } this.Digits = digits; if (period <= 0) { throw new ArgumentOutOfRangeException("period"); } this.Period = period; if (!Enum.IsDefined(typeof(Algorithm), algorithm)) { throw new ArgumentOutOfRangeException("algorithm"); } this.Algorithm = algorithm; if (qrcodeprovider == null) { throw new ArgumentNullException("qrcodeprovider"); } this.QrCodeProvider = qrcodeprovider; if (rngprovider == null) { throw new ArgumentNullException("rngprovider"); } this.RngProvider = rngprovider; }
/// <summary> /// Intializes a new instance of the <see cref="TwoFactorAuth"/> class. /// </summary> /// <param name="issuer">The issuer of the TOTP authentication token.</param> /// <param name="digits">The number of digits to be displayed to the user / required for verification.</param> /// <param name="period">The period, specified in seconds, a TOTP is valid.</param> /// <param name="algorithm">The algorithm to use when generating TOTP codes.</param> /// <param name="qrcodeprovider">The <see cref="IQrCodeProvider"/> to use for generating QR codes.</param> /// <param name="rngprovider">The <see cref="IRngProvider"/> to use for generating sequences of random numbers.</param> /// <exception cref="ArgumentOutOfRangeException"> /// Thrown when <paramref name="digits"/> or <paramref name="period"/> are less than 0 or the specified /// <paramref name="algorithm"/> is invalid. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when the specified <paramref name="qrcodeprovider"/> or <paramref name="rngprovider"/> is null. /// </exception> public TwoFactorAuth(string issuer, int digits, int period, Algorithm algorithm, IQrCodeProvider qrcodeprovider, IRngProvider rngprovider) { this.Issuer = issuer; if (digits <= 0) throw new ArgumentOutOfRangeException("digits"); this.Digits = digits; if (period <= 0) throw new ArgumentOutOfRangeException("period"); this.Period = period; if (!Enum.IsDefined(typeof(Algorithm), algorithm)) throw new ArgumentOutOfRangeException("algorithm"); this.Algorithm = algorithm; if (qrcodeprovider == null) throw new ArgumentNullException("qrcodeprovider"); this.QrCodeProvider = qrcodeprovider; if (rngprovider == null) throw new ArgumentNullException("rngprovider"); this.RngProvider = rngprovider; }
/// <summary> /// Intializes a new instance of the <see cref="TwoFactorAuth"/> class. /// </summary> /// <param name="issuer">The issuer of the TOTP authentication token.</param> /// <param name="algorithm">The algorithm to use when generating TOTP codes.</param> /// <param name="qrcodeprovider">The <see cref="IQrCodeProvider"/> to use for generating QR codes.</param> /// <param name="rngprovider">The <see cref="IRngProvider"/> to use for generating sequences of random numbers.</param> /// <exception cref="ArgumentOutOfRangeException"> /// Thrown when the specified <paramref name="algorithm"/> is invalid. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when the specified <paramref name="qrcodeprovider"/> or <paramref name="rngprovider"/> is null. /// </exception> public TwoFactorAuth(string issuer, Algorithm algorithm, IQrCodeProvider qrcodeprovider, IRngProvider rngprovider) : this(issuer, DEFAULTDIGITS, DEFAULTPERIOD, algorithm, qrcodeprovider, rngprovider) { }
/// <summary> /// Intializes a new instance of the <see cref="TwoFactorAuth"/> class. /// </summary> /// <param name="issuer">The issuer of the TOTP authentication token.</param> /// <param name="algorithm">The algorithm to use when generating TOTP codes.</param> /// <param name="rngprovider">The <see cref="IRngProvider"/> to use for generating sequences of random numbers.</param> /// <exception cref="ArgumentOutOfRangeException"> /// Thrown when the specified <paramref name="algorithm"/> is invalid. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when the specified <paramref name="rngprovider"/> is null. /// </exception> public TwoFactorAuth(string issuer, Algorithm algorithm, IRngProvider rngprovider) : this(issuer, DEFAULTDIGITS, DEFAULTPERIOD, algorithm, DefaultProviders.DefaultQrCodeProvider, rngprovider) { }
/// <summary> /// Intializes a new instance of the <see cref="TwoFactorAuth"/> class. /// </summary> /// <param name="issuer">The issuer of the TOTP authentication token.</param> /// <param name="qrcodeprovider">The <see cref="IQrCodeProvider"/> to use for generating QR codes.</param> /// <param name="rngprovider">The <see cref="IRngProvider"/> to use for generating sequences of random numbers.</param> /// <exception cref="ArgumentNullException"> /// Thrown when the specified <paramref name="rngprovider"/> is null. /// </exception> public TwoFactorAuth(string issuer, IQrCodeProvider qrcodeprovider, IRngProvider rngprovider) : this(issuer, DEFAULTDIGITS, DEFAULTPERIOD, DEFAULTALGORITHM, qrcodeprovider, rngprovider) { }
/// <summary> /// Intializes a new instance of the <see cref="TwoFactorAuth"/> class. /// </summary> /// <param name="issuer">The issuer of the TOTP authentication token.</param> /// <param name="rngprovider">The <see cref="IRngProvider"/> to use for generating sequences of random numbers.</param> /// <exception cref="ArgumentNullException"> /// Thrown when the specified <paramref name="rngprovider"/> is null. /// </exception> public TwoFactorAuth(string issuer, IRngProvider rngprovider) : this(issuer, DEFAULTDIGITS, DEFAULTPERIOD, DEFAULTALGORITHM, DefaultProviders.DefaultQrCodeProvider, rngprovider) { }
/// <summary> /// Intializes a new instance of the <see cref="TwoFactorAuth"/> class. /// </summary> /// <param name="issuer">The issuer of the TOTP authentication token.</param> /// <param name="algorithm">The algorithm to use when generating TOTP codes.</param> /// <param name="qrcodeprovider">The <see cref="IQrCodeProvider"/> to use for generating QR codes.</param> /// <param name="rngprovider">The <see cref="IRngProvider"/> to use for generating sequences of random numbers.</param> /// <exception cref="ArgumentOutOfRangeException"> /// Thrown when the specified <paramref name="algorithm"/> is invalid. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when the specified <paramref name="qrcodeprovider"/> or <paramref name="rngprovider"/> is null. /// </exception> public TwoFactorAuth(string issuer, Algorithm algorithm, IQrCodeProvider qrcodeprovider, IRngProvider rngprovider) : this(issuer, DEFAULTDIGITS, DEFAULTPERIOD, algorithm, qrcodeprovider, rngprovider) { }
/// <summary> /// Intializes a new instance of the <see cref="TwoFactorAuth"/> class. /// </summary> /// <param name="issuer">The issuer of the TOTP authentication token.</param> /// <param name="algorithm">The algorithm to use when generating TOTP codes.</param> /// <param name="rngprovider">The <see cref="IRngProvider"/> to use for generating sequences of random numbers.</param> /// <exception cref="ArgumentOutOfRangeException"> /// Thrown when the specified <paramref name="algorithm"/> is invalid. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when the specified <paramref name="rngprovider"/> is null. /// </exception> public TwoFactorAuth(string issuer, Algorithm algorithm, IRngProvider rngprovider) : this(issuer, DEFAULTDIGITS, DEFAULTPERIOD, algorithm, DefaultProviders.DefaultQrCodeProvider, rngprovider) { }
/// <summary> /// Intializes a new instance of the <see cref="TwoFactorAuth"/> class. /// </summary> /// <param name="issuer">The issuer of the TOTP authentication token.</param> /// <param name="qrcodeprovider">The <see cref="IQrCodeProvider"/> to use for generating QR codes.</param> /// <param name="rngprovider">The <see cref="IRngProvider"/> to use for generating sequences of random numbers.</param> /// <exception cref="ArgumentNullException"> /// Thrown when the specified <paramref name="rngprovider"/> is null. /// </exception> public TwoFactorAuth(string issuer, IQrCodeProvider qrcodeprovider, IRngProvider rngprovider) : this(issuer, DEFAULTDIGITS, DEFAULTPERIOD, DEFAULTALGORITHM, qrcodeprovider, rngprovider) { }
/// <summary> /// Intializes a new instance of the <see cref="TwoFactorAuth"/> class. /// </summary> /// <param name="issuer">The issuer of the TOTP authentication token.</param> /// <param name="rngprovider">The <see cref="IRngProvider"/> to use for generating sequences of random numbers.</param> /// <exception cref="ArgumentNullException"> /// Thrown when the specified <paramref name="rngprovider"/> is null. /// </exception> public TwoFactorAuth(string issuer, IRngProvider rngprovider) : this(issuer, DEFAULTDIGITS, DEFAULTPERIOD, DEFAULTALGORITHM, DefaultProviders.DefaultQrCodeProvider, rngprovider) { }