public WorkflowToolbarVm(ISecurityUser securityUser, int objectID, string objectType) { this.CurrentUser = securityUser; this.ObjectType = objectType; this.ObjectID = objectID; this.Stages = new List<StageVM>(); }
/***************************** 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; }
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); } }
public LocalContextSecurityUser(ISecurityUser newUser, ISecurityUser restoreUser, AppContextBootstrapper appContextBootstrapper) { _restoreUser = restoreUser; _appContextBootstrapper = appContextBootstrapper; _appContextBootstrapper.RemoveSecurityUser(); _appContextBootstrapper.SetSecurityUser(newUser); }
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); }
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); }
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); }
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()); }
public void ModifyObject(ISecurityUser securityUser, BaseObject src, IEnumerable<InitItem> inits) { _objectInitializer.InitializeObject(securityUser, src, src, inits); }
/// <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; }
public BaseViewModel(BaseViewModel baseViewModel) { _securityUser = baseViewModel.SecurityUser; _viewModelConfigs = baseViewModel.ViewModelConfigs; }
protected virtual IEnumerable <IPermission> GetAllPermissions(ISecurityUser securityUser) { return(securityUser.GetPermissions()); }
public MissingEntityResolverContext(ISecurityUser user) : base(user) { }
public Context(ISecurityUser currentUser, SecuritySystem securitySystem) { // Create a new instance. Security = new SecurityContext(currentUser, securitySystem); }
public SecurityContextForConcurrencyTests(ISecurityUser currentUser) : base(currentUser) { }
private string GetUserKeyCache(ISecurityUser user) { return String.Format("{1}:{0}", _keyCache, user.GetKey()); }
public ObjectAccessItem(ISecurityUser securityUser, BaseObject obj) : this(securityUser.ID, obj) { }
public BaseViewModel(BaseViewModel baseViewModel) { _securityUser = baseViewModel.SecurityUser; _uiFasade = baseViewModel.UiFasade; }
public void Clear(ISecurityUser user) { _cacheWrapper.Remove(GetUserKeyCache(user)); }
public BaseViewModel(IBaseController controller) { _securityUser = controller.SecurityUser; _uiFasade = controller.UiFasade; }
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); } }
public BaseViewModel(ISecurityUser securityUser, IReadOnlyList<ViewModelConfig> viewModelConfigs) { _securityUser = securityUser; _viewModelConfigs = viewModelConfigs; }
/// <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)) { }
public void Clear(ISecurityUser securityUser) { Clear(securityUser.Login); }
public bool IsEnabled(ISecurityUser user) { return Status == SupportQAStatus.Created; }
public BasePageViewModel(ISecurityUser securityUser, IReadOnlyList<ViewModelConfig> viewModelConfigs) : base(securityUser, viewModelConfigs) { ThemeColor = "#4a4560"; }
public ObjectAccessItem(ISecurityUser securityUser, Type type, int id) : this(securityUser.ID, type, id) { }
public ContentPageViewModel(ISecurityUser securityUser, IReadOnlyList<ViewModelConfig> viewModelConfigs) : base(securityUser, viewModelConfigs) { }
public bool IsEnabled(ISecurityUser user) { return true; //return this.ContentItemStatus == ContentItemStatus.New // || this.ContentItemStatus == ContentItemStatus.Rework; }
public IDisposable LocalContextSecurity(ISecurityUser securityUser) { return new LocalContextSecurityUser(securityUser, GetSecurityUser(), this); }
public TestSecurityContext(ISecurityUser currentUser) : base(currentUser) { }
public ServiceSecurityContext(ISecurityUser currentUser, SecuritySystem securitySystem) : base(currentUser, securitySystem) { }
public virtual void Logon(ISecurityUser user) { IAuthorization authorization = (IAuthorization)this.GetService <IPermissionsProvider>(); authorization.Logon(user); }
public virtual void Logoff() { SecurityUser = null; }
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)); }
public void InitializeObject(ISecurityUser securityUser, BaseObject src, BaseObject dest, IEnumerable<InitItem> inits) { _objectInitializer.InitializeObject(securityUser, src, dest, inits); }
public void OnEnterToExtendedStage(ISecurityUser securityUser, ExtendedStage extendedStage, BaseObject baseObject) { var service = GetExtenderService(extendedStage); service.OnStageEnter(securityUser, extendedStage, extendedStage.Extender, baseObject); }
public BaseViewModel(IBaseController controller) { _securityUser = controller.SecurityUser; _viewModelConfigs = controller.ViewModelConfigs; }
public void OnLeaveFromExtendedStage(ISecurityUser securityUser, ExtendedStage extendedStage, BaseObject baseObject) { var service = GetExtenderService(extendedStage); service.OnStageLeave(securityUser, extendedStage, extendedStage.Extender, baseObject); }
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); }
public Context(ISecurityUser currentUser) { // Create a new instance. Security = new TestSecurityContext(currentUser); }
public virtual void Logon(ISecurityUser securityUser) { this.SecurityUser = securityUser; }