private void BindClaimType() { CheckBoxListClaimType.DataSource = ClaimType.GetClaimTypeList(); CheckBoxListClaimType.DataValueField = "ClaimTypeId"; CheckBoxListClaimType.DataTextField = "Description"; CheckBoxListClaimType.DataBind(); }
public Claim(Permission permission, Access accessType, ClaimType claimType, string sid) { this.Permission = permission; this.AccessType = accessType; this.ClaimType = claimType; this.Sid = sid; }
public void NewClaim() { Claims_Content claim = new Claims_Content(); Console.WriteLine("Enter claim id"); string claimidasString = Console.ReadLine(); int claimId = int.Parse(claimidasString); Console.WriteLine("Enter Type of claim"); string typeasString = Console.ReadLine(); ClaimType claimType = (ClaimType)int.Parse(typeasString); Console.WriteLine("Enter a discription of the claim"); string description = Console.ReadLine(); Console.WriteLine("Enter a claim amount"); string amountasString = Console.ReadLine(); decimal claimAmount = decimal.Parse(amountasString); Console.WriteLine("Enter date of incident (yyyy/mm/dd)"); string dateOfIncidentasString = Console.ReadLine(); DateTime dateOfIncident = DateTime.Parse(dateOfIncidentasString); Console.WriteLine("Enter date of claim (yyyy/mm/dd)"); string dateOfClaimasString = Console.ReadLine(); DateTime dateOfClaim = DateTime.Parse(dateOfClaimasString); Claims_Content incident = new Claims_Content(claimId, claimType, description, claimAmount, dateOfIncident, dateOfClaim); _claimsRepo.NewClaim(incident); }
public void AddNewClaim() { Console.WriteLine("Enter the claim ID: "); string claimIDAsString = Console.ReadLine(); int claimID = int.Parse(claimIDAsString); Console.WriteLine("What type of claim is this?\n" + "1. Car\n" + "2. Home\n" + "3. Theft\n"); string typeOfClaimAsString = Console.ReadLine(); int typeOfClaimAsInt = int.Parse(typeOfClaimAsString); ClaimType typeOfClaim = (ClaimType)typeOfClaimAsInt; Console.WriteLine("Enter a description of the claim: "); string description = Console.ReadLine(); Console.WriteLine("Amount of damage: "); string claimAmountAsString = Console.ReadLine(); float claimAmount = float.Parse(claimAmountAsString); Console.WriteLine("Enter date of incident as DD/MM/YYYY: "); string dateOfIncidentAsString = Console.ReadLine(); DateTime dateOfIncident = DateTime.Parse(dateOfIncidentAsString); Console.WriteLine("Enter date of claim as DD/MM/YYYY: "); string dateOfClaimAsString = Console.ReadLine(); DateTime dateOfClaim = DateTime.Parse(dateOfClaimAsString); ClaimItems newClaim = new ClaimItems(claimID, typeOfClaim, description, claimAmount, dateOfIncident, dateOfClaim); _repo.AddNewClaim(newClaim); }
public override int GetHashCode() { int hash = 1; if (entityId_ != null) { hash ^= EntityId.GetHashCode(); } if (ClaimType != 0) { hash ^= ClaimType.GetHashCode(); } if (dateRange_ != null) { hash ^= DateRange.GetHashCode(); } if (room_ != null) { hash ^= Room.GetHashCode(); } if (MaintenanceHoldReason.Length != 0) { hash ^= MaintenanceHoldReason.GetHashCode(); } if (reservation_ != null) { hash ^= Reservation.GetHashCode(); } return(hash); }
private void AllowAccess(ClaimType type, string sid, params Access[] accessToAllow) { // Spec: // To allow a user we add the corresponding allow claim and remove any deny claims. // We also remove any pending reset requests. var allowClaims = accessToAllow.Select(x => new Claim(Permission.Allow, x, type, sid)); var denyClaims = accessToAllow.Select(x => new Claim(Permission.Deny, x, type, sid)); // Add the new added claims allowClaims.For(c => { if (this.CurrentClaims.Contains(c) == false) { this.CurrentClaims.Add(c); } }); denyClaims.For(c => { while (this.CurrentClaims.Contains(c) == true) { this.CurrentClaims.Remove(c); } }); accessToAllow.For(a => { var request = new ResetRequest(type, sid, a); while (this.ResetRequests.Contains(request) == true) { this.ResetRequests.Remove(request); } }); }
private static IEnumerable <InputPolicyClaim> RetrieveInputClaims(XElement ruleElement, IDictionary <string, Issuer> issuers, IDictionary <string, string> claimTypes) { List <InputPolicyClaim> inputClaims = new List <InputPolicyClaim>(); foreach (XElement inputClaimElement in ruleElement.Element("input").Descendants("claim")) { string inputClaimValue = inputClaimElement.Attribute("value").Value; string inputIssuerDisplayName = inputClaimElement.Attribute("issuer").Value; string inputTypeDisplayName = inputClaimElement.Attribute("type").Value; if (!issuers.ContainsKey(inputIssuerDisplayName)) { throw new PolicyClaimException(string.Format(CultureInfo.CurrentUICulture, Resources.IssuerNotDefined, inputIssuerDisplayName)); } if (!claimTypes.ContainsKey(inputTypeDisplayName)) { throw new PolicyClaimException(string.Format(CultureInfo.CurrentUICulture, Resources.ClaimTypeNotDefined, inputTypeDisplayName)); } Issuer issuer = issuers[inputIssuerDisplayName]; ClaimType claimType = new ClaimType(claimTypes[inputTypeDisplayName], inputTypeDisplayName); inputClaims.Add(new InputPolicyClaim(issuer, claimType, inputClaimValue)); } return(inputClaims); }
public void ShouldOutputCorrectInputValue() { var store = new MockPolicyStore(); ClaimsPolicyEvaluator evaluator = new ClaimsPolicyEvaluator(store); InputPolicyClaim inputPolicyClaim1 = new InputPolicyClaim(this.issuer, this.inputClaimType, "*"); ClaimType outputClaimType1 = new ClaimType("http://myOutputClaimType1"); OutputPolicyClaim outputPolicyClaim1 = new OutputPolicyClaim(outputClaimType1, "myOutputClaimValue"); PolicyRule policyRule1 = new PolicyRule(AssertionsMatch.Any, new[] { inputPolicyClaim1 }, outputPolicyClaim1); InputPolicyClaim inputPolicyClaim2 = new InputPolicyClaim(this.issuer, this.inputClaimType, "inputClaimValue"); ClaimType outputClaimType2 = new ClaimType("http://myOutputClaimType2"); OutputPolicyClaim outputPolicyClaim2 = new OutputPolicyClaim(outputClaimType2, string.Empty, CopyFromConstants.InputValue); PolicyRule policyRule2 = new PolicyRule(AssertionsMatch.Any, new[] { inputPolicyClaim2 }, outputPolicyClaim2); store.RetrieveScopesReturnValue = new List <PolicyScope>() { new PolicyScope(new Uri("http://myScope"), new[] { policyRule1, policyRule2 }) }; IEnumerable <Claim> evaluatedOutputClaims = evaluator.Evaluate(new Uri("http://myScope"), new[] { new Claim("http://myInputClaimType", "inputClaimValue", string.Empty, "http://myInputClaimIssuer") }); Assert.IsNotNull(evaluatedOutputClaims); Assert.AreEqual(2, evaluatedOutputClaims.Count()); var outputClaim1 = evaluatedOutputClaims.FirstOrDefault(c => c.ClaimType == "http://myOutputClaimType1"); Assert.IsNotNull(outputClaim1); Assert.AreEqual("myOutputClaimValue", outputClaim1.Value); var outputClaim2 = evaluatedOutputClaims.FirstOrDefault(c => c.ClaimType == "http://myOutputClaimType2"); Assert.IsNotNull(outputClaim2); Assert.AreEqual("inputClaimValue", outputClaim2.Value); }
public void SeeAllClaims() { Console.Clear(); Console.WriteLine("What Type Of Claim Would You Like To See? Enter The Number\n" + "1. Car\n" + "2. Home\n" + "3. Theft"); ClaimType claimType = ClaimType.Car; string inputType = Console.ReadLine(); if (inputType == "1") { claimType = ClaimType.Car; } if (inputType == "2") { claimType = ClaimType.Home; } if (inputType == "3") { claimType = ClaimType.Theft; } Console.Clear(); Queue <Claims> queue = _newClaimRepo.GetContentByEnum(claimType); foreach (Claims content in queue) { Console.WriteLine($"{content.ClaimID}\n{content.CType}\n{content.Description}\n{content.ClaimAmount}\n{content.DateOfIncident}\n{content.DateOfClaim}\n{content.IsValidClaim}"); } Console.ReadLine(); }
// Override method public override void OnAuthorization(AuthorizationContext filterContext) { // Get a reference to the user var user = filterContext.HttpContext.User as ClaimsPrincipal; // Matches (below) are case-insensitive // Look for claims that match the incoming type // The matchingClaims will be a collection of zero or more matching claims var matchingClaims = user.Claims .Where(c => c.Type.ToLower().Contains(ClaimType.ToLower())); // Attempt to locate matching values var matchedClaim = false; foreach (var claim in matchingClaims) { if (claim.Value.ToLower() == ClaimValue.ToLower()) { matchedClaim = true; break; } } if (matchedClaim) { // Yes, authorized base.OnAuthorization(filterContext); } else { // No, not authorized base.HandleUnauthorizedRequest(filterContext); } }
public async Task <Guid> CreateAsync(ClaimTypeParam model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var items = await _repository.ListAsync(new ClaimTypeByName(model.Name)); var entity = items.Count > 0 ? items[0] : null; if (entity == null) { // create new entity var newEntity = ClaimType.Create( model.Name, model.ClaimValueType, model.Description ); await _repository.AddAsync(newEntity); return(newEntity.Id); } // update existing entity model.Id = entity.Id; SimpleMapper.Map(model, entity); await _repository.UpdateAsync(entity); return(entity.Id); }
public override Task OnAuthorizationAsync(HttpActionContext actionContext, CancellationToken cancellationToken) { var principal = actionContext.RequestContext.Principal as ClaimsPrincipal; if (actionContext.ActionDescriptor.GetCustomAttributes <AllowAnonymousAttribute>().Any <AllowAnonymousAttribute>() || actionContext.ControllerContext.ControllerDescriptor.GetCustomAttributes <AllowAnonymousAttribute>().Any <AllowAnonymousAttribute>()) { return(Task.FromResult <object>(null)); } if (!principal.Identity.IsAuthenticated) { actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized); return(Task.FromResult <object>(null)); } if (UserConfig.GetLoggedOutUser().Contains(principal.FindFirst(e => e.Type == "user").Value)) { actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized); return(Task.FromResult <object>(null)); } if (!(principal.HasClaim(e => e.Type.ToLower().Equals(ClaimType.ToLower()) && ClaimValue.ToLower().Contains(e.Value.ToLower())))) { actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized); return(Task.FromResult <object>(null)); } return(Task.FromResult <object>(null)); }
private static void ParseClaims(Acl acl, JObject item) { var sid = item.Property("sid").Value.ToString(); var type = item.Property("type").Value.ToString(); List <Access> allowed = new List <Access>(); List <Access> denied = new List <Access>(); var allowProperty = item.Property("allow"); if (allowProperty != null) { allowProperty .Values() .Select(x => (Access)Enum.Parse(typeof(Access), x.ToString(), true)) .For(x => allowed.Add(x)); } var denyProperty = item.Property("deny"); if (denyProperty != null) { denyProperty .Values() .Select(x => (Access)Enum.Parse(typeof(Access), x.ToString(), true)) .For(x => denied.Add(x)); } ClaimType claimType = (ClaimType)Enum.Parse(typeof(ClaimType), type, true); List <Claim> claims = new List <Claim>(); allowed.For(x => claims.Add(new Claim(Permission.Allow, x, claimType, sid))); denied.For(x => claims.Add(new Claim(Permission.Deny, x, claimType, sid))); acl.SetInternal(claims); }
public void CreateNewClaim_AddToClaim_CountShouldBeTheSame() { ////AAA/// ClaimsContent claims = new ClaimsContent(); ClaimsRepository _claimrepo = new ClaimsRepository(); Queue <ClaimsContent> queue = _claimrepo.SeeAllClaims(); ///AA/// ClaimsContent claim1 = new ClaimsContent(20, ClaimType.Home, "whole house burned down", 308987.34m, DateTime.Parse("03/01/2019"), DateTime.Parse("03/28/2019")); claim1.ClaimType = ClaimType.Home; ClaimType expected = ClaimType.Home; //A// Assert.AreEqual(expected, claim1.ClaimType); Assert.AreEqual(20, claim1.ClaimId); Assert.AreEqual("whole house burned down", claim1.Description); Assert.AreEqual(308987.34m, claim1.ClaimAmount); Assert.AreEqual(DateTime.Parse("03/01/2019"), claim1.DateOfIncident); Assert.AreEqual(DateTime.Parse("03/28/2019"), claim1.DateOfClaim); _claimrepo.AddToQueue(claim1); int expected1 = 1; int actual = queue.Count; Assert.AreEqual(expected1, actual); }
private void CreateNewClaim() { Console.WriteLine("Please enter the claim id:"); int id = int.Parse(Console.ReadLine()); Console.WriteLine("Please enter the claim type 1 for car 2 for home 3 for theft:"); int claimtype = int.Parse(Console.ReadLine()); ClaimType theType = GetClaimType(claimtype); Console.WriteLine("Please enter the description: "); string desc = Console.ReadLine(); Console.WriteLine("Please enter the claim amount: "); double amount = double.Parse(Console.ReadLine()); Console.WriteLine("Please enter the date of accident as month day, year ex: Jan 1, 2009 "); var incident = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Please enter the date of claim as month day, year ex: Jan 1, 2009 "); var claimdate = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Please enter if the claim is valid true or false"); bool valid = bool.Parse(Console.ReadLine()); Claim claim = new Claim(id, theType, desc, amount, incident, claimdate, valid); claimsRepo.AddClaimToQueue(claim); }
private void EnterANewClaim() { Console.WriteLine("Please enter a Claim ID"); string claimIDAsString = Console.ReadLine(); int claimID = int.Parse(claimIDAsString); Console.WriteLine("Please select a Claim Type\n" + "1 Car\n" + "2 Home\n" + "3 Theft\n" + "4 Exit"); string input = Console.ReadLine(); ClaimType typeofclaim = (ClaimType)int.Parse(input); Console.WriteLine("Please enter a description of this claim"); string description = Console.ReadLine(); Console.WriteLine("Please enter a claim amount"); string claimAmountAsString = Console.ReadLine(); decimal claimAmount = decimal.Parse(claimAmountAsString); Console.WriteLine("Please enter the date of the incident(yyyy/mm/dd"); DateTime dateOfIncident = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Please enter the date of the claim (yyyy/mm/dd"); DateTime dateOfClaim = DateTime.Parse(Console.ReadLine()); ClaimContent newClaimContent = new ClaimContent(typeofclaim, claimID, description, claimAmount, dateOfIncident, dateOfClaim); _queueRepo.AddContentToQueue(newClaimContent); }
public void ClaimContentObject() { ClaimContent contentOne = new ClaimContent(); contentOne.ClaimAmount = 200m; decimal expected = 200m; Assert.AreEqual(expected, contentOne.ClaimAmount); ClaimContent content = new ClaimContent(1, ClaimType.Car, 300m, DateTime.Today, DateTime.Today); int expectedID = 1; ClaimType expectedType = ClaimType.Car; decimal expectedClaimAmount = 300m; DateTime expectedDateOfIncident = DateTime.Today; DateTime expectedDateOfClaim = DateTime.Today; bool expectedIsValid = true; Assert.AreEqual(expectedID, content.ClaimID); Assert.AreEqual(expectedType, content.Type); Assert.AreEqual(expectedClaimAmount, content.ClaimAmount); Assert.AreEqual(expectedDateOfIncident, content.DateOfIncident); Assert.AreEqual(expectedDateOfClaim, content.DateOfClaim); Assert.AreEqual(expectedIsValid, content.IsValid); }
public override Task OnAuthorizationAsync(HttpActionContext actionContext, CancellationToken cancellationToken) { var principal = actionContext.RequestContext.Principal as ClaimsPrincipal; if (actionContext.ActionDescriptor.GetCustomAttributes <AllowAnonymousAttribute>().Any() || actionContext.ControllerContext.ControllerDescriptor.GetCustomAttributes <AllowAnonymousAttribute>().Any()) { return(Task.FromResult <object>(null)); } if (!principal.Identity.IsAuthenticated) { actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized); //burada araya giriyoruz. return(Task.FromResult <object>(null)); //method u sonlandırmak için yazılıyor. } if (UserConfig.GetLoggedOutUsers().Contains(principal.FindFirst(e => e.Type == "user").Value)) { actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized); return(Task.FromResult <object>(null)); } if (!principal.HasClaim(e => e.Type.ToLower().Contains(ClaimType.ToLower()) && ClaimValue.ToLower().Equals(e.Value.ToLower()))) //user ya da role tipinde claim var mı ve admin mi { actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized); //burada araya giriyoruz. return(Task.FromResult <object>(null)); } return(Task.FromResult <object>(null)); }
public async Task <IActionResult> CreateClaimType([FromBody] CreateClaimTypeRequest request) { var claimType = new ClaimType { Id = $"{Guid.NewGuid()}", Name = request.Name, DisplayName = request.DisplayName, Description = request.Description, Rule = request.Rule, ValueType = request.ValueType, Required = request.Required, Reserved = false, UserEditable = request.UserEditable }; _configurationDbContext.ClaimTypes.Add(claimType); await _configurationDbContext.SaveChangesAsync(); return(CreatedAtAction(nameof(GetClaimType), Name, new { id = claimType.Id }, new ClaimTypeInfo { Id = claimType.Id, Name = claimType.Name, DisplayName = claimType.DisplayName, Description = claimType.Description, Rule = claimType.Rule, ValueType = claimType.ValueType, Required = claimType.Required, Reserved = claimType.Reserved, UserEditable = claimType.UserEditable })); }
public void InsertClaimType() { var db = new ApplicationDbContext(); var claimType = new ClaimType(); TryUpdateModel(claimType); if (ModelState.IsValid) { try { db.ClaimTypes.Add(claimType); db.SaveChanges(); ErrorLabel.Text = String.Empty; } catch (DbEntityValidationException ex) { ErrorLabel.Visible = true; ErrorLabel.Text = EventLogManager.LogError(ex); } catch (Exception exp) { ErrorLabel.Text = exp.Message; ErrorLabel.Visible = true; } } else { ErrorLabel.Text = "Complete todos los campos."; ErrorLabel.Visible = true; } }
private static OutputPolicyClaim RetrieveOutputClaim(XElement ruleElement, IDictionary <string, string> claimTypes) { string outputTypeDisplayName = ruleElement.Element("output").Attribute("type").Value; string outputClaimValue = string.Empty; if (ruleElement.Element("output").Attribute("value") != null) { outputClaimValue = ruleElement.Element("output").Attribute("value").Value; } string copyFrom = string.Empty; if (ruleElement.Element("output").Attribute("copyFrom") != null) { copyFrom = ruleElement.Element("output").Attribute("copyFrom").Value.ToUpperInvariant(); } if (!claimTypes.ContainsKey(outputTypeDisplayName)) { throw new PolicyClaimException(string.Format(CultureInfo.CurrentUICulture, Resources.ClaimTypeNotDefined, outputTypeDisplayName)); } ClaimType claimType = new ClaimType(claimTypes[outputTypeDisplayName], outputTypeDisplayName); return(new OutputPolicyClaim(claimType, outputClaimValue, copyFrom)); }
public void ShouldMatchInputClaimAndCopyInputIssuerToOutputValue() { var store = new MockPolicyStore(); ClaimsPolicyEvaluator evaluator = new ClaimsPolicyEvaluator(store); ClaimType inputClaimType = new ClaimType("http://myInputClaimType"); ClaimType outputClaimType = new ClaimType("http://myOutputClaimType"); Issuer issuer = new Issuer("http://myInputClaimIssuer"); InputPolicyClaim inputClaim = new InputPolicyClaim(issuer, inputClaimType, "myInputClaim"); OutputPolicyClaim outputClaim = new OutputPolicyClaim(outputClaimType, string.Empty, CopyFromConstants.InputIssuer); PolicyRule rule = new PolicyRule(AssertionsMatch.Any, new[] { inputClaim }, outputClaim); store.RetrieveScopesReturnValue = new List <PolicyScope>() { new PolicyScope(new Uri("http://myScope"), new[] { rule }) }; IEnumerable <Claim> evaluatedOutputClaims = evaluator.Evaluate(new Uri("http://myScope"), new[] { new Claim("http://myInputClaimType", "myInputClaim", string.Empty, "http://myInputClaimIssuer") }); Assert.IsNotNull(evaluatedOutputClaims); Assert.AreEqual(1, evaluatedOutputClaims.Count()); Assert.AreEqual("http://myOutputClaimType", evaluatedOutputClaims.ElementAt(0).ClaimType); Assert.AreEqual("http://myInputClaimIssuer", evaluatedOutputClaims.ElementAt(0).Value); }
private void EnterNewClaim() { Console.Clear(); Console.WriteLine("Enter a new Claim ID number:"); int claimID = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("What type of claim is this:\n" + "1. Car\n" + "2. Home\n" + "3. Theft\n" ); string typeInput = Console.ReadLine(); int typeNumber = Convert.ToInt32(typeInput); ClaimType type = (ClaimType)typeNumber; Console.WriteLine("Enter a description:"); string description = Console.ReadLine(); Console.WriteLine("Enter a claim amount:"); double claimAmount = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Enter the date of the incident:"); DateTime incidentDate = Convert.ToDateTime(Console.ReadLine()); Console.WriteLine("Enter the date of the claim:"); DateTime claimDate = Convert.ToDateTime(Console.ReadLine()); InsuranceClaim newClaim = new InsuranceClaim(claimID, type, description, claimAmount, incidentDate, claimDate); _repo.AddClaimToQueue(newClaim); Console.WriteLine("New claim added!"); Console.ReadKey(); }
public void EnterNewClaim() { Console.WriteLine("Enter claim id: "); string claimIDString = Console.ReadLine(); int claimID = int.Parse(claimIDString); Console.WriteLine("Enter claim type: \n" + "1. Car\n" + "2. Home\n" + "3. Theft\n"); string typeAsString = Console.ReadLine(); int typeAsInt = int.Parse(typeAsString); ClaimType type = (ClaimType)typeAsInt; Console.WriteLine("Enter claim amount: "); string claimAmountString = Console.ReadLine(); decimal claimAmount = decimal.Parse(claimAmountString); Console.WriteLine("Enter date of incident: (Example: 9/8/2009) "); string dateOfIncidentString = Console.ReadLine(); DateTime dateOfIncident = DateTime.Parse(dateOfIncidentString); Console.WriteLine("Enter date of claim: (Example: 9/8/2009) "); string dateOfClaimString = Console.ReadLine(); DateTime dateOfClaim = DateTime.Parse(dateOfClaimString); ClaimContent content = new ClaimContent(claimID, type, claimAmount, dateOfIncident, dateOfClaim); _claimRepo.AddToList(content); }
private static XElement SerializaClaimType(ClaimType claimType) { XElement claimTypeElement = new XElement("claimType"); claimTypeElement.SetAttributeValue("fullName", claimType.FullName); claimTypeElement.SetAttributeValue("displayName", claimType.DisplayName); return(claimTypeElement); }
private void BindClaimType() { DropDownListClaimType.DataSource = ClaimType.GetClaimTypeList(); DropDownListClaimType.DataTextField = "Description"; DropDownListClaimType.DataValueField = "ClaimTypeId"; DropDownListClaimType.DataBind(); DropDownListClaimType.Items.Insert(0, new ListItem("Please select", "0")); }
private static Claim GetClaim(ClaimType claimType, IPrincipal user) { var identity = (ClaimsIdentity)user.Identity; IEnumerable <Claim> claims = identity.Claims; var identityClaim = claims.FirstOrDefault(n => n.Type == claimType.ToString()); return(identityClaim); }
public Claim(int claimID, ClaimType claimType, string claimDescription, double claimAmount, string dateOfAccident) { ClaimID = claimID; ClaimType = claimType; ClaimDescription = claimDescription; ClaimAmount = claimAmount; DateOfAccident = dateOfAccident; }
public Claim(ClaimType type, string desc, decimal amount, DateTime incidentDate, DateTime claimDate) : this() { this.ClaimType = type; this.Description = desc; this.ClaimAmount = amount; this.DateOfIncident = incidentDate; this.DateOfClaim = claimDate; }
public override void Deserialize(IoBuffer input, ISerializationContext context) { Status = input.GetEnum <TransferClaimResponseStatus>(); Type = input.GetEnum <ClaimType>(); EntityId = input.GetInt32(); ClaimId = input.GetUInt32(); NewOwner = input.GetPascalString(); }
public void ShouldMatchInputClaimAndCopyInputIssuerToOutputValue() { var store = new MockPolicyStore(); ClaimsPolicyEvaluator evaluator = new ClaimsPolicyEvaluator(store); ClaimType inputClaimType = new ClaimType("http://myInputClaimType"); ClaimType outputClaimType = new ClaimType("http://myOutputClaimType"); Issuer issuer = new Issuer("http://myInputClaimIssuer"); InputPolicyClaim inputClaim = new InputPolicyClaim(issuer, inputClaimType, "myInputClaim"); OutputPolicyClaim outputClaim = new OutputPolicyClaim(outputClaimType, string.Empty, CopyFromConstants.InputIssuer); PolicyRule rule = new PolicyRule(AssertionsMatch.Any, new[] { inputClaim }, outputClaim); store.RetrieveScopesReturnValue = new List<PolicyScope>() { new PolicyScope(new Uri("http://myScope"), new[] { rule }) }; IEnumerable<Claim> evaluatedOutputClaims = evaluator.Evaluate(new Uri("http://myScope"), new[] { new Claim("http://myInputClaimType", "myInputClaim", string.Empty, "http://myInputClaimIssuer") }); Assert.IsNotNull(evaluatedOutputClaims); Assert.AreEqual(1, evaluatedOutputClaims.Count()); Assert.AreEqual("http://myOutputClaimType", evaluatedOutputClaims.ElementAt(0).ClaimType); Assert.AreEqual("http://myInputClaimIssuer", evaluatedOutputClaims.ElementAt(0).Value); }
protected PolicyClaim(ClaimType claimType, string value) { this.ClaimType = claimType; this.Value = value; }
private static XElement SerializaClaimType(ClaimType claimType) { XElement claimTypeElement = new XElement("claimType"); claimTypeElement.SetAttributeValue("fullName", claimType.FullName); claimTypeElement.SetAttributeValue("displayName", claimType.DisplayName); return claimTypeElement; }
public InputPolicyClaim(Issuer issuer, ClaimType claimType, string value) : base(claimType, value) { this.Issuer = issuer; }
public AuthorizeUserAttribute(ClaimType countryClaim, ClaimType roleClaim, UserRoles countryRole, params UserRoles[] roles) { _roles = roles; _countryClaim = countryClaim; _roleClaim = roleClaim; }
private static OutputPolicyClaim RetrieveOutputClaim(XElement ruleElement, IDictionary<string, string> claimTypes) { string outputTypeDisplayName = ruleElement.Element("output").Attribute("type").Value; string outputClaimValue = string.Empty; if (ruleElement.Element("output").Attribute("value") != null) { outputClaimValue = ruleElement.Element("output").Attribute("value").Value; } string copyFrom = string.Empty; if (ruleElement.Element("output").Attribute("copyFrom") != null) { copyFrom = ruleElement.Element("output").Attribute("copyFrom").Value.ToUpperInvariant(); } if (!claimTypes.ContainsKey(outputTypeDisplayName)) { throw new PolicyClaimException(string.Format(CultureInfo.CurrentUICulture, Resources.ClaimTypeNotDefined, outputTypeDisplayName)); } ClaimType claimType = new ClaimType(claimTypes[outputTypeDisplayName], outputTypeDisplayName); return new OutputPolicyClaim(claimType, outputClaimValue, copyFrom); }
private static void ClaimDemand(ClaimType claim, SecureResource resource) { AuthorizationContext authContext = ServiceSecurityContext.Current.AuthorizationContext; ClaimSet issuerClaimSet = null; foreach (ClaimSet cs in authContext.ClaimSets) { if (cs.Issuer == _issuer) { issuerClaimSet = cs; break; } } if (issuerClaimSet == null) throw new PermissionException(string.Format("No claims for issuer {0} were provided.", _issuer[0].Resource)); var c = new Claim(ClaimType.All.ToString(), SecureResource.All, Rights.PossessProperty); if (issuerClaimSet.ContainsClaim(c)) // if administrator return; if (claim != ClaimType.All) { c = new Claim(ClaimType.All.ToString(), resource, Rights.PossessProperty); if (issuerClaimSet.ContainsClaim(c)) return; } if (resource != SecureResource.All) { c = new Claim(claim.ToString(), SecureResource.All, Rights.PossessProperty); if (issuerClaimSet.ContainsClaim(c)) return; } c = new Claim(claim.ToString(), resource, Rights.PossessProperty); if (issuerClaimSet.ContainsClaim(c)) return; throw new PermissionException(string.Format("Claim {0} for resource {1} is not satisfied.", claim, resource)); }
public void AddRuleShouldSetTheRightClaimTypeDisplayName() { var scope = RetrievePolicyScope(); var inputClaimType = new ClaimType("http://tests/sampleclaimtype/", string.Empty); var inputClaim = new InputPolicyClaim(sampleIssuer, inputClaimType, "new sample value"); var rule = new PolicyRule(AssertionsMatch.Any, new List<InputPolicyClaim> { inputClaim }, GetSampleOutputClaim()); Assert.AreEqual(string.Empty, inputClaimType.DisplayName); Assert.AreEqual(1, scope.ClaimTypes.Count); scope.AddRule(rule); Assert.AreEqual(sampleClaimType.DisplayName, inputClaimType.DisplayName); Assert.AreEqual(1, scope.ClaimTypes.Count); }
public void ShouldOutputCorrectInputValue() { var store = new MockPolicyStore(); ClaimsPolicyEvaluator evaluator = new ClaimsPolicyEvaluator(store); InputPolicyClaim inputPolicyClaim1 = new InputPolicyClaim(this.issuer, this.inputClaimType, "*"); ClaimType outputClaimType1 = new ClaimType("http://myOutputClaimType1"); OutputPolicyClaim outputPolicyClaim1 = new OutputPolicyClaim(outputClaimType1, "myOutputClaimValue"); PolicyRule policyRule1 = new PolicyRule(AssertionsMatch.Any, new[] { inputPolicyClaim1 }, outputPolicyClaim1); InputPolicyClaim inputPolicyClaim2 = new InputPolicyClaim(this.issuer, this.inputClaimType, "inputClaimValue"); ClaimType outputClaimType2 = new ClaimType("http://myOutputClaimType2"); OutputPolicyClaim outputPolicyClaim2 = new OutputPolicyClaim(outputClaimType2, string.Empty, CopyFromConstants.InputValue); PolicyRule policyRule2 = new PolicyRule(AssertionsMatch.Any, new[] { inputPolicyClaim2 }, outputPolicyClaim2); store.RetrieveScopesReturnValue = new List<PolicyScope>() { new PolicyScope(new Uri("http://myScope"), new[] { policyRule1, policyRule2 }) }; IEnumerable<Claim> evaluatedOutputClaims = evaluator.Evaluate(new Uri("http://myScope"), new[] { new Claim("http://myInputClaimType", "inputClaimValue", string.Empty, "http://myInputClaimIssuer") }); Assert.IsNotNull(evaluatedOutputClaims); Assert.AreEqual(2, evaluatedOutputClaims.Count()); var outputClaim1 = evaluatedOutputClaims.FirstOrDefault(c => c.ClaimType == "http://myOutputClaimType1"); Assert.IsNotNull(outputClaim1); Assert.AreEqual("myOutputClaimValue", outputClaim1.Value); var outputClaim2 = evaluatedOutputClaims.FirstOrDefault(c => c.ClaimType == "http://myOutputClaimType2"); Assert.IsNotNull(outputClaim2); Assert.AreEqual("inputClaimValue", outputClaim2.Value); }
public void AddToClaimTypes(ClaimType claimType) { base.AddObject("ClaimTypes", claimType); }
public static ClaimType CreateClaimType(long ID, bool systemReserved) { ClaimType claimType = new ClaimType(); claimType.Id = ID; claimType.SystemReserved = systemReserved; return claimType; }
public WikidataClaim() { this._valueAsDateTime = new Wikidate(); Type = new ClaimType(); Qcode = 0; }
public void ShouldThrowIfScopeIsNotFoundOnStore() { var store = new MockPolicyStore(); Issuer issuer = new Issuer("http://myIssuer", "myIssuer"); ClaimType myClaimType = new ClaimType("http://myClaimType", "myClaimType"); store.RetrieveScopesReturnValue = new List<PolicyScope>() { new PolicyScope( new Uri("http://mappedScope"), new[] { new PolicyRule(AssertionsMatch.All, new[] { new InputPolicyClaim(issuer, myClaimType, "myClaimValue") }, new OutputPolicyClaim(myClaimType, string.Empty, CopyFromConstants.InputValue)) }) }; ClaimsPolicyEvaluator evaluator = new ClaimsPolicyEvaluator(store); evaluator.Evaluate(new Uri("http://unmappedScope"), new[] { new Claim("http://myInputClaimType", "myInputClaim") }); }
public AuthorizeUserAttribute(ClaimType roleClaim, params UserRoles[] roles) { _roles = roles; _roleClaim = roleClaim; }
private static IEnumerable<InputPolicyClaim> RetrieveInputClaims(XElement ruleElement, IDictionary<string, Issuer> issuers, IDictionary<string, string> claimTypes) { List<InputPolicyClaim> inputClaims = new List<InputPolicyClaim>(); foreach (XElement inputClaimElement in ruleElement.Element("input").Descendants("claim")) { string inputClaimValue = inputClaimElement.Attribute("value").Value; string inputIssuerDisplayName = inputClaimElement.Attribute("issuer").Value; string inputTypeDisplayName = inputClaimElement.Attribute("type").Value; if (!issuers.ContainsKey(inputIssuerDisplayName)) { throw new PolicyClaimException(string.Format(CultureInfo.CurrentUICulture, Resources.IssuerNotDefined, inputIssuerDisplayName)); } if (!claimTypes.ContainsKey(inputTypeDisplayName)) { throw new PolicyClaimException(string.Format(CultureInfo.CurrentUICulture, Resources.ClaimTypeNotDefined, inputTypeDisplayName)); } Issuer issuer = issuers[inputIssuerDisplayName]; ClaimType claimType = new ClaimType(claimTypes[inputTypeDisplayName], inputTypeDisplayName); inputClaims.Add(new InputPolicyClaim(issuer, claimType, inputClaimValue)); } return inputClaims; }