예제 #1
0
        public Identity(IIdentity identity)
        {
            if (identity == null)
            {
                throw new ArgumentNullException("identity");
            }

            ClrType = identity.GetType().FullName;

            if (!identity.IsAuthenticated)
            {
                IsAuthenticated = false;
                return;
            }

            Name = identity.Name;
            AuthenticationType = identity.AuthenticationType;
            IsAuthenticated = true;

            var claimsIdentity = identity as ClaimsIdentity;
            if (claimsIdentity != null)
            {
                Claims = new Claims();
                claimsIdentity.Claims.ToList().ForEach(c => Claims.Add(new Claim
                            {
                                ClaimType = c.ClaimType,
                                Value = c.Value,
                                Issuer = c.Issuer,
                                OriginalIssuer = c.OriginalIssuer
                            }));
            }
        }
예제 #2
0
        public virtual void RemoveClaim([NotNull] Claim claim)
        {
            Check.NotNull(claim, nameof(claim));

            Claims.RemoveAll(c => c.ClaimValue == claim.Value && c.ClaimType == claim.Type);
        }
예제 #3
0
 //see method
 private void ShowAClaim(Claims claim)
 {
     Console.WriteLine($"{claim.ClaimId,-4} {claim.TypeOfClaim,-6} {claim.Description,-25} {claim.ClaimAmount,-11}{claim.DateOfIncident.ToString("MM/dd/yyyy"),-16} {claim.DateOfClaim.ToString("MM/dd/yyyy"),-20} {claim.IsValid,-4}");
 }
예제 #4
0
        private static void AddMicrosoftIdentityWebApiImplementation(
            AuthenticationBuilder builder,
            Action <JwtBearerOptions> configureJwtBearerOptions,
            Action <MicrosoftIdentityOptions> configureMicrosoftIdentityOptions,
            string jwtBearerScheme,
            bool subscribeToJwtBearerMiddlewareDiagnosticsEvents)
        {
            builder.AddJwtBearer(jwtBearerScheme, configureJwtBearerOptions);
            builder.Services.Configure(jwtBearerScheme, configureMicrosoftIdentityOptions);

            builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton <IValidateOptions <MicrosoftIdentityOptions>, MicrosoftIdentityOptionsValidation>());
            builder.Services.AddHttpContextAccessor();
            builder.Services.AddHttpClient();
            builder.Services.TryAddSingleton <MicrosoftIdentityIssuerValidatorFactory>();
            builder.Services.AddOptions <AadIssuerValidatorOptions>();

            if (subscribeToJwtBearerMiddlewareDiagnosticsEvents)
            {
                builder.Services.AddSingleton <IJwtBearerMiddlewareDiagnostics, JwtBearerMiddlewareDiagnostics>();
            }

            // Change the authentication configuration to accommodate the Microsoft identity platform endpoint (v2.0).
            builder.Services.AddOptions <JwtBearerOptions>(jwtBearerScheme)
            .Configure <IServiceProvider, IOptionsMonitor <MicrosoftIdentityOptions> >((options, serviceProvider, microsoftIdentityOptionsMonitor) =>
            {
                var microsoftIdentityOptions = microsoftIdentityOptionsMonitor.Get(jwtBearerScheme);

                if (string.IsNullOrWhiteSpace(options.Authority))
                {
                    options.Authority = AuthorityHelpers.BuildAuthority(microsoftIdentityOptions);
                }

                // This is a Microsoft identity platform web API
                options.Authority = AuthorityHelpers.EnsureAuthorityIsV2(options.Authority);

                if (options.TokenValidationParameters.AudienceValidator == null &&
                    options.TokenValidationParameters.ValidAudience == null &&
                    options.TokenValidationParameters.ValidAudiences == null)
                {
                    RegisterValidAudience registerAudience = new RegisterValidAudience();
                    registerAudience.RegisterAudienceValidation(
                        options.TokenValidationParameters,
                        microsoftIdentityOptions);
                }

                // If the developer registered an IssuerValidator, do not overwrite it
                if (options.TokenValidationParameters.ValidateIssuer && options.TokenValidationParameters.IssuerValidator == null)
                {
                    // Instead of using the default validation (validating against a single tenant, as we do in line of business apps),
                    // we inject our own multi-tenant validation logic (which even accepts both v1.0 and v2.0 tokens)
                    MicrosoftIdentityIssuerValidatorFactory microsoftIdentityIssuerValidatorFactory =
                        serviceProvider.GetRequiredService <MicrosoftIdentityIssuerValidatorFactory>();

                    options.TokenValidationParameters.IssuerValidator =
                        microsoftIdentityIssuerValidatorFactory.GetAadIssuerValidator(options.Authority).Validate;
                }

                // If you provide a token decryption certificate, it will be used to decrypt the token
                if (microsoftIdentityOptions.TokenDecryptionCertificates != null)
                {
                    options.TokenValidationParameters.TokenDecryptionKey =
                        new X509SecurityKey(DefaultCertificateLoader.LoadFirstCertificate(microsoftIdentityOptions.TokenDecryptionCertificates));
                }

                if (options.Events == null)
                {
                    options.Events = new JwtBearerEvents();
                }

                // When an access token for our own web API is validated, we add it to MSAL.NET's cache so that it can
                // be used from the controllers.
                var tokenValidatedHandler       = options.Events.OnTokenValidated;
                options.Events.OnTokenValidated = async context =>
                {
                    if (!microsoftIdentityOptions.AllowWebApiToBeAuthorizedByACL && !context !.Principal !.Claims.Any(x => x.Type == ClaimConstants.Scope) &&
                        !context !.Principal !.Claims.Any(y => y.Type == ClaimConstants.Scp) &&
                        !context !.Principal !.Claims.Any(y => y.Type == ClaimConstants.Roles) &&
                        !context !.Principal !.Claims.Any(y => y.Type == ClaimConstants.Role))
                    {
                        throw new UnauthorizedAccessException(IDWebErrorMessage.NeitherScopeOrRolesClaimFoundInToken);
                    }

                    await tokenValidatedHandler(context).ConfigureAwait(false);
                };

                if (subscribeToJwtBearerMiddlewareDiagnosticsEvents)
                {
                    var diagnostics = serviceProvider.GetRequiredService <IJwtBearerMiddlewareDiagnostics>();

                    diagnostics.Subscribe(options.Events);
                }
            });
        }
