Пример #1
0
        public void NullDynamicScenarioShouldThrowException()
        {
            YotiClient client = CreateYotiClient();

            var aggregateException = Assert.ThrowsException <AggregateException>(() =>
            {
                client.CreateShareUrl(null);
            });

            Assert.IsTrue(TestTools.Exceptions.IsExceptionInAggregateException <ArgumentNullException>(aggregateException));
        }
Пример #2
0
        public IActionResult DBSStandard()
        {
            try
            {
                string yotiKeyFilePath = Environment.GetEnvironmentVariable("YOTI_KEY_FILE_PATH");
                _logger.LogInformation(
                    string.Format(
                        "yotiKeyFilePath='{0}'",
                        yotiKeyFilePath));

                StreamReader privateKeyStream = System.IO.File.OpenText(yotiKeyFilePath);

                var yotiClient = new YotiClient(_clientSdkId, privateKeyStream);

                DynamicPolicy dynamicPolicy = new DynamicPolicyBuilder()
                                              .WithIdentityProfileRequirements(new
                {
                    trust_framework = "UK_TFIDA",
                    scheme          = new
                    {
                        type      = "DBS",
                        objective = "BASIC"
                    }
                }).Build();

                var dynamicScenario = new DynamicScenarioBuilder()
                                      .WithCallbackEndpoint("/account/connect")
                                      .WithPolicy(dynamicPolicy)
                                      .WithSubject(new
                {
                    subject_id = "some_subject_id_string"
                })
                                      .Build();
                ShareUrlResult shareUrlResult = yotiClient.CreateShareUrl(dynamicScenario);

                ViewBag.YotiClientSdkId = _clientSdkId;

                return(View("DBSCheck", shareUrlResult));
            }
            catch (Exception e)
            {
                _logger.LogError(
                    exception: e,
                    message: e.Message);

                TempData["Error"]          = e.Message;
                TempData["InnerException"] = e.InnerException?.Message;
                return(RedirectToAction("Error", "Account"));
            }
        }
Пример #3
0
        public IActionResult DynamicScenario()
        {
            try
            {
                string yotiKeyFilePath = Environment.GetEnvironmentVariable("YOTI_KEY_FILE_PATH");
                _logger.LogInformation(
                    string.Format(
                        "yotiKeyFilePath='{0}'",
                        yotiKeyFilePath));

                StreamReader privateKeyStream = System.IO.File.OpenText(yotiKeyFilePath);

                var yotiClient = new YotiClient(_clientSdkId, privateKeyStream);

                var givenNamesWantedAttribute = new WantedAttributeBuilder()
                                                .WithName("given_names")
                                                .Build();

                DynamicPolicy dynamicPolicy = new DynamicPolicyBuilder()
                                              .WithWantedAttribute(givenNamesWantedAttribute)
                                              .WithFullName()
                                              .WithSelfie()
                                              .WithPhoneNumber()
                                              .WithAgeOver(18)
                                              .WithRememberMeId(true)
                                              .Build();

                var dynamicScenario = new DynamicScenarioBuilder()
                                      .WithCallbackEndpoint("/account/connect")
                                      .WithPolicy(dynamicPolicy)
                                      .Build();
                ShareUrlResult shareUrlResult = yotiClient.CreateShareUrl(dynamicScenario);

                ViewBag.YotiClientSdkId = _clientSdkId;

                return(View("DynamicScenario", shareUrlResult));
            }
            catch (Exception e)
            {
                _logger.LogError(
                    exception: e,
                    message: e.Message);

                TempData["Error"]          = e.Message;
                TempData["InnerException"] = e.InnerException?.Message;
                return(RedirectToAction("Error", "Account"));
            }
        }