public override bool IsMemberModificationDenied(object targetObject, IMemberInfo memberInfo) {
     if (memberInfo.GetPath().Any(currentMemberInfo =>!SecuritySystem.IsGranted(new MemberAccessPermission(
                                                                      currentMemberInfo.Owner.Type,
                                                                      currentMemberInfo.Name,
                                                                      MemberOperation.Write)))) {
         return true;
     }
     return base.IsMemberModificationDenied(targetObject, memberInfo);
 }
 public override bool IsMemberModificationDenied(object targetObject, IMemberInfo memberInfo) {
     bool firstOrDefault =memberInfo.GetPath().Select(info =>!SecuritySystemExtensions.IsGranted(
                 new MemberAccessPermission(info.Owner.Type, info.Name, MemberOperation.Write), true)).Where(b => b).FirstOrDefault();
     if (firstOrDefault) {
         return Fit(targetObject,MemberOperation.Write);
     }
     var securityComplex = ((SecurityBase)SecuritySystem.Instance);
     bool isGrantedForNonExistentPermission = securityComplex.IsGrantedForNonExistentPermission;
     securityComplex.IsGrantedForNonExistentPermission = true;
     bool isMemberModificationDenied = base.IsMemberModificationDenied(targetObject, memberInfo);
     securityComplex.IsGrantedForNonExistentPermission = isGrantedForNonExistentPermission;
     return isMemberModificationDenied;
 }
        public override bool IsMemberModificationDenied(object targetObject, IMemberInfo memberInfo)
        {
            var         objectType     = targetObject == null ? memberInfo.Owner.Type : targetObject.GetType();
            IMemberInfo firstOrDefault = memberInfo.GetPath().FirstOrDefault(info => !SecuritySystemExtensions.IsGranted(
                                                                                 new MemberAccessPermission(objectType, info.Name, MemberOperation.Write), true));

            if (firstOrDefault != null)
            {
                return(Fit(targetObject, memberInfo, MemberOperation.Write));
            }
            var  securityComplex = ((SecurityBase)SecuritySystem.Instance);
            bool isGrantedForNonExistentPermission = securityComplex.IsGrantedForNonExistentPermission;

            securityComplex.IsGrantedForNonExistentPermission = true;
            bool isMemberModificationDenied = base.IsMemberModificationDenied(targetObject, memberInfo);

            securityComplex.IsGrantedForNonExistentPermission = isGrantedForNonExistentPermission;
            return(isMemberModificationDenied);
        }
        public override bool IsMemberReadGranted(Type requestedType, string propertyName,
                                                 SecurityContextList securityContexts)
        {
            ITypeInfo   typeInfo   = XafTypesInfo.Instance.FindTypeInfo(requestedType);
            IMemberInfo memberInfo = typeInfo.FindMember(propertyName);

            if (memberInfo.GetPath().Any(currentMemberInfo
                                         => !SecuritySystemExtensions.IsGranted(new MemberAccessPermission(currentMemberInfo.Owner.Type,
                                                                                                           currentMemberInfo.Name, MemberOperation.Read), true)))
            {
                return(false);
            }
            var  securityComplex = ((SecurityBase)SecuritySystem.Instance);
            bool isGrantedForNonExistentPermission = securityComplex.IsGrantedForNonExistentPermission;

            securityComplex.IsGrantedForNonExistentPermission = true;
            bool isMemberReadGranted = base.IsMemberReadGranted(requestedType, propertyName, securityContexts);

            securityComplex.IsGrantedForNonExistentPermission = isGrantedForNonExistentPermission;
            return(isMemberReadGranted);
        }
Esempio n. 5
0
 public void Setup(XafApplication application, IObjectSpace objectSpace, IModelMemberViewItem model) {
     _application = application;
     _objectSpace = objectSpace;
     _model = model;
     _propertyMemberInfo = null;
     _dataSourceMemberInfo = null;
     ITypeInfo typeInfo = GetObjectTypeInfo(model);
     if (typeInfo == null) return;
     _propertyMemberInfo = typeInfo.FindMember(model.PropertyName);
     if (!String.IsNullOrEmpty(model.DataSourceProperty)) {
         var builder = new StringBuilder(model.DataSourceProperty);
         IList<IMemberInfo> path = _propertyMemberInfo.GetPath();
         for (int index = path.Count - 2; index >= 0; index--)
             builder.Insert(0, ".").Insert(0, path[index].Name);
         _dataSourceMemberInfo = typeInfo.FindMember(builder.ToString());
     }
     Init(_propertyMemberInfo.MemberType);
 }
Esempio n. 6
0
 public static Object FindLastObject(Object sourceObject, IMemberInfo memberInfo) {
     Object lastObject = null;
     Object currObject = sourceObject;
     IList<IMemberInfo> path = memberInfo.GetPath();
     foreach (IMemberInfo t in path) {
         if (SimpleTypes.IsSimpleType(t.MemberType)) break;
         currObject = t.GetValue(currObject);
         lastObject = currObject;
     }
     return lastObject;
 }
 public void Setup(XafApplication application, IObjectSpace objectSpace, IModelMemberViewItem model)
 {
     /* Applicatie / Objectspace. */
     this._application = application;
     this._objectSpace = objectSpace;
     this._model = model;
     /* Reset member infos. */
     _propertyMemberInfo = null;
     _dataSourceMemberInfo = null;
     /* Get TypeInfo for view object. If not present, nothing to do. */
     var typeInfo = GetObjectTypeInfo(model);
     if (typeInfo == null) return;
     /* Get member info for property associated to the editor. */
     _propertyMemberInfo = typeInfo.FindMember(model.PropertyName);
     /* Analyse datasource property. */
     if (!String.IsNullOrEmpty(model.DataSourceProperty))
     {
         /* Create appropriate datasource property path relative to editor property.
          * This makes the datasource work with nested properties (xxxx.yyyy.EnunPropertyField)
          * as well. */
         StringBuilder builder = new StringBuilder(model.DataSourceProperty);
         var path = _propertyMemberInfo.GetPath();
         for (int index = path.Count - 2; index >= 0; index--)
             // property path delimiter
             builder.Insert(0, ".").Insert(0, path[index].Name);
         /* Get the member. */
         _dataSourceMemberInfo = typeInfo.FindMember(builder.ToString());
     }
     /* default initialisation */
     Init(_propertyMemberInfo.MemberType);
 }