예제 #5
0
        public IList <Claim> GetClaims()
        {
            EnsureClaims();

            return(Claims.Select(x => new Claim(x.Key, x.Value)).ToList());
        }
예제 #6
0
 public HttpStatusCode Delete(long id)
 {
     Products.DeleteProduct(Claims.GetConnectionString(User), id);
     return(HttpStatusCode.OK);
 }
예제 #7
0
 public List <Product> Get()
 {
     return(Products.GetProducts(Claims.GetConnectionString(User)));
 }
예제 #8
0
 public virtual void RemoveClaim(string value, string type)
 {
     Claims.RemoveAll(c => c.Value == value && c.Type == type);
 }
예제 #9
0
 internal void AddClaim(Claim claim)
 {
     Claims.Add(claim);
 }
예제 #10
0
        //public void VersionClaimTypes()
        //{
        //    AllVersionClaims = new List<string>
        //    {
        //        "CanViewVersions",
        //        "CanAddVersions",
        //        "CanEditVersions",
        //        "CanDeleteVersions"
        //    };
        //}

        public async Task <IActionResult> OnGetAsync()
        {
            List <RoleClaim> roleClaims = new List <RoleClaim>();
            List <RoleClaim> userClaims = new List <RoleClaim>();
            //List<RoleClaim> versionClaims = new List<RoleClaim>();
            var RoleToUpdate = TempData["UpdateRole"].ToString();

            GetRole = await _roleManager.FindByIdAsync(RoleToUpdate);

            Claims = await _roleManager.GetClaimsAsync(GetRole) as List <Claim>;

            RoleClaimTypes();
            UserClaimTypes();
            //VersionClaimTypes();

            foreach (var claim in AllRoleClaims)
            {
                if (claim.Contains("Roles"))
                {
                    /////
                    if (Claims.Exists(x => x.Type == claim))
                    {
                        RoleClaim newClaim = new RoleClaim
                        {
                            claim    = claim,
                            Selected = true
                        };
                        roleClaims.Add(newClaim);
                    }
                    else
                    {
                        RoleClaim newClaim = new RoleClaim
                        {
                            claim    = claim,
                            Selected = false
                        };
                        roleClaims.Add(newClaim);
                    }
                    ////
                }
            }
            foreach (var claim in AllUserClaims)
            {
                if (claim.Contains("Users"))
                {
                    /////
                    if (Claims.Exists(x => x.Type == claim))
                    {
                        RoleClaim newClaim = new RoleClaim
                        {
                            claim    = claim,
                            Selected = true
                        };
                        userClaims.Add(newClaim);
                    }
                    else
                    {
                        RoleClaim newClaim = new RoleClaim
                        {
                            claim    = claim,
                            Selected = false
                        };
                        userClaims.Add(newClaim);
                    }
                    ////
                }
            }

            //foreach (var claim in AllVersionClaims)
            //{
            //    if (claim.Contains("Version"))
            //    {
            //        /////
            //        if (Claims.Exists(x => x.Type == claim))
            //        {
            //            RoleClaim newClaim = new RoleClaim
            //            {
            //                claim = claim,
            //                Selected = true
            //            };
            //            versionClaims.Add(newClaim);
            //        }
            //        else
            //        {
            //            RoleClaim newClaim = new RoleClaim
            //            {
            //                claim = claim,
            //                Selected = false
            //            };
            //            versionClaims.Add(newClaim);
            //        }
            //        ////
            //    }
            //}

            RoleClaims = roleClaims;
            UserClaims = userClaims;
            //VersionClaims = versionClaims;

            return(Page());
        }
 public IEnumerable <Claim> GetClaimsByValueType(string valueType)
 {
     return(Claims.FindAll(c => c.ValueType == valueType));
 }
