예제 #1
0
        public static SecurityObjectPermission CreateRolePermission(this ISecurityObjectPermission permission)
        {
            SecurityObjectPermission securityOperationPermission = new SecurityObjectPermission();

            securityOperationPermission.SetValue(permission);
            return(securityOperationPermission);
        }
예제 #2
0
 public static void SetValue(this SecurityObjectPermission operationPermission, IObjectPermission permission)
 {
     operationPermission.Operations     = permission.Operations;
     operationPermission.OperationState = permission.OperationState;
     operationPermission.Type           = permission.Type;
     operationPermission.Criteria       = permission.Criteria;
 }
예제 #3
0
        public static void SetValue(this SecurityObjectPermission operationPermission, ISecurityObjectPermission permission)
        {
            operationPermission.Operations     = permission.Operations;
            operationPermission.OperationState = permission.OperationState;
            CriteriaSerializer criteriaSerializer = new CriteriaSerializer();

            // TODO: more checks are needed...
            operationPermission.Type     = ((ParameterExpression)criteriaSerializer.Deserialize(permission.StringType)).Type;
            operationPermission.Criteria = (LambdaExpression)criteriaSerializer.Deserialize(permission.StringCriteria);
        }
        public virtual IObjectPermission AddObjectPermission <TSource, TargetType>(SecurityOperation operation, OperationState state, Expression <Func <TSource, TargetType, bool> > criteria) where TSource : BaseSecurityDbContext
        {
            SecurityObjectPermission objectPermission = new SecurityObjectPermission();

            objectPermission.Type           = typeof(TargetType);
            objectPermission.Criteria       = criteria;
            objectPermission.Operations     = operation;
            objectPermission.OperationState = state;
            this.ObjectPermissions.Add(objectPermission);
            return(objectPermission);
        }