Ejemplo n.º 1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || ServiceLocator.Current == null)
            {
                return(Visibility.Visible);
            }

            IPermissionValidationInfo info = null;

            if (value is IPermissionValidationInfo)
            {
                info = value as IPermissionValidationInfo;
            }

            if (value is IMenuInfo)
            {
                info = ((IMenuInfo)value).PermissionValidation;
            }

            if (info == null)
            {
                return(Visibility.Visible);
            }

            //var service = InternalShare.AuthenticationService;

            //if (service != null && service.IsValid(info))
            //    return Visibility.Visible;

            return(Visibility.Collapsed);
        }
Ejemplo n.º 2
0
        public virtual bool Validate(IPermissionValidationInfo validationInfo)
        {
            Guard.ArgumentIsNotNull(validationInfo, nameof(validationInfo));

            if (IsAdaptFor(validationInfo))
            {
                return(Validate(validationInfo as TValidationInfo));
            }

            throw new NotSupportedException($"The Authentication Adapter {this.GetType().FullName} is not supporting {validationInfo.GetType().FullName}");
        }
Ejemplo n.º 3
0
        public bool IsValid(IPermissionValidationInfo info)
        {
            if (info == null)
            {
                return(true);
            }
            if (!IsAuthenticated)
            {
                return(false);
            }

            var adapters = this.Adapters.Where(a => a.IsAdaptFor(info)).ToList();

            if (adapters.Count <= 0)
            {
                throw new InstanceNotFoundException($"Authentication Adapter for {info.GetType().FullName} is not found.");
            }

            return(adapters.Any(a => a.Validate(info)));
        }
Ejemplo n.º 4
0
 public virtual bool IsAdaptFor(IPermissionValidationInfo validationInfo) => validationInfo is TValidationInfo;
Ejemplo n.º 5
0
 public RoleActionCommand(Action <object> executeAction, Func <object, bool> canExecuteAction,
                          IPermissionValidationInfo info) : base(executeAction, canExecuteAction)
 {
     PermissionInfo = info;
 }