예제 #12
0
        /// <summary>claimType="P","S","PreAuth","W" (waiting to send).</summary>
        public static Claim CreateClaim(string claimType, List <PatPlan> PatPlanList, List <InsPlan> InsPlanList, List <ClaimProc> ClaimProcList,
                                        List <Procedure> procsForPat, Patient pat, List <Procedure> procsForClaim, List <Benefit> benefitList, List <InsSub> SubList,
                                        bool calculateLineNumber = true, string claimIdentifier = "")
        {
            //Claim ClaimCur=CreateClaim("P",PatPlanList,InsPlanList,ClaimProcList,procsForPat);
            InsPlan PlanCur1 = new InsPlan();
            InsSub  SubCur1  = new InsSub();
            InsPlan PlanCur2 = new InsPlan();
            InsSub  SubCur2  = new InsSub();

            switch (claimType)
            {
            case "P":
                SubCur1  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 1), SubList);
                PlanCur1 = InsPlans.GetPlan(SubCur1.PlanNum, InsPlanList);
                SubCur2  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 2), SubList);
                //PlanCur2=InsPlans.GetPlan(SubCur.PlanNum,InsPlanList);//can end up null
                break;

            case "S":
                SubCur1  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 2), SubList);
                PlanCur1 = InsPlans.GetPlan(SubCur1.PlanNum, InsPlanList);
                SubCur2  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 1), SubList);
                //PlanCur2=InsPlans.GetPlan(SubCur.PlanNum,InsPlanList);//can end up null
                break;

            case "PreAuth":
                SubCur1  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 1), SubList);
                PlanCur1 = InsPlans.GetPlan(SubCur1.PlanNum, InsPlanList);
                SubCur2  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 2), SubList);
                break;

            case "W":
                SubCur1  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 1), SubList);
                PlanCur1 = InsPlans.GetPlan(SubCur1.PlanNum, InsPlanList);
                SubCur2  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 2), SubList);
                break;

            case "Med":
                SubCur1  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, PatPlans.GetOrdinal(PriSecMed.Medical, PatPlanList, InsPlanList, SubList)), SubList);
                PlanCur1 = InsPlans.GetPlan(SubCur1.PlanNum, InsPlanList);
                SubCur2  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, PatPlans.GetOrdinal(PriSecMed.Primary, PatPlanList, InsPlanList, SubList)), SubList);
                break;
            }
            //DataTable table=DataSetMain.Tables["account"];
            Procedure proc;

            //proc=Procedures.GetProcFromList(procsForPat,PIn.Long(table.Rows[gridAccount.SelectedIndices[0]]["ProcNum"].ToString()));
            //long clinicNum=proc.ClinicNum;
            ClaimProc[] claimProcs = new ClaimProc[procsForClaim.Count];          //1:1 with procs
            long        procNum;

            for (int i = 0; i < procsForClaim.Count; i++)       //loop through selected procs
            //and try to find an estimate that can be used
            {
                procNum       = procsForClaim[i].ProcNum;
                claimProcs[i] = Procedures.GetClaimProcEstimate(procNum, ClaimProcList, PlanCur1, SubCur1.InsSubNum);
            }
            for (int i = 0; i < claimProcs.Length; i++)       //loop through each claimProc
            //and create any missing estimates. This handles claims to 3rd and 4th ins co's.
            {
                if (claimProcs[i] == null)
                {
                    claimProcs[i] = new ClaimProc();
                    proc          = procsForClaim[i];
                    ClaimProcs.CreateEst(claimProcs[i], proc, PlanCur1, SubCur1);
                }
            }
            Claim claim = new Claim();

            Claims.Insert(claim);            //to retreive a key for new Claim.ClaimNum
            claim.PatNum        = pat.PatNum;
            claim.DateService   = claimProcs[claimProcs.Length - 1].ProcDate;
            claim.ClinicNum     = procsForClaim[0].ClinicNum;
            claim.DateSent      = DateTime.Today;
            claim.DateSentOrig  = claim.DateSent;
            claim.ClaimStatus   = "S";
            claim.AttachedFlags = "Mail";
            if (!string.IsNullOrEmpty(claimIdentifier))
            {
                claim.ClaimIdentifier = claimIdentifier;
            }
            //datereceived
            switch (claimType)
            {
            case "P":
                claim.PlanNum    = SubCur1.PlanNum;
                claim.InsSubNum  = PatPlans.GetInsSubNum(PatPlanList, 1);
                claim.PatRelat   = PatPlans.GetRelat(PatPlanList, 1);
                claim.ClaimType  = "P";
                claim.PlanNum2   = SubCur2.PlanNum;                    //might be 0 if no sec ins
                claim.InsSubNum2 = PatPlans.GetInsSubNum(PatPlanList, 2);
                claim.PatRelat2  = PatPlans.GetRelat(PatPlanList, 2);
                break;

            case "S":
                claim.PlanNum    = SubCur1.PlanNum;
                claim.InsSubNum  = PatPlans.GetInsSubNum(PatPlanList, 2);
                claim.PatRelat   = PatPlans.GetRelat(PatPlanList, 2);
                claim.ClaimType  = "S";
                claim.PlanNum2   = SubCur2.PlanNum;
                claim.InsSubNum2 = PatPlans.GetInsSubNum(PatPlanList, 1);
                claim.PatRelat2  = PatPlans.GetRelat(PatPlanList, 1);
                break;

            case "W":
                claim.PlanNum     = SubCur1.PlanNum;
                claim.InsSubNum   = PatPlans.GetInsSubNum(PatPlanList, 2);
                claim.PatRelat    = PatPlans.GetRelat(PatPlanList, 2);
                claim.ClaimType   = "P";
                claim.ClaimStatus = "W";
                claim.PlanNum2    = SubCur2.PlanNum;
                claim.InsSubNum2  = PatPlans.GetInsSubNum(PatPlanList, 1);
                claim.PatRelat2   = PatPlans.GetRelat(PatPlanList, 1);
                break;

            case "Med":
                claim.PlanNum    = SubCur1.PlanNum;
                claim.InsSubNum  = PatPlans.GetInsSubNum(PatPlanList, 1);
                claim.PatRelat   = PatPlans.GetRelat(PatPlanList, 1);
                claim.ClaimType  = "Other";
                claim.PlanNum2   = SubCur2.PlanNum;                    //might be 0 if no other ins
                claim.InsSubNum2 = PatPlans.GetInsSubNum(PatPlanList, 2);
                claim.PatRelat2  = PatPlans.GetRelat(PatPlanList, 2);
                break;
            }
            claim.ProvTreat     = procsForClaim[0].ProvNum;
            claim.IsProsthesis  = "I";
            claim.ProvBill      = Providers.GetBillingProvNum(claim.ProvTreat, claim.ClinicNum);
            claim.EmployRelated = YN.No;
            //attach procedures
            Procedure ProcCur;

            for (int i = 0; i < claimProcs.Length; i++)
            {
                ProcCur = procsForClaim[i];
                claimProcs[i].ClaimNum = claim.ClaimNum;
                claimProcs[i].Status   = ClaimProcStatus.NotReceived;            //status for claims unsent or sent.
                //writeoff handled in ClaimL.CalculateAndUpdate()
                claimProcs[i].CodeSent = ProcedureCodes.GetProcCode(ProcCur.CodeNum).ProcCode;
                if (claimProcs[i].CodeSent.Length > 5 && claimProcs[i].CodeSent.Substring(0, 1) == "D")
                {
                    claimProcs[i].CodeSent = claimProcs[i].CodeSent.Substring(0, 5);
                }
                if (calculateLineNumber)
                {
                    claimProcs[i].LineNumber = (byte)(i + 1);
                }
                ClaimProcs.Update(claimProcs[i]);
            }
            ClaimProcList = ClaimProcs.Refresh(pat.PatNum);
            Claims.CalculateAndUpdate(procsForPat, InsPlanList, claim, PatPlanList, benefitList, pat, SubList);
            return(claim);
        }
