コード例 #1
0
 public WorkflowToolbarVm(ISecurityUser securityUser, int objectID, string objectType)
 {
     this.CurrentUser = securityUser;
     this.ObjectType = objectType;
     this.ObjectID = objectID;
     this.Stages = new List<StageVM>();
 }
コード例 #2
0
        /***************************** Context **************************/

        /// <summary>
        /// Creates a new instance of the SecurityContext using the passed user instance and the SecuritySystem.
        /// </summary>
        public SecurityContext(ISecurityUser currentUser, SecuritySystem securitySystem)
        {
            CurrentUser      = currentUser;
            SecuritySystem   = securitySystem;
            Evaluator        = new PermissionEvaluator(this);
            _permissionQuery = SecuritySystem.PermissionQuery;
        }
コード例 #3
0
        public WorkflowUserService(
            IUnitOfWork unitOfWork)
        {

            if (_manager == null)
            {
                var repository = unitOfWork.GetRepository<User>();

                var user = repository.Find(x => x.Login == "WorkflowManager");
                if (user == null)
                {
                    user = new User
                    {
                        Login = "******",
                        CategoryID = 1,
                        Roles = new List<Role> {
                            new Role {
                                ChildRoles = new List<ChildRole>(),
                                Permissions = new List<Permission>(),
                                Name = "WorkflowManagerRole",
                                SystemRole = SystemRole.Admin
                            }
                        },
                        FirstName = "Менеджер бизнес-процессов"
                    };

                    repository.Create(user);
                    unitOfWork.SaveChanges();
                }

                _manager = new SecurityUser(user);
            }
        }
コード例 #4
0
 public LocalContextSecurityUser(ISecurityUser newUser, ISecurityUser restoreUser, AppContextBootstrapper appContextBootstrapper)
 {
     _restoreUser = restoreUser;
     _appContextBootstrapper = appContextBootstrapper;
     _appContextBootstrapper.RemoveSecurityUser();
     _appContextBootstrapper.SetSecurityUser(newUser);
 }
コード例 #5
0
        public virtual void Logon(string userName, string password)
        {
            ISecurityUser currentUser = GetUserByCredentials(userName, password);

            if (currentUser == null)
            {
                throw new InvalidOperationException("Logon is failed. Try enter right credentials.");
            }
            Logon(currentUser);
        }
コード例 #6
0
        public void SetSecurityUser(ISecurityUser securityUser)
        {
            if (securityUser == null)
                throw new ArgumentNullException("securityUser");

            //var user = GetSecurityUser();
            //if (user != null)
            //    throw new InvalidOperationException("The user should be set only once");

            CallContext.LogicalSetData(s_userKey, securityUser);
        }
コード例 #7
0
        public bool Authenticate(ISecurityUser user, out string token)
        {
            if (!string.Equals(user.Username, "admin") || !string.Equals(user.Password, "password"))
            {
                token = null;
                return(false);
            }

            token = Guid.NewGuid().ToString("N");
            userTokenMap[token] = user;
            return(true);
        }
コード例 #8
0
        private static string GetMessage(string msg, string path, int entityId, ISecurityUser user, PermissionTypeBase[] permissionTypes)
        {
            var sb = new StringBuilder(msg ?? "Access denied.");

            if (path != null)
            {
                sb.Append(" Path: ").Append(path);
            }
            if (entityId != default)
            {
                sb.Append(" EntityId: ").Append(entityId);
            }
            if (user != null)
            {
                sb.Append(" UserId: ").Append(user.Id);
            }
            if (permissionTypes != null)
            {
                sb.Append(" PermissionTypes: ").Append(string.Join(", ", permissionTypes.Select(pt => pt.Name)));
            }
            return(sb.ToString());
        }
コード例 #9
0
 public void ModifyObject(ISecurityUser securityUser, BaseObject src, IEnumerable<InitItem> inits)
 {
     _objectInitializer.InitializeObject(securityUser, src, src, inits);
 }
