Ejemplo n.º 1
0
        protected void Login_Click(object sender, EventArgs e)
        {
            try
            {
                if (Request.QueryString["InstitutionID"] == null)
                {
                    Response.Redirect("SelectInstitution.aspx");
                }
                AggregationCategorizationService svc = Services.AggCatService.GetService(Cache, HttpContext.Current.User.Identity.Name);
                InstitutionDetail insutitutionDetail = svc.GetInstitutionDetails(long.Parse(Request.QueryString["InstitutionID"]));
                InstitutionLogin  instLogin          = new InstitutionLogin();
                Credentials       creds       = new Credentials();
                List <Credential> credentials = new List <Credential>();
                foreach (Control control in LoginControls.Controls)
                {
                    if (control as TextBox != null)
                    {
                        Credential cred       = new Credential();
                        TextBox    loginValue = (TextBox)control;
                        cred.name  = loginValue.Attributes["KeyName"];
                        cred.value = loginValue.Text;
                        credentials.Add(cred);
                    }
                }
                creds.credential          = credentials.ToArray();
                instLogin.AnyIntuitObject = creds;

                Challenges       challenges       = null;
                ChallengeSession challengeSession = null;

                AccountList accountList = svc.DiscoverAndAddAccounts(long.Parse(Request.QueryString["InstitutionID"].ToString()), instLogin, out challenges, out challengeSession);
                Response.Redirect("MyAccounts.aspx?Success");
            }
            catch (Exception ex)
            {
                Master.ErrorMessage = "Error occurred while calling logging into the instituion: " + ex.Message;
            }
        }
        protected void Login_Click(object sender, EventArgs e)
        {
            try
            {
                if (Request.QueryString["InstitutionID"] == null) { Response.Redirect("SelectInstitution.aspx"); }
                AggregationCategorizationService svc = Services.AggCatService.GetService(Cache, HttpContext.Current.User.Identity.Name);
                InstitutionDetail insutitutionDetail = svc.GetInstitutionDetails(long.Parse(Request.QueryString["InstitutionID"]));
                InstitutionLogin instLogin = new InstitutionLogin();
                Credentials creds = new Credentials();
                List<Credential> credentials = new List<Credential>();
                foreach (Control control in LoginControls.Controls)
                {
                    if (control as TextBox != null)
                    {
                        Credential cred = new Credential();
                        TextBox loginValue = (TextBox)control;
                        cred.name = loginValue.Attributes["KeyName"];
                        cred.value = loginValue.Text;
                        credentials.Add(cred);
                    }
                }
                creds.credential = credentials.ToArray();
                instLogin.AnyIntuitObject = creds;

                Challenges challenges = null;
                ChallengeSession challengeSession = null;

                AccountList accountList = svc.DiscoverAndAddAccounts(long.Parse(Request.QueryString["InstitutionID"].ToString()), instLogin, out challenges, out challengeSession);
                Response.Redirect("MyAccounts.aspx?Success");
            }
            catch (Exception ex)
            {
                Master.ErrorMessage = "Error occurred while calling logging into the instituion: " + ex.Message;
            }
        }
        internal DiscoverAddModel DiscoverAndAdd(InstitutionModel institutionModel)
        {
            DiscoverAddModel discoverAddModel = new DiscoverAddModel();
            try
            {

                //Demo purposes only.  The OAuth tokens returned by the SAML assertion are valid for 1 hour and do not need to be requested before each API call.
                SamlRequestValidator validator = new SamlRequestValidator(AggCatAppSettings.Certificate,
                                                                          AggCatAppSettings.ConsumerKey,
                                                                          AggCatAppSettings.ConsumerSecret,
                                                                          AggCatAppSettings.SamlIdentityProviderId,
                                                                          AggCatAppSettings.CustomerId);
                ServiceContext ctx = new ServiceContext(validator);
                AggregationCategorizationService svc = new AggregationCategorizationService(ctx);

                InstitutionLogin instLogin = new InstitutionLogin();
                Credentials creds = new Credentials();
                List<Credential> credentials = new List<Credential>();
                Credential cred = new Credential();
                cred.name = institutionModel.InstitutionDetail.keys.FirstOrDefault(k => k.displayOrder == 1).name;
                cred.value = institutionModel.Value1;
                credentials.Add(cred);

                cred = new Credential();
                cred.name = institutionModel.InstitutionDetail.keys.FirstOrDefault(k => k.displayOrder == 2).name;
                cred.value = institutionModel.Value2;
                credentials.Add(cred);

                IEnumerable<InstitutionDetailKey> idk = institutionModel.InstitutionDetail.keys.Where(k => k.displayOrder != 1 && k.displayOrder != 2);
                foreach (InstitutionDetailKey item in idk)
                {
                    cred = new Credential();
                    cred.name = item.name;
                    cred.value = item.val;
                    credentials.Add(cred);
                }

                creds.credential = credentials.ToArray();
                instLogin.AnyIntuitObject = creds;

                Challenges challenges = null;
                ChallengeSession challengeSession = null;
                AccountList accountList = svc.DiscoverAndAddAccounts(institutionModel.InstitutionDetail.institutionId, instLogin, out challenges, out challengeSession);
                discoverAddModel.AccountList = accountList;
                discoverAddModel.Challenges = challenges;
                discoverAddModel.ChallengeSession = challengeSession;
                discoverAddModel.Success = true;
                discoverAddModel.Error = null;
                if (accountList == null && challenges != null)
                {
                    discoverAddModel.MFA = true;
                }
            }
            catch (AggregationCategorizationException ex)
            {
                discoverAddModel.AccountList = null;
                discoverAddModel.Challenges = null;
                discoverAddModel.ChallengeSession = null;
                discoverAddModel.Success = false;
                discoverAddModel.Error = ex.ToString();
            }

            return discoverAddModel;
        }