예제 #13
0
        //#8 - inside class, outside other methods; write methods for display options
        //Add claim to list
        //methods void - get input but don't have to return anything
        private void AddClaimToList()
        {
            //#11 clear content
            Console.Clear();
            Claims newClaim = new Claims();

            //Claim ID
            Console.WriteLine("Enter the Claim ID:");
            string idAsString = Console.ReadLine();

            newClaim.ClaimID = int.Parse(idAsString);

            //Type
            Console.WriteLine("Enter the claim type number: \n " +
                              "1. Car\n" +
                              "2. Home\n" +
                              "3. Theft");
            string claimAsString = Console.ReadLine();
            int    claimAsInt    = int.Parse(claimAsString);

            newClaim.TypeOfClaim = (ClaimType)claimAsInt;

            //Description
            Console.WriteLine("Enter the incident description.:");
            newClaim.Description = Console.ReadLine();

            //Amount
            Console.WriteLine("Enter the amount of damage: ");
            string amountAsString = Console.ReadLine();

            newClaim.ClaimAmount = double.Parse(amountAsString);

            //Date of Incident
            Console.WriteLine("Enter the date of the incident (Year/Month/Day): ");
            string incidentDateAsString = Console.ReadLine();

            newClaim.DateOfIncident = DateTime.Parse(incidentDateAsString);

            //Date of claim
            Console.WriteLine("Enter the date of the claim (Year/Month/Day)");
            string claimDateAsString = Console.ReadLine();

            newClaim.DateOfClaim = DateTime.Parse(claimDateAsString);

            //Is valid
            //Console.WriteLine("Is the claim valid (y/n)? ");
            //string claimValidString = Console.ReadLine().ToLower();

            if ((newClaim.DateOfClaim - newClaim.DateOfIncident).TotalDays <= 30)
            {
                Console.WriteLine("Claim is valid.");
            }
            else
            {
                Console.WriteLine("Claim is not valid");
            }

            //#9 - once all properties are set, need to call repository and add to list - create _claimsRepo (at top of program UI)
            //#10
            _claimsRepo.AddClaimToList(newClaim);
        }