コード例 #10
0
 /// <summary>
 /// Creates a new instance of the SecurityContext using the passed user instance
 /// and pointers to the ISecurityDataProvider, IMessageProvider and SecurityCache global objects.
 /// </summary>
 public SecurityContext(ISecurityUser currentUser)
 {
     CurrentUser  = currentUser;
     DataProvider = _securityDataProviderPrototype.CreateNew();
     Cache        = _cacheHolder;
 }
コード例 #11
0
ファイル: BaseViewModel.cs プロジェクト: altaricka/vDesign
        public BaseViewModel(BaseViewModel baseViewModel)
        {
            _securityUser = baseViewModel.SecurityUser;

            _viewModelConfigs = baseViewModel.ViewModelConfigs;
        }
 protected virtual IEnumerable <IPermission> GetAllPermissions(ISecurityUser securityUser)
 {
     return(securityUser.GetPermissions());
 }
コード例 #13
0
 public MissingEntityResolverContext(ISecurityUser user) : base(user)
 {
 }
コード例 #14
0
ファイル: Context.cs プロジェクト: SenseNet/sn-security
 public Context(ISecurityUser currentUser, SecuritySystem securitySystem)
 {
     // Create a new instance.
     Security = new SecurityContext(currentUser, securitySystem);
 }
コード例 #15
0
 public SecurityContextForConcurrencyTests(ISecurityUser currentUser) : base(currentUser)
 {
 }
コード例 #16
0
ファイル: MenuService.cs プロジェクト: altaricka/vDesign
 private string GetUserKeyCache(ISecurityUser user)
 {
     return String.Format("{1}:{0}", _keyCache, user.GetKey());
 }
コード例 #17
0
ファイル: ObjectAccessItem.cs プロジェクト: altaricka/vDesign
 public ObjectAccessItem(ISecurityUser securityUser, BaseObject obj)
     : this(securityUser.ID, obj) { }
コード例 #18
0
ファイル: BaseViewModel.cs プロジェクト: altaricka/vDesign
 public BaseViewModel(BaseViewModel baseViewModel)
 {
     _securityUser = baseViewModel.SecurityUser;
     _uiFasade = baseViewModel.UiFasade;
 }
コード例 #19
0
ファイル: MenuService.cs プロジェクト: altaricka/vDesign
 public void Clear(ISecurityUser user)
 {
     _cacheWrapper.Remove(GetUserKeyCache(user));
 }
コード例 #20
0
ファイル: BaseViewModel.cs プロジェクト: altaricka/vDesign
 public BaseViewModel(IBaseController controller)
 {
     _securityUser = controller.SecurityUser;
     _uiFasade = controller.UiFasade;
 }