Ejemplo n.º 4
0
        internal DiscoverAddModel DiscoverAndAdd(InstitutionModel institutionModel)
        {
            DiscoverAddModel discoverAddModel = new DiscoverAddModel();

            try
            {
                //Demo purposes only.  The OAuth tokens returned by the SAML assertion are valid for 1 hour and do not need to be requested before each API call.
                SamlRequestValidator validator = new SamlRequestValidator(AggCatAppSettings.Certificate,
                                                                          AggCatAppSettings.ConsumerKey,
                                                                          AggCatAppSettings.ConsumerSecret,
                                                                          AggCatAppSettings.SamlIdentityProviderId,
                                                                          AggCatAppSettings.CustomerId);
                ServiceContext ctx = new ServiceContext(validator);
                AggregationCategorizationService svc = new AggregationCategorizationService(ctx);

                InstitutionLogin  instLogin   = new InstitutionLogin();
                Credentials       creds       = new Credentials();
                List <Credential> credentials = new List <Credential>();
                Credential        cred        = new Credential();
                cred.name  = institutionModel.InstitutionDetail.keys.FirstOrDefault(k => k.displayOrder == 1).name;
                cred.value = institutionModel.Value1;
                credentials.Add(cred);

                cred       = new Credential();
                cred.name  = institutionModel.InstitutionDetail.keys.FirstOrDefault(k => k.displayOrder == 2).name;
                cred.value = institutionModel.Value2;
                credentials.Add(cred);

                IEnumerable <InstitutionDetailKey> idk = institutionModel.InstitutionDetail.keys.Where(k => k.displayOrder != 1 && k.displayOrder != 2);
                foreach (InstitutionDetailKey item in idk)
                {
                    cred       = new Credential();
                    cred.name  = item.name;
                    cred.value = item.val;
                    credentials.Add(cred);
                }

                creds.credential          = credentials.ToArray();
                instLogin.AnyIntuitObject = creds;

                Challenges       challenges       = null;
                ChallengeSession challengeSession = null;
                AccountList      accountList      = svc.DiscoverAndAddAccounts(institutionModel.InstitutionDetail.institutionId, instLogin, out challenges, out challengeSession);
                discoverAddModel.AccountList      = accountList;
                discoverAddModel.Challenges       = challenges;
                discoverAddModel.ChallengeSession = challengeSession;
                discoverAddModel.Success          = true;
                discoverAddModel.Error            = null;
                if (accountList == null && challenges != null)
                {
                    discoverAddModel.MFA = true;
                }
            }
            catch (AggregationCategorizationException ex)
            {
                discoverAddModel.AccountList      = null;
                discoverAddModel.Challenges       = null;
                discoverAddModel.ChallengeSession = null;
                discoverAddModel.Success          = false;
                discoverAddModel.Error            = ex.ToString();
            }

            return(discoverAddModel);
        }