예제 #14
0
 public HttpStatusCode Delete(long id)
 {
     Employees.DeleteEmployee(Claims.GetConnectionString(User), id);
     return(HttpStatusCode.OK);
 }
예제 #15
0
 public HttpStatusCode Put(long id, Employee emp)
 {
     Employees.UpdateEmployee(Claims.GetConnectionString(User), id, emp);
     return(HttpStatusCode.OK);
 }
예제 #16
0
 public List <Employee> Get()
 {
     return(Employees.GetEmployees(Claims.GetConnectionString(User)));
 }
예제 #17
0
 public virtual void RemoveAllClaims()
 {
     Claims.Clear();
 }
예제 #18
0
 internal void RemoveClaim(Claim claim)
 {
     Claims.RemoveAll(x => x.Type == claim.Type && x.Value == claim.Value);
 }
예제 #19
0
 public virtual ClientClaim FindClaim(string value, string type)
 {
     return(Claims.FirstOrDefault(c => c.Type == type && c.Value == value));
 }
예제 #20
0
 ///<summary>Fills the missing data field on the queueItem that was passed in.  This contains all missing data on this claim.  Claim will not be allowed to be sent electronically unless this string comes back empty.</summary>
 public static ClaimSendQueueItem GetMissingData(Clearinghouse clearinghouseClin, ClaimSendQueueItem queueItem)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         return(Meth.GetObject <ClaimSendQueueItem>(MethodBase.GetCurrentMethod(), clearinghouseClin, queueItem));
     }
     if (queueItem == null)
     {
         return(new ClaimSendQueueItem()
         {
             MissingData = Lans.g("Eclaims", "Unable to fill claim data. Please recreate claim.")
         });
     }
     queueItem.Warnings             = "";
     queueItem.MissingData          = "";
     queueItem.ErrorsPreventingSave = "";
     //this is usually just the default clearinghouse or the clearinghouse for the PayorID.
     if (clearinghouseClin == null)
     {
         if (queueItem.MedType == EnumClaimMedType.Dental)
         {
             queueItem.MissingData += "No default dental clearinghouse set.";
         }
         else
         {
             queueItem.MissingData += "No default medical/institutional clearinghouse set.";
         }
         return(queueItem);
     }
     #region Data Sanity Checking (for Replication)
     //Example: We had one replication customer who was able to delete an insurance plan for which was attached to a claim.
     //Imagine two replication servers, server A and server B.  An insplan is created which is not associated to any claims.
     //Both databases have a copy of the insplan.  The internet connection is lost.  On server A, a user deletes the insurance
     //plan (which is allowed because no claims are attached).  On server B, a user creates a claim with the insurance plan.
     //When the internet connection returns, the delete insplan statement is run on server B, which then creates a claim with
     //an invalid InsPlanNum on server B.  Without the checking below, the send claims window would crash for this one scenario.
     Claim   claim   = Claims.GetClaim(queueItem.ClaimNum); //This should always exist, because we just did a select to get the queue item.
     InsPlan insPlan = InsPlans.RefreshOne(claim.PlanNum);
     if (insPlan == null)                                   //Check for missing PlanNums
     {
         queueItem.ErrorsPreventingSave = Lans.g("Eclaims", "Claim insurance plan record missing.  Please recreate claim.");
         queueItem.MissingData          = Lans.g("Eclaims", "Claim insurance plan record missing.  Please recreate claim.");
         return(queueItem);
     }
     if (claim.InsSubNum2 != 0)
     {
         InsPlan insPlan2 = InsPlans.RefreshOne(claim.PlanNum2);
         if (insPlan2 == null)               //Check for missing PlanNums
         {
             queueItem.MissingData = Lans.g("Eclaims", "Claim other insurance plan record missing.  Please recreate claim.");
             return(queueItem);                   //This will let the office send other claims that passed validation without throwing an exception.
         }
     }
     #endregion Data Sanity Checking (for Replication)
     if (claim.ProvTreat == 0)           //This has only happened in the past due to a conversion.
     {
         queueItem.MissingData = Lans.g("Eclaims", "No treating provider set.");
         return(queueItem);
     }
     try {
         if (clearinghouseClin.Eformat == ElectronicClaimFormat.x837D_4010)
         {
             X837_4010.Validate(clearinghouseClin, queueItem);                   //,out warnings);
             //return;
         }
         else if (clearinghouseClin.Eformat == ElectronicClaimFormat.x837D_5010_dental ||
                  clearinghouseClin.Eformat == ElectronicClaimFormat.x837_5010_med_inst)
         {
             X837_5010.Validate(clearinghouseClin, queueItem);                   //,out warnings);
             //return;
         }
         else if (clearinghouseClin.Eformat == ElectronicClaimFormat.Renaissance)
         {
             queueItem.MissingData = Renaissance.GetMissingData(queueItem);
             //return;
         }
         else if (clearinghouseClin.Eformat == ElectronicClaimFormat.Canadian)
         {
             queueItem.MissingData = Canadian.GetMissingData(queueItem);
             //return;
         }
         else if (clearinghouseClin.Eformat == ElectronicClaimFormat.Dutch)
         {
             Dutch.GetMissingData(queueItem);                    //,out warnings);
             //return;
         }
         else if (clearinghouseClin.Eformat == ElectronicClaimFormat.Ramq)
         {
             Ramq.GetMissingData(clearinghouseClin, queueItem);
         }
     }
     catch (Exception e) {
         queueItem.MissingData = Lans.g("Eclaims", "Unable to validate claim data:") + " " + e.Message + Lans.g("Eclaims", " Please recreate claim.");
     }
     return(queueItem);
 }
