Exemplo n.º 1
0
 public static AclEditModel AddTargets <TDomain>(this AclEditModel m, ISecurityService <TDomain> sec, IEnumerable <SecurityTarget> ts)
 {
     //Contract.Requires( m != null );
     //Contract.Requires( ts != null );
     //Contract.Ensures( //Contract.Result<AclEditModel>() != null );
     return(m.AddEntries(AllEntriesForEdit(sec, ts)));
 }
Exemplo n.º 2
0
 public IHtmlString With(AclEditModel model, string fieldName)
 {
     return(Html.Partial <Views.AccessControlList.Acl>().WithModel(
                new AccessControlListModel
     {
         Parameters = new AccessControlListParameters {
             Html = Html, FieldName = fieldName, SubjectSelector = model.SubjectSelector(Html)
         },
         InitialEntries = (from t in model.Entries
                           let target = t.Key
                                        from e in t.Where(FilterNullSubjects)
                                        group new { target, e } by e.Entry.Subject into subj
                           let es = subj.Select(e => new { tp = TargetPrivilege.Pair(e.target, e.e.Entry.Privilege.SID, null), e = e.e })
                                    select new PrivilegesListModel
         {
             Subject = subj.Key,
             OwnEntries = es.Where(e => e.e.InheritedFrom == null).Select(e => Pair.Create(e.tp, e.e.Entry.Kind)),
             InheritedEntries = es.Where(e => e.e.InheritedFrom != null).Select(e =>
                                                                                Pair.Create(e.tp, new InheritedPrivilegeModel {
                 Kind = e.e.Entry.Kind, InheritedFrom = e.e.InheritedFrom
             }))
         }
                           ).ToList(),
         PrivilegeEditors = model.PrivilegeEditors
     }));
 }
Exemplo n.º 3
0
        public static AclEditModel AddEntries(this AclEditModel m, ILookup <BigTuple <Guid>, AnnotatedAclEntry> entries)
        {
            //Contract.Requires( m != null );
            //Contract.Requires( entries != null );
            //Contract.Ensures( //Contract.Result<AclEditModel>() != null );

            return(new AclEditModel
            {
                Entries = m.Entries.Merge(entries),
                SubjectSelector = m.SubjectSelector,
                PrivilegeEditors = m.PrivilegeEditors
            });
        }
Exemplo n.º 4
0
        public static AclEditModel AddPrivilegesEditor(this AclEditModel m, IJsControlledView editor)
        {
            //Contract.Requires( m != null );
            //Contract.Requires( editor != null );
            //Contract.Ensures( //Contract.Result<AclEditModel>() != null );

            return(new AclEditModel
            {
                Entries = m.Entries,
                SubjectSelector = m.SubjectSelector,
                PrivilegeEditors = m.PrivilegeEditors.EmptyIfNull().Concat(new[] { editor })
            });
        }