public IEnumerable <EntityToken> GetParents(EntityToken entityToken) { Verify.ArgumentNotNull(entityToken, nameof(entityToken)); List <IAuxiliarySecurityAncestorProvider> auxiliarySecurityAncestorProviders; List <IAuxiliarySecurityAncestorProvider> flushPersistentAuxiliarySecurityAncestorProviders; _auxiliarySecurityAncestorProviders.TryGetValue(entityToken.GetType(), out auxiliarySecurityAncestorProviders); _flushPersistentAuxiliarySecurityAncestorProviders.TryGetValue(entityToken.GetType(), out flushPersistentAuxiliarySecurityAncestorProviders); IEnumerable <IAuxiliarySecurityAncestorProvider> resultSecurityAncestorProviders = auxiliarySecurityAncestorProviders.ConcatOrDefault(flushPersistentAuxiliarySecurityAncestorProviders); if (resultSecurityAncestorProviders == null) { return(null); } IEnumerable <EntityToken> totalResult = null; foreach (IAuxiliarySecurityAncestorProvider auxiliarySecurityAncestorProvider in resultSecurityAncestorProviders) { var result = auxiliarySecurityAncestorProvider.GetParents(new [] { entityToken }); if (result.Count > 0) { totalResult = totalResult.ConcatOrDefault(result.Values.First()); } } return(totalResult); }
/// <exclude /> public static bool IsAttachingPoint(EntityToken leftEntityToken, EntityToken rightEntityToken) { return leftEntityToken.GetType() == rightEntityToken.GetType() && leftEntityToken.Id == rightEntityToken.Id && leftEntityToken.Type == rightEntityToken.Type && leftEntityToken.Source == rightEntityToken.Source; }
/// <exclude /> public static bool IsAttachingPoint(EntityToken entityToken, AttachingPoint attachingPoint) { return attachingPoint.Id == entityToken.Id && attachingPoint.Source == entityToken.Source && attachingPoint.EntityTokenType == entityToken.GetType(); }
public IEnumerable <EntityToken> GetParents(EntityToken entityToken) { if (entityToken == null) { throw new ArgumentNullException("entityToken"); } List <IAuxiliarySecurityAncestorProvider> auxiliarySecurityAncestorProviders; List <IAuxiliarySecurityAncestorProvider> flushPersistentAuxiliarySecurityAncestorProviders; _auxiliarySecurityAncestorProviders.TryGetValue(entityToken.GetType(), out auxiliarySecurityAncestorProviders); _flushPersistentAuxiliarySecurityAncestorProviders.TryGetValue(entityToken.GetType(), out flushPersistentAuxiliarySecurityAncestorProviders); IEnumerable <IAuxiliarySecurityAncestorProvider> resultSecurityAncestorProviders = auxiliarySecurityAncestorProviders.ConcatOrDefault(flushPersistentAuxiliarySecurityAncestorProviders); if (resultSecurityAncestorProviders == null) { return(null); } IEnumerable <EntityToken> totalResult = null; foreach (IAuxiliarySecurityAncestorProvider auxiliarySecurityAncestorProvider in resultSecurityAncestorProviders) { Dictionary <EntityToken, IEnumerable <EntityToken> > result = auxiliarySecurityAncestorProvider.GetParents(new EntityToken[] { entityToken }); if (result.Count > 0) { var firstValue = result.Values.First(); if (totalResult == null) { totalResult = firstValue; } else { totalResult = totalResult.Concat(firstValue); } } } return(totalResult); }
public IEnumerable<EntityToken> GetParents(EntityToken entityToken) { if (entityToken == null) throw new ArgumentNullException("entityToken"); List<IAuxiliarySecurityAncestorProvider> auxiliarySecurityAncestorProviders; List<IAuxiliarySecurityAncestorProvider> flushPersistentAuxiliarySecurityAncestorProviders; _auxiliarySecurityAncestorProviders.TryGetValue(entityToken.GetType(), out auxiliarySecurityAncestorProviders); _flushPersistentAuxiliarySecurityAncestorProviders.TryGetValue(entityToken.GetType(), out flushPersistentAuxiliarySecurityAncestorProviders); IEnumerable<IAuxiliarySecurityAncestorProvider> resultSecurityAncestorProviders = auxiliarySecurityAncestorProviders.ConcatOrDefault(flushPersistentAuxiliarySecurityAncestorProviders); if (resultSecurityAncestorProviders == null) return null; IEnumerable<EntityToken> totalResult = null; foreach (IAuxiliarySecurityAncestorProvider auxiliarySecurityAncestorProvider in resultSecurityAncestorProviders) { Dictionary<EntityToken, IEnumerable<EntityToken>> result = auxiliarySecurityAncestorProvider.GetParents(new EntityToken[] { entityToken }); if (result.Count > 0) { var firstValue = result.Values.First(); if (totalResult == null) { totalResult = firstValue; } else { totalResult = totalResult.Concat(firstValue); } } } return totalResult; }
/// <exclude /> public void PostRefreshMessages(EntityToken specificEntityToken) { Verify.ArgumentNotNull(specificEntityToken, "specificEntityToken"); if (_postRefreshMessagesCalled) { throw new InvalidOperationException("Only one PostRefreshMessages call is allowed"); } IManagementConsoleMessageService messageService = _flowControllerServicesContainer.GetService<IManagementConsoleMessageService>(); messageService.RefreshTreeSection(specificEntityToken); Log.LogVerbose(GetType().Name, "Refreshing EntityToken: Type = {0}, Source = {1}, Id = {2}, EntityTokenType = {3}", specificEntityToken.Type, specificEntityToken.Source, specificEntityToken.Id, specificEntityToken.GetType()); }
/// <exclude /> public bool EqualsWithVersionIgnore(object obj) { EntityToken entityToken = obj as EntityToken; if (entityToken == null) { return(false); } ValidateEntityToken(); if (entityToken.GetHashCode() != GetHashCode()) { return(false); } return(entityToken.Id == this.Id && entityToken.Type == this.Type && entityToken.Source == this.Source && entityToken.GetType() == this.GetType()); }
/// <exclude /> public static string Serialize(EntityToken entityToken, bool includeHashValue) { Verify.ArgumentNotNull(entityToken, "entityToken"); var sb = new StringBuilder(); StringConversionServices.SerializeKeyValuePair(sb, "entityTokenType", TypeManager.SerializeType(entityToken.GetType())); string serializedEntityToken = entityToken.Serialize(); if (serializedEntityToken == null) { throw new InvalidCastException($"'{entityToken.GetType()}' Serialize returned null"); } StringConversionServices.SerializeKeyValuePair(sb, "entityToken", serializedEntityToken); if (includeHashValue) { StringConversionServices.SerializeKeyValuePair(sb, "entityTokenHash", HashSigner.GetSignedHash(serializedEntityToken).Serialize()); } return(sb.ToString()); }
public IEnumerable<Element> GetChildren(EntityToken entityToken, SearchToken seachToken) { if ((entityToken is PackageElementProviderRootEntityToken)) { return GetRootChildren(seachToken); } if ((entityToken is PackageElementProviderAvailablePackagesFolderEntityToken)) { return GetAvailablePackagesFolderChildren(seachToken); } if ((entityToken is PackageElementProviderAvailablePackagesGroupFolderEntityToken)) { var castedToken = entityToken as PackageElementProviderAvailablePackagesGroupFolderEntityToken; return GetAvailablePackageGroupFolderChildren(castedToken.GroupName, seachToken); } if ((entityToken is PackageElementProviderInstalledPackageFolderEntityToken)) { return GetInstalledPackageFolderChildren(seachToken); } if ((entityToken is PackageElementProviderPackageSourcesFolderEntityToken)) { return GetPackageSourcesFolderChildren(seachToken); } if ((entityToken is PackageElementProviderInstalledPackageLocalPackagesFolderEntityToken)) { return GetInstalledLocalPackagesFolderChildren(seachToken); } if ((entityToken is PackageElementProviderInstalledPackageGroupFolderEntityToken)) { var castedToken = entityToken as PackageElementProviderInstalledPackageGroupFolderEntityToken; return GetInstalledPackageGroupFolderChildren(castedToken.GroupName, seachToken); } throw new InvalidOperationException("Unexpected entity token type: " + entityToken.GetType()); }
private void PrettyPrintEntityToken(EntityToken entityToken, string color) { List<object> idList = new List<object>(); if (entityToken.Id.Contains("=") == true) { Dictionary<string, string> dic = StringConversionServices.ParseKeyValueCollection(entityToken.Id); idList.Add(new XElement("br")); foreach (KeyValuePair<string, string> kvp in dic) { idList.Add(new XElement("span", new XAttribute("style", "padding-left: 15px;"), string.Format("{0} = {1}", kvp.Key, kvp.Value))); idList.Add(new XElement("br")); } } else { idList.Add(entityToken.Id); } List<object> usersermisstionsDefinedHere = new List<object>(); List<object> currentUsersPermisstionTypes = new List<object>(); string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken); IEnumerable<string> usernames = UserValidationFacade.AllUsernames; foreach (string username in usernames) { IEnumerable<PermissionType> userPermissionTypes = PermissionTypeFacade.GetLocallyDefinedUserPermissionTypes(new UserToken(username), entityToken); StringBuilder sb = new StringBuilder(); foreach (PermissionType permissionType in userPermissionTypes) { if (sb.ToString() != "") { sb.Append(", "); } sb.Append(new PermissionDescriptor(permissionType).Label); } usersermisstionsDefinedHere.Add(new XElement("span", new XAttribute("style", "padding-left: 15px;"), string.Format("{0} = {1}", username, sb.ToString()))); usersermisstionsDefinedHere.Add(new XElement("br")); IEnumerable<PermissionType> currentPermissionTypes = PermissionTypeFacade.GetCurrentPermissionTypes(new UserToken(username), entityToken, PermissionTypeFacade.GetUserPermissionDefinitions(username), PermissionTypeFacade.GetUserGroupPermissionDefinitions(username)); StringBuilder currentSb = new StringBuilder(); foreach (PermissionType permissionType in currentPermissionTypes) { if (currentSb.ToString() != "") { currentSb.Append(", "); } currentSb.Append(new PermissionDescriptor(permissionType).Label); } currentUsersPermisstionTypes.Add(new XElement("span", new XAttribute("style", "padding-left: 15px;"), string.Format("{0} = {1}", username, currentSb.ToString()))); currentUsersPermisstionTypes.Add(new XElement("br")); } List<object> userGroupPermissionsDefinedHere = new List<object>(); List<object> inheritedGroupPermissions = new List<object>(); List<IUserGroup> userGroups = DataFacade.GetData<IUserGroup>().ToList(); foreach (IUserGroup userGroup in userGroups) { IEnumerable<PermissionType> userGroupPermissionTypes = PermissionTypeFacade.GetLocallyDefinedUserGroupPermissionTypes(userGroup.Id, entityToken); StringBuilder sb = new StringBuilder(); foreach (PermissionType permissionType in userGroupPermissionTypes) { if (sb.ToString() != "") { sb.Append(", "); } sb.Append(new PermissionDescriptor(permissionType).Label); } userGroupPermissionsDefinedHere.Add(new XElement("span", new XAttribute("style", "padding-left: 15px;"), string.Format("{0} = {1}", userGroup.Name, sb.ToString()))); userGroupPermissionsDefinedHere.Add(new XElement("br")); IEnumerable<PermissionType> inheritedUserGroupPermissionTypes = PermissionTypeFacade.GetInheritedGroupPermissionsTypes(userGroup.Id, entityToken); sb = new StringBuilder(); foreach (PermissionType permissionType in inheritedUserGroupPermissionTypes) { if (sb.ToString() != "") { sb.Append(", "); } sb.Append(new PermissionDescriptor(permissionType).Label); } inheritedGroupPermissions.Add(new XElement("span", new XAttribute("style", "padding-left: 15px;"), string.Format("{0} = {1}", userGroup.Name, sb.ToString()))); inheritedGroupPermissions.Add(new XElement("br")); } XElement element = new XElement("div", new XAttribute("style", string.Format("border:2px; border-style: solid; border-color: {0}; margin-bottom: 2px; margin-left:5px; margin-right:5px; padding: 3px;", color)), new XElement("b", "Runtime type: "), entityToken.GetType().ToString(), new XElement("br"), new XElement("b", "Hashcode: "), entityToken.GetHashCode().ToString(), new XElement("br"), new XElement("b", "Source: "), entityToken.Source, new XElement("br"), new XElement("b", "Type: "), entityToken.Type, new XElement("br"), new XElement("b", "Id: "), idList, new XElement("br"), new XElement("b", "Serialized entity token: "), serializedEntityToken, new XElement("br"), new XElement("b", "Users permissions defined here: "), new XElement("br"), usersermisstionsDefinedHere, new XElement("br"), new XElement("b", "Current users permissions here: "), new XElement("br"), currentUsersPermisstionTypes, new XElement("br"), new XElement("b", "User group permissions defined here: "), new XElement("br"), userGroupPermissionsDefinedHere, new XElement("br"), new XElement("b", "Inherted user group permissions: "), new XElement("br"), inheritedGroupPermissions, new XElement("br") ); RelationshipGraphHolder.Controls.Add(new LiteralControl(element.ToString())); }
private ITemplateDeleter GetPageTemplateDeleter(EntityToken entityToken) { if (entityToken is DataEntityToken) { return new XmlPageTemplateDeleter(entityToken as DataEntityToken); } if(entityToken is PageTemplateEntityToken) { Guid pageTemplateId = (entityToken as PageTemplateEntityToken).TemplateId; var pageTemplateDescriptor = PageTemplateFacade.GetPageTemplate(pageTemplateId); if(pageTemplateDescriptor is RazorPageTemplateDescriptor) { return new RazorPageTemplateDeleter(pageTemplateDescriptor as RazorPageTemplateDescriptor); } if(pageTemplateDescriptor is MasterPagePageTemplateDescriptor) { return new MasterPagePageTemplateDeleter(pageTemplateDescriptor as MasterPagePageTemplateDescriptor); } throw new NotSupportedException("Not supported page template descriptor type '{0}'" .FormatWith(pageTemplateDescriptor.GetType().FullName)); } throw new NotSupportedException("Not supported entity token type '{0}'".FormatWith(entityToken.GetType().FullName)); }
/// <exclude /> public static FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer, TaskManagerEvent taskManagerEvent) { if (entityToken == null) throw new ArgumentNullException("entityToken"); if (actionToken == null) throw new ArgumentNullException("actionToken"); string username = UserValidationFacade.GetUsername(); #if NO_SECURITY #else HookingFacade.EnsureInitialization(); IEnumerable<UserPermissionDefinition> userPermissionDefinitions = PermissionTypeFacade.GetUserPermissionDefinitions(username); IEnumerable<UserGroupPermissionDefinition> userGroupPermissionDefinitions = PermissionTypeFacade.GetUserGroupPermissionDefinitions(username); SecurityResult securityResult = SecurityResolver.Resolve(UserValidationFacade.GetUserToken(), actionToken, entityToken, userPermissionDefinitions, userGroupPermissionDefinitions); if ((securityResult != SecurityResult.Allowed) && (entityToken.GetType() != typeof(SecurityViolationWorkflowEntityToken))) { return ExecuteSecurityViolation(actionToken, entityToken, flowControllerServicesContainer); } #endif bool ignoreLocking = actionToken.IsIgnoreEntityTokenLocking(); if ((ignoreLocking) || (ActionLockingFacade.IsLocked(entityToken) == false)) { IActionExecutor actionExecutor = ActionExecutorCache.GetActionExecutor(actionToken); ActionEventSystemFacade.FireOnBeforeActionExecution(entityToken, actionToken); FlowToken flowToken; using (TaskContainer taskContainer = TaskManagerFacade.CreateNewTasks(entityToken, actionToken, taskManagerEvent)) { ITaskManagerFlowControllerService taskManagerService = null; if (flowControllerServicesContainer.GetService(typeof(ITaskManagerFlowControllerService)) == null) { taskManagerService = new TaskManagerFlowControllerService(taskContainer); flowControllerServicesContainer.AddService(taskManagerService); } try { if ((actionExecutor is IActionExecutorSerializedParameters)) { string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken); string serializedActionToken = ActionTokenSerializer.Serialize(actionToken); flowToken = Execute(actionExecutor as IActionExecutorSerializedParameters, serializedEntityToken, serializedActionToken, actionToken, flowControllerServicesContainer); } else { flowToken = Execute(actionExecutor, entityToken, actionToken, flowControllerServicesContainer); } } finally { if (taskManagerService != null) { flowControllerServicesContainer.RemoveService(taskManagerService); } } taskContainer.SetOnIdleTaskManagerEvent(new FlowTaskManagerEvent(flowToken)); taskContainer.UpdateTasksWithFlowToken(flowToken); taskContainer.SaveTasks(); } ActionEventSystemFacade.FireOnAfterActionExecution(entityToken, actionToken, flowToken); IManagementConsoleMessageService managementConsoleMessageService = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>(); if (managementConsoleMessageService != null) { FlowControllerFacade.RegisterNewFlowInformation(flowToken, entityToken, actionToken, managementConsoleMessageService.CurrentConsoleId); } else { LoggingService.LogWarning("ActionExecutorFacade", "Missing ManagementConsoleMessageService, can not register the flow"); } return flowToken; } else { return ExecuteEntityTokenLocked(actionToken, entityToken, flowControllerServicesContainer); } }