예제 #21
0
 public HttpStatusCode Put(long id, Product prod)
 {
     Products.UpdateProduct(Claims.GetConnectionString(User), id, prod);
     return(HttpStatusCode.OK);
 }
예제 #22
0
 private IEnumerable <string> GetRolesNames()
 {
     return(Claims.Where(x => x.Type == ClaimTypes.Role).Select(x => x.Value).ToImmutableList());
 }
예제 #23
0
        public void Assert_json_correctly_generates_errors_for_nested_arrays_of_objects_with_properties_of_different_types_or_names()
        {
            var actual = new
            {
                MyObjects = new[]
                {
                    new
                    {
                        MyFirstArrayObjectProp  = 1,
                        MySecondArrayObjectProp = 2.0,
                        MyNestedObjects         = new[]
                        {
                            new
                            {
                                MyFirstArrayObjectProp     = 1,
                                MySecondArrayObjectProp    = 2,
                                MySecondLevelNestedObjects = new [] { "123" },
                                MyWrongValueProperty       = 12
                            },
                            new
                            {
                                MyFirstArrayObjectProp     = 1,
                                MySecondArrayObjectProp    = 2,
                                MySecondLevelNestedObjects = new [] { "123" },
                                MyWrongValueProperty       = 12
                            },
                            new
                            {
                                MyFirstArrayObjectProp     = 1,
                                MySecondArrayObjectProp    = 2,
                                MySecondLevelNestedObjects = new [] { "123" },
                                MyWrongValueProperty       = 12
                            }
                        }
                    }
                }
            };

            var exception = Assert.Catch <AssertFailedException>(() =>
            {
                Claims.Get("https://www.test.com", () => CreateMockedJsonHttpClient(actual))
                .AssertJson(new
                {
                    MyObjects = new[]
                    {
                        new
                        {
                            MyFirstArrayObjectProp  = "1",   // Wrong Type
                            MySecondArrayObjectProp = 2,     // Wrong Type
                            MyNestedObjects         = new[]
                            {
                                new
                                {
                                    MyFirstArrayObjectProp1    = 1,             // Wrong Name
                                    MySecondArrayObjectProp    = 2.0,           // Wrong Type
                                    MySecondLevelNestedObjects = new[] { 123 }, // Wrong Type
                                    MyWrongValueProperty       = 13             // Wrong Value
                                },
                                new
                                {
                                    MyFirstArrayObjectProp1    = 1,             // Wrong Name
                                    MySecondArrayObjectProp    = 2.0,           // Wrong Type
                                    MySecondLevelNestedObjects = new[] { 123 }, // Wrong Type
                                    MyWrongValueProperty       = 13             // Wrong Value
                                },
                                new
                                {
                                    MyFirstArrayObjectProp1    = 1,             // Wrong Name
                                    MySecondArrayObjectProp    = 2.0,           // Wrong Type
                                    MySecondLevelNestedObjects = new[] { 123 }, // Wrong Type
                                    MyWrongValueProperty       = 13             // Wrong Value
                                }
                            }
                        }
                    }
                })
                .Execute();
            });

            Assert.IsTrue(exception.FailedResults.Single().Message.Contains("The expected property 'MyObjects[0].MyFirstArrayObjectProp' is not of the same type as the property in the response. Expected type: 'String'. Actual type: 'Integer'"));
            Assert.IsTrue(exception.FailedResults.Single().Message.Contains("The expected property 'MyObjects[0].MySecondArrayObjectProp' is not of the same type as the property in the response. Expected type: 'Int32'. Actual type: 'Float'"));
            Assert.IsTrue(exception.FailedResults.Single().Message.Contains("The expected property 'MyObjects[0].MyNestedObjects[0].MyFirstArrayObjectProp1' was not present in the response."));
            Assert.IsTrue(exception.FailedResults.Single().Message.Contains("The expected property 'MyObjects[0].MyNestedObjects[0].MySecondArrayObjectProp' is not of the same type as the property in the response. Expected type: 'Double'. Actual type: 'Integer'"));
            Assert.IsTrue(exception.FailedResults.Single().Message.Contains("The expected property 'MyObjects[0].MyNestedObjects[0].MySecondLevelNestedObjects[0]' is not of the same type as the property in the response. Expected type: 'Int32'. Actual type: 'String'"));
            Assert.IsTrue(exception.FailedResults.Single().Message.Contains("The expected property 'MyObjects[0].MyNestedObjects[0].MyWrongValueProperty' does not have the same value as the property in the response. Expected value: '13'. Actual value: '12'"));
            Assert.IsTrue(exception.FailedResults.Single().Message.Contains("The expected property 'MyObjects[0].MyNestedObjects[1].MyFirstArrayObjectProp1' was not present in the response."));
            Assert.IsTrue(exception.FailedResults.Single().Message.Contains("The expected property 'MyObjects[0].MyNestedObjects[1].MySecondArrayObjectProp' is not of the same type as the property in the response. Expected type: 'Double'. Actual type: 'Integer'"));
            Assert.IsTrue(exception.FailedResults.Single().Message.Contains("The expected property 'MyObjects[0].MyNestedObjects[1].MySecondLevelNestedObjects[0]' is not of the same type as the property in the response. Expected type: 'Int32'. Actual type: 'String'"));
            Assert.IsTrue(exception.FailedResults.Single().Message.Contains("The expected property 'MyObjects[0].MyNestedObjects[1].MyWrongValueProperty' does not have the same value as the property in the response. Expected value: '13'. Actual value: '12'"));
            Assert.IsTrue(exception.FailedResults.Single().Message.Contains("The expected property 'MyObjects[0].MyNestedObjects[2].MyFirstArrayObjectProp1' was not present in the response."));
            Assert.IsTrue(exception.FailedResults.Single().Message.Contains("The expected property 'MyObjects[0].MyNestedObjects[2].MySecondArrayObjectProp' is not of the same type as the property in the response. Expected type: 'Double'. Actual type: 'Integer'"));
            Assert.IsTrue(exception.FailedResults.Single().Message.Contains("The expected property 'MyObjects[0].MyNestedObjects[2].MySecondLevelNestedObjects[0]' is not of the same type as the property in the response. Expected type: 'Int32'. Actual type: 'String'"));
            Assert.IsTrue(exception.FailedResults.Single().Message.Contains("The expected property 'MyObjects[0].MyNestedObjects[2].MyWrongValueProperty' does not have the same value as the property in the response. Expected value: '13'. Actual value: '12'"));
        }
예제 #24
0
 public void AddClaim(string claim)
 {
     Require.ArgumentNotNullEmpty(claim, nameof(claim));
     Claims = Claims.Concat(new[] { claim }).Distinct().ToArray();
 }
예제 #25
0
 private static Claims TicketToJson(string ticket, Func<string, string, bool> verifier, ClaimsAuthority claimsAuthority)
 {
     Contract.Assert(Conf.Preamble.Equals(ticket.Substring(0, Conf.Preamble.Length)), "preamble missing or corrupt");
     var versionAndClaimAndImpersonator = ticket.Substring(Conf.Preamble.Length).Split(Conf.VersionAndClaimAndImpersonatorSeperator);
     var version = versionAndClaimAndImpersonator[Conf.VersionIndex];
     var claimAndSignatureBlock = versionAndClaimAndImpersonator[Conf.ClaimIndex];
     var impersonator = versionAndClaimAndImpersonator.Length + 1 == Conf.ImpersonatorIndex ? versionAndClaimAndImpersonator[Conf.ImpersonatorIndex] : string.Empty;
     Contract.Assert(!string.IsNullOrWhiteSpace(version), "parser error -- version is required");
     Contract.Assert(!string.IsNullOrWhiteSpace(claimAndSignatureBlock), "parser error -- claim and signature are required");
     var claimAndSignature = claimAndSignatureBlock.Split(Conf.ClaimAndSignatureSeperator);
     var claimSectionsBlock = claimAndSignature[Conf.ClaimSectionsIndex];
     var signature = claimAndSignature[Conf.SignatureIndex];
     var encoded = claimSectionsBlock;
     var claimSections = claimSectionsBlock.Split(Conf.SectionSeperator);
     var claimset = claimSections[Conf.ClaimsetIndex];
     var details = claimSections[Conf.DetailsIndex];
     var expiration = claimSections[Conf.TimestampIndex];
     Contract.Assert(!string.IsNullOrWhiteSpace(claimset), "parser error -- claimset section is required");
     Contract.Assert(!string.IsNullOrWhiteSpace(details), "parser error -- details section is required");
     Contract.Assert(!string.IsNullOrWhiteSpace(expiration), "parser error -- expiration section is required");
     var detailBlocks = details.Split(Conf.ItemSeperator);
     var len = detailBlocks.Length;
     var i = -1;
     var parsedDetails = new Dictionary<string, Dictionary<string, string>>();
     while (++i < len)
     {
         var block = detailBlocks[i].Split(Conf.ClaimsetSeparator);
         var claimsetId = new ArraySegment<string>(block, Conf.ClaimsetIdIndex, Conf.ClaimsetDetailsIndex - Conf.ClaimsetIdIndex).First();
         var rawDetailsArray = new ArraySegment<string>(block, Conf.ClaimsetDetailsIndex, block.Length - Conf.ClaimsetDetailsIndex).ToArray();
         var detailsArrayLen = rawDetailsArray.Length;
         var j = -1;
         var parsedValues = new Dictionary<string, string>();
         while (++j < detailsArrayLen)
         {
             var rules = rawDetailsArray[j].Split(Conf.DetailSeperator);
             var detailRuleId = rules[Conf.DetailsRuleIdIndex];
             var detail = rules[Conf.DetailsRuleIndex];
             parsedValues[detailRuleId] = detail;
         }
         parsedDetails[claimsetId] = parsedValues;
     }
     var claimBlocks = claimset.Split(Conf.ItemSeperator);
     len = claimBlocks.Length;
     i = -1;
     var claimsets = new Dictionary<string, Claimset>();
     var knownIdentityValues = new Dictionary<string, string>();
     while (++i < len)
     {
         var block = claimBlocks[i].Split(Conf.ClaimsetSeparator);
         var claimsetId = block[Conf.ClaimsetIdIndex];
         var claimsetRules = int.Parse(block[Conf.ClaimsetRulesIndex], System.Globalization.NumberStyles.HexNumber);
         var claims = new Dictionary<string, Claim>();
         var b = 1;
         while (b <= claimsetRules)
         {
             if (b == (b & claimsetRules))
             {
                 var claimId = b.ToString("x");
                 var claimOptionsValue = default(string);
                 if (parsedDetails.ContainsKey(claimsetId))
                 {
                     var claimsetDetails = parsedDetails[claimsetId];
                     var encodedValue = claimsetDetails[claimId];
                     claimOptionsValue = Encoding.UTF8.GetString(Convert.FromBase64String(encodedValue));
                 }
                 var claimOptionsKind = !string.IsNullOrWhiteSpace(claimOptionsValue) ? ClaimKind.Identity : ClaimKind.Unknown;
                 claims[claimId] = new Claim(id: claimId, kind: claimOptionsKind, value: claimOptionsValue);
             }
             b *= 2;
         }
         claimsets[claimsetId] = new Claimset(id: claimsetId, claims: claims, signature: signature);
     }
     var result = new Claims(claimsets, Convert.ToDateTime(expiration), signature, encoded, ticket, verifier, claimsAuthority);
     return result;
 }
예제 #26
0
 public void RemoveClaim(string claim)
 {
     Require.ArgumentNotNullEmpty(claim, nameof(claim));
     Claims = Claims.Where(cm => cm.IsNotEqualTo(claim)).ToArray();
 }
예제 #27
0
        public ClaimsIdentity ToIdentity()
        {
            var claims = Claims.Select(x => new Claim(x.ClaimType, x.Value, x.ValueType));

            return(new ClaimsIdentity(claims, AuthenticationType, NameClaimType, RoleClaimType));
        }
예제 #28
0
        public void GenerateLoginToken_HasPassedClaims()
        {
            // Act
            var token = Handler.Handle(new GenerateLoginTokenQuery(Claims), CancellationToken.None).Result;

            // Assert
            Assert.Contains(Claims.First().Value, new JwtSecurityToken(token).Claims.First(claim => claim.Value == Claims.First().Value).Value);
        }
예제 #29
0
        public virtual IdentityUserClaim FindClaim([NotNull] Claim claim)
        {
            Check.NotNull(claim, nameof(claim));

            return(Claims.FirstOrDefault(c => c.ClaimType == claim.Type && c.ClaimValue == claim.Value));
        }
예제 #30
0
 public void ClaimsArranged()
 {
     _claimsRepo = new ClaimsRepo();
     _claims     = new Claims(1, ClaimType.Car, "Rear-ended on Southport and Emerson.", 475.00, "08/10/20", "8/15/20", true);
     _claimsRepo.EnterNewClaim(_claims);
 }
예제 #31
0
 public virtual void AddClaim([NotNull] string value, string type)
 {
     Claims.Add(new ClientClaim(Id, type, value));
 }
예제 #32
0
 public virtual void RemoveClaim(Claim claim)
 {
     Claims.RemoveAll(c => c.ClaimType == claim.Type && c.ClaimValue == claim.Value);
 }