public object ReadYaml(IParser parser, Type type) { IAccessControlEntry ace = null; if (typeof(IAccessControlEntry).IsAssignableFrom(type) && parser.Current.GetType() == typeof(MappingStart)) { parser.MoveNext(); // skip the sequence start Dictionary <string, string> props = new Dictionary <string, string>(); while (parser.Current.GetType() != typeof(MappingEnd)) { string prop = ((Scalar)parser.Current).Value; parser.MoveNext(); string value = ((Scalar)parser.Current).Value; parser.MoveNext(); props[prop] = value; } parser.MoveNext(); bool isAuditAce = typeof(IAccessControlEntryAudit).IsAssignableFrom(type); if (props.ContainsKey(RightFields.RightType)) { ace = AccessControlEntryUtilities.MakeAceFromRightType(props[RightFields.RightType], props, isAuditAce); } } return(ace); }
public override object ReadJson(JsonReader reader, Type type, object existingValue, JsonSerializer serializer) { IAccessControlEntry ace = null; Dictionary <string, string> props = new Dictionary <string, string>(); JObject aceJson = JObject.Load(reader); foreach (JProperty prop in aceJson.Properties()) { props[prop.Name] = prop.Value.ToString(); } bool isAuditAce = typeof(IAccessControlEntryAudit).IsAssignableFrom(type) || props.ContainsKey(RightFields.Denied); if (props.ContainsKey(RightFields.RightData)) { props.Remove(RightFields.RightData); props[RightFields.RightType] = aceJson[RightFields.RightData].SelectToken(RightFields.RightType).ToString(); } if (props.ContainsKey(RightFields.RightType)) { ace = AccessControlEntryUtilities.MakeAceFromRightType(props[RightFields.RightType], props, isAuditAce); } return(ace); }
int EvalRights(int allowedMask, int deniedMask) { Type rightType = Ace.RightData.RightType; IAccessControlEntry allowedAce = AccessControlEntryUtilities.MakeGenericAceFromType(rightType); allowedAce.Allowed = true; allowedAce.SetRight(allowedMask.ToString()); IAccessControlEntry deniedAce = AccessControlEntryUtilities.MakeGenericAceFromType(rightType); deniedAce.Allowed = false; deniedAce.SetRight(deniedMask.ToString()); _sd.Clear(); _sd.Dacl.Add(allowedAce); _sd.Dacl.Add(deniedAce); _sd.Eval(rightType); //suppress reentrancy into this function: IsChecked=true fires CheckBox_Checked _suppressRightsEval = true; int mask = 0; foreach (CheckBox cb in this.Items) { cb.IsChecked = _sd.Results.GetByTypeRight(rightType, (int)cb.Content).AccessAllowed; if (cb.IsChecked.Value) { mask |= (int)cb.Content; } } _suppressRightsEval = false; return(mask); }