コード例 #21
0
        public void InitializeObject(ISecurityUser securityUser, BaseObject src, BaseObject dest, IEnumerable<Entities.InitItem> inits)
        {
            var resultScript = String.Empty;

            try
            {
                var engine = Python.CreateEngine();

                engine.Runtime.LoadAssembly(Assembly.GetExecutingAssembly());

                var scope = engine.CreateScope(new Dictionary<string, object> { { "Dest", dest }, { "Src", src } });

                IEnumerable<RefObject> refObjects;

                var macroses = PrepareMacros(dest, inits, out refObjects);

                foreach (var refObj in refObjects)
                    scope.SetVariable(String.Format("_refobject_{0}", refObj.Property.Name), refObj.Object);

                foreach (var pair in macroses.AsEnumerable().Reverse())
                {
                    var script = new StringBuilder(String.Format("Dest.{0} =", pair.Property.Name));

                    foreach (var initItem in pair.Macroses)
                    {
                        switch (initItem.MacroType)
                        {
                            case MacroType.String:
                                script.AppendFormat(" '{0}'", initItem.Value);
                                break;
                            case MacroType.Number:
                                {
                                    if (pair.Property.PropertyType.IsEnum)
                                    {
                                        var tempName = String.Format("_enum{0}", pair.Property.Name);

                                        scope.SetVariable(tempName, Enum.Parse(pair.Property.PropertyType, initItem.Value));

                                        script.AppendFormat(tempName);

                                        break;
                                    }

                                    goto case MacroType.Operator;
                                }
                            case MacroType.Boolean:
                            {
                                script.AppendFormat(" '{0}'", initItem.Value);

                                break;
                            }
                            case MacroType.Operator:
                                script.AppendFormat(" {0}", initItem.Value);
                                break;
                            case MacroType.InitObject:
                                {
                                    script.AppendFormat(" Src.{0}", initItem.Value);
                                    break;
                                }
                            case MacroType.BaseObject:
                                if (dest is ICategorizedItem)
                                {
                                    var foreignKey = pair.Property.GetCustomAttribute<ForeignKeyAttribute>();

                                    if (foreignKey != null && foreignKey.Name == "CategoryID")
                                    {
                                        script.Append(" None");

                                        dest.GetType().GetProperty("CategoryID").SetValue(dest, JsonConvert.DeserializeObject<ObjectRefItem>(initItem.Value).ID);

                                        break;
                                    }
                                }

                                script.AppendFormat(" _refobject_{0}", pair.Property.Name);
                                break;
                            case MacroType.Function:
                                if (initItem.Value == "dtn()")
                                {
                                    var locVar = this.GenerateVaribleName();

                                    scope.SetVariable(locVar, DateTime.Now);

                                    script.AppendFormat(" {0}", locVar);
                                }
                                break;
                            case MacroType.DateTime:
                            {
                                DateTime dt;
                                if (DateTime.TryParse(initItem.Value, out dt))
                                {
                                    var locVar = this.GenerateVaribleName();

                                    scope.SetVariable(locVar, dt);

                                    script.AppendFormat(" {0}", locVar);

                                    break;
                                }

                                throw ExceptionHelper.ActionInvokeException(
                                    String.Format("Дата имеет неверный формат {0} -> {1}", pair.Property.Name, initItem.Value));
                            }
                            case MacroType.TimeSpan:
                            {
                                double minutes;
                                if (double.TryParse(initItem.Value, out minutes))
                                {
                                    var locVar = this.GenerateVaribleName();

                                    scope.SetVariable(locVar, TimeSpan.FromMinutes(minutes));

                                    script.AppendFormat(" {0}", locVar);

                                    break;
                                }

                                throw ExceptionHelper.ActionInvokeException(
                                    String.Format("Временной интервал имел неверный формат {0} -> {1}", pair.Property.Name, initItem.Value));
                            }

                            default:
                                throw new ArgumentOutOfRangeException();
                        }
                    }

                    script.Append(";");

                    resultScript = script.ToString();

                    engine.Execute(resultScript, scope);
                }
            }
            catch (Exception e)
            {
                throw new ScriptExecutionException("Ошибка выполнения макроса" + Environment.NewLine + resultScript, e)
                    .IfNotNull(x => x.Data["Script"] = resultScript);
            }
        }
コード例 #22
0
ファイル: BaseViewModel.cs プロジェクト: altaricka/vDesign
 public BaseViewModel(ISecurityUser securityUser, IReadOnlyList<ViewModelConfig> viewModelConfigs)
 {
     _securityUser = securityUser;
     _viewModelConfigs = viewModelConfigs;
 }
コード例 #23
0
 /// <summary>Initializes a new instance of the AccessDeniedException class.</summary>
 public AccessDeniedException(string message, string path, int entityId, ISecurityUser user, PermissionTypeBase[] permissionTypes)
     : base(GetMessage(message, path, entityId, user, permissionTypes))
 {
 }
コード例 #24
0
 public void Clear(ISecurityUser securityUser)
 {
     Clear(securityUser.Login);
 }
コード例 #25
0
ファイル: SupportQA.cs プロジェクト: altaricka/vDesign
 public bool IsEnabled(ISecurityUser user)
 {
     return Status == SupportQAStatus.Created;
 }
コード例 #26
0
ファイル: BaseViewModel.cs プロジェクト: altaricka/vDesign
 public BasePageViewModel(ISecurityUser securityUser, IReadOnlyList<ViewModelConfig> viewModelConfigs) : base(securityUser, viewModelConfigs)
 {
     ThemeColor = "#4a4560";
 }
コード例 #27
0
ファイル: ObjectAccessItem.cs プロジェクト: altaricka/vDesign
 public ObjectAccessItem(ISecurityUser securityUser, Type type, int id)
     : this(securityUser.ID, type, id) { }
コード例 #28
0
ファイル: BaseViewModel.cs プロジェクト: altaricka/vDesign
 public ContentPageViewModel(ISecurityUser securityUser, IReadOnlyList<ViewModelConfig> viewModelConfigs) : base(securityUser, viewModelConfigs)
 {
 }
コード例 #29
0
ファイル: ContentItem.cs プロジェクト: altaricka/vDesign
 public bool IsEnabled(ISecurityUser user)
 {
     return true;
     //return this.ContentItemStatus == ContentItemStatus.New
     //    || this.ContentItemStatus == ContentItemStatus.Rework;
 }
コード例 #30
0
 public IDisposable LocalContextSecurity(ISecurityUser securityUser)
 {
     return new LocalContextSecurityUser(securityUser, GetSecurityUser(), this);
 }
コード例 #31
0
 public TestSecurityContext(ISecurityUser currentUser) : base(currentUser)
 {
 }
コード例 #32
0
 public ServiceSecurityContext(ISecurityUser currentUser, SecuritySystem securitySystem) : base(currentUser, securitySystem)
 {
 }
コード例 #33
0
        public virtual void Logon(ISecurityUser user)
        {
            IAuthorization authorization = (IAuthorization)this.GetService <IPermissionsProvider>();

            authorization.Logon(user);
        }
 public virtual void Logoff()
 {
     SecurityUser = null;
 }
コード例 #35
0
ファイル: Task.cs プロジェクト: altaricka/vDesign
 public bool IsEnabled(ISecurityUser user)
 {
     return !this.Auto &&
            (this.AssignedFromID == user.ID &&
             (this.Status == TaskStatus.New || this.Status == TaskStatus.Redirection ||
              this.Status == TaskStatus.Refinement))
            ||
            (this.AssignedToID == user.ID &&
             (this.Status == TaskStatus.Viewed || this.Status == TaskStatus.InProcess ||
              this.Status == TaskStatus.Rework));
 }
コード例 #36
0
 public void InitializeObject(ISecurityUser securityUser, BaseObject src, BaseObject dest,
     IEnumerable<InitItem> inits)
 {
     _objectInitializer.InitializeObject(securityUser, src, dest, inits);
 }
コード例 #37
0
        public void OnEnterToExtendedStage(ISecurityUser securityUser, ExtendedStage extendedStage, BaseObject baseObject)
        {
            var service = GetExtenderService(extendedStage);

            service.OnStageEnter(securityUser, extendedStage, extendedStage.Extender, baseObject);
        }
コード例 #38
0
ファイル: BaseViewModel.cs プロジェクト: altaricka/vDesign
        public BaseViewModel(IBaseController controller)
        {
            _securityUser = controller.SecurityUser;

            _viewModelConfigs = controller.ViewModelConfigs;
        }
コード例 #39
0
        public void OnLeaveFromExtendedStage(ISecurityUser securityUser, ExtendedStage extendedStage, BaseObject baseObject)
        {
            var service = GetExtenderService(extendedStage);

            service.OnStageLeave(securityUser, extendedStage, extendedStage.Extender, baseObject);
        }
コード例 #40
0
        public IQueryable<Workflow> GetWorkflowList(ISecurityUser securityUser, Type type, BaseObject model, IQueryable<Workflow> all)
        {
            var listStrategy = _strategyService.GetCommonStrategyInstance<IWorkflowListStrategy>(x => x.EntityType == type) ??
                               new WorkflowListStrategy<BaseObject>();

            return listStrategy.GetWorkflows(securityUser, model, all).Where(x => x.ObjectType == type.FullName);
        }
コード例 #41
0
ファイル: Context.cs プロジェクト: lomtec-sn/sn-security
 public Context(ISecurityUser currentUser)
 {
     // Create a new instance.
     Security = new TestSecurityContext(currentUser);
 }
 public virtual void Logon(ISecurityUser securityUser)
 {
     this.SecurityUser = securityUser;
 }