public OtpResult VerifyOtp(ValidateOtpInput input) { var decryptedOtpJsonObj = DecryptOtpJsonObject(input.Key); if (decryptedOtpJsonObj == null) { var errors = new List <OtpError> { ErrorDescriber.OtpIsInvalid() }; return(OtpResult.Fail(errors)); } var otpJsonObject = DeserializeOtpJsonObject(decryptedOtpJsonObj); if (otpJsonObject == null || !otpJsonObject.IsValid()) { var errors = new List <OtpError> { ErrorDescriber.OtpIsInvalid() }; return(OtpResult.Fail(errors)); } if (otpJsonObject.Issuer != Settings.Issuer) { var errors = new List <OtpError> { ErrorDescriber.OtpIsInvalid() }; return(OtpResult.Fail(errors)); } if (otpJsonObject.GeneratedFor != input.GeneratedFor) { var errors = new List <OtpError> { ErrorDescriber.OtpIsInvalid() }; return(OtpResult.Fail(errors)); } if (otpJsonObject.Password != input.Password) { var errors = new List <OtpError> { ErrorDescriber.OtpIsInvalid() }; return(OtpResult.Fail(errors)); } if (otpJsonObject.IsExpired()) { var errors = new List <OtpError> { ErrorDescriber.PasswordIsExpired() }; return(OtpResult.Fail(errors)); } return(OtpResult.Success()); }
public void UserOTP() { string otpsec; using (Authenticate a = new Authenticate("*****@*****.**")) using (OTPTool otp = new OTPTool()) { otpsec = otp.RandomiseSecret(); a.Set2FASecret(otpsec); } using (OTPTool otp = new OTPTool()) using (Authenticate a = new Authenticate("*****@*****.**")) { otp.SecretBase32 = otpsec; string otpinput = otp.OTPNow.ToString("D6"); OtpResult rslt = a.Validate2FA(otpinput); if (rslt != OtpResult.Success) { Trace.Write(otp.ToString()); } Assert.IsTrue(rslt == OtpResult.Success); } }
public FakeUi(OtpResult otp, OobResult oob) { _otp = otp; _oob = oob; }