示例#1
0
        public bool Authorize(IResourceItem resource, Permission permission)
        {
            bool isAuthorized = false;

            //authorization logic goes here
            return(isAuthorized);
        }
示例#2
0
 public void InsertOrUpdateResourceSecurityInformation(string cluster, IResourceItem resourceItem)
 {
     resourceItem.ClusterName = cluster;
     ConfigurationStore.Transaction transaction = _store.BeginTransaction(cluster);
     transaction.InsertOrUpdateResourceSecurityInformation(resourceItem);
     _store.CommitTransaction(transaction);
 }
示例#3
0
        public IResourceItem GetResourceSecurityInformatio(string cluster, string resource)
        {
            ConfigurationStore.Transaction transaction = _store.BeginTransaction(cluster);
            IResourceItem resourceItem = transaction.GetResourceSecurityInformation(resource);

            return(resourceItem);
        }
示例#4
0
        public Common.Security.Interfaces.IResourceItem GetResourceSecurityInformatio(string cluster, string resource)
        {
            IResourceItem resourceItem = null;
            JSONDocument  doc          = new JSONDocument();
            bool          found        = FindDocument(resource, Alachisoft.NosDB.Core.Util.MiscUtil.SystemCollection.SecurityInformationCollection, out doc);

            if (found)
            {
                resourceItem = JsonSerializer.Deserialize <IResourceItem>(doc);
            }
            return(resourceItem);
        }
        public static string Resolve(IResourceItem item)
        {
            string message = Resolve(item.Key);

            if (item.Params != null && item.Params.Count > 0)
            {
                for (int index = 0; index < item.Params.Count; index++)
                {
                    message = message.Replace("{" + index + "}", item.Params[index]);
                }
            }
            return(message);
        }
示例#6
0
        public Common.Security.Interfaces.IResourceItem[] GetAllResourcesSecurityInformation()
        {
            ICollectionStore collection = ((SystemDatabaseStore)_store).Collections[Alachisoft.NosDB.Core.Util.MiscUtil.SystemCollection.SecurityInformationCollection];

            IResourceItem[] resources = new IResourceItem[collection.Count()];
            int             i         = 0;

            foreach (JSONDocument doc in collection)
            {
                resources[i] = JsonSerializer.Deserialize <IResourceItem>(doc);
                i++;
            }
            return(resources);
        }
示例#7
0
        public static string Resolve(IResourceItem item)
        {
            string message = ResourceHelper.Resolve(item.Key);

            if (item.Params == null || item.Params.Count <= 0)
            {
                return(message);
            }
            for (int index = 0; index < item.Params.Count; index++)
            {
                message = message.Replace("{" + index + "}", item.Params[index]);
            }

            return(message);
        }
示例#8
0
 public void Merge(IResourceItem resourceItem)
 {
     foreach (IRole role in resourceItem.Roles.Keys)
     {
         if (Roles.ContainsKey(role))
         {
             foreach (string username in resourceItem.Roles[role].AuthorizedUsers)
             {
                 if (!Roles[role].AuthorizedUsers.Contains(username))
                 {
                     Roles[role].AuthorizedUsers.Add(username);
                 }
             }
         }
     }
 }
示例#9
0
        /// <summary>
        /// 根据ResourceItem 决定是注册文件资源或者程序集资源
        /// </summary>
        /// <param name="item"></param>
        /// <param name="asm"></param>
        public void Register(IResourceItem item, Assembly asm)
        {
            if (item == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(item.AssemblyFile))
            {
                Register(item.BaseResourceName, AssemblyLoader.Load(item.AssemblyFile));
            }
            else if (!string.IsNullOrEmpty(item.ResourceFile))
            {
                Register(item.ResourceFile);
            }
            else
            {
                Register(item.BaseResourceName, asm);
            }
        }
示例#10
0
        public static IDictionary <string, IList <string> > GetUserInfo(IResourceItem resourceItem)
        {
            IDictionary <string, IList <string> > usersRoleSet = null;

            if (resourceItem != null)
            {
                usersRoleSet = new Dictionary <string, IList <string> >();
                foreach (IRole role in resourceItem.Roles.Keys)
                {
                    foreach (string user in resourceItem.Roles[role].AuthorizedUsers)
                    {
                        if (!usersRoleSet.ContainsKey(user))
                        {
                            usersRoleSet[user] = new List <string>();
                        }
                        usersRoleSet[user].Add(role.RoleName);
                    }
                }
            }
            return(usersRoleSet);
        }
    public void InitResource(IResourceItem obj)
    {
        resourceType = (ResourceType)Rectifier(Random.Range(0, 6));
        string sign;

        switch (resourceType)
        {
        case ResourceType.SQUARE:
            sign = dataMaganer.squareSign;
            obj.InitReasorce(this, sign, dataMaganer.SetupPikes(this, sign), dataMaganer.SetupView(this, sign), dataMaganer.SetupHealth(this, sign));
            break;

        case ResourceType.TRIANGLE:
            sign = dataMaganer.triangleSign;
            obj.InitReasorce(this, sign, dataMaganer.SetupPikes(this, sign), dataMaganer.SetupView(this, sign), dataMaganer.SetupHealth(this, sign));
            break;

        case ResourceType.PENTAGON:
            sign = dataMaganer.hexagonSign;
            obj.InitReasorce(this, sign, dataMaganer.SetupPikes(this, sign), dataMaganer.SetupView(this, sign), dataMaganer.SetupHealth(this, sign));
            break;
        }
    }
示例#12
0
 /// <summary>
 /// Vrátí obsah daného zdroje.
 /// </summary>
 /// <param name="resourceItem"></param>
 public static byte[] GetResourceContent(IResourceItem resourceItem)
 {
     return((resourceItem is DataResourceItem dataItem) ? dataItem.Content : null);
 }
示例#13
0
		private void ReleaseConsumedResource()
		{
			if (this.consumedResource != null)
			{
				var np = this.consumedResource as INotifyPropertyChanged;
				if (np != null)
				{
					np.PropertyChanged -= this.ConsumedResourcePropertyChanged;
				}
				this.resourceManager.ReleaseResource(this.consumedResource.Type, this.consumedResource.Hash);
				this.consumedResource = null;
			}
			this.consumedFileResource = null;
		}
		protected virtual void SetNewValue(IResourceItem item)
		{
			var t = this.context.ResolveKeyed<IResourceType>(this.Type);
			ResourceReference newR;
			if (item == null)
			{
				newR = new ResourceReference(this.Type, this.resourceManager, this.Reference.Container);
			}
			else
			{
				newR = t.BuildReference(item, this.fileReferencesAllowed);
			}
			var oldR = this.Reference.Clone();
			var setReferenceCommand = new SetReferenceCommand(this.Reference, newR, oldR);
			this.history.RegisterAction(setReferenceCommand);
			setReferenceCommand.Redo();
		}
 public void SendScore(IResourceItem obj, int pts)
 {
     scoreManager.ScorePlus(this, pts);
 }
 public override void WriteJson(JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer)
 {
     writer.WriteStartObject();
     if (value is IResourceItem)
     {
         IResourceItem resourceItem = value as IResourceItem;
         if (resourceItem != null)
         {
             writer.WritePropertyName("ResourceId");
             serializer.Serialize(writer, resourceItem.ResourceId);
             writer.WritePropertyName("SecurityInformationType");
             serializer.Serialize(writer, resourceItem.SecurityInformationType);
             writer.WritePropertyName("ClusterName");
             serializer.Serialize(writer, resourceItem.ClusterName);
             writer.WritePropertyName("Roles");
             writer.WriteStartArray();
             foreach (var kvp in resourceItem.Roles)
             {
                 writer.WriteStartArray();
                 serializer.Serialize(writer, kvp.Key);
                 serializer.Serialize(writer, kvp.Value);
                 writer.WriteEndArray();
             }
             writer.WriteEndArray();
             writer.WritePropertyName("SubResources");
             writer.WriteStartArray();
             foreach (ResourceId resourceId in resourceItem.SubResources)
             {
                 serializer.Serialize(writer, resourceId);
             }
             writer.WriteEndArray();
         }
     }
     else if (value is IRole)
     {
         IRole role = value as IRole;
         if (role != null)
         {
             writer.WritePropertyName("RoleName");
             serializer.Serialize(writer, role.RoleName);
             writer.WritePropertyName("RoleType");
             serializer.Serialize(writer, role.RoleType);
             writer.WritePropertyName("SecurityInformationType");
             serializer.Serialize(writer, role.SecurityInformationType);
             writer.WritePropertyName("Permissions");
             writer.WriteStartArray();
             foreach (Permission permission in role.Permissions)
             {
                 serializer.Serialize(writer, permission);
             }
             writer.WriteEndArray();
         }
     }
     else if (value is User)
     {
         User user = value as User;
         if (user != null)
         {
             writer.WritePropertyName("UserName");
             serializer.Serialize(writer, user.Username);
             writer.WritePropertyName("SecurityInformationType");
             serializer.Serialize(writer, user.SecurityInformationType);
         }
     }
     else if (value is IRoleInstance)
     {
         IRoleInstance roleInstance = value as IRoleInstance;
         if (roleInstance != null)
         {
             writer.WritePropertyName("SecurityInformationType");
             serializer.Serialize(writer, roleInstance.SecurityInformationType);
             writer.WritePropertyName("AuthorizedUsers");
             writer.WriteStartArray();
             foreach (string user in roleInstance.AuthorizedUsers)
             {
                 serializer.Serialize(writer, user);
             }
             writer.WriteEndArray();
         }
     }
     else if (value is Permission)
     {
         Permission permission = value as Permission;
         if (permission != null)
         {
             writer.WritePropertyName("OperationType");
             serializer.Serialize(writer, permission.OperationType);
             writer.WritePropertyName("ResourceType");
             serializer.Serialize(writer, permission.ResourceType);
             writer.WritePropertyName("SecurityInformationType");
             serializer.Serialize(writer, permission.SecurityInformationType);
         }
     }
     else if (value is ResourceId)
     {
         ResourceId resourceId = value as ResourceId;
         if (resourceId != null)
         {
             writer.WritePropertyName("Name");
             serializer.Serialize(writer, resourceId.Name);
             writer.WritePropertyName("ResourceType");
             serializer.Serialize(writer, resourceId.ResourceType);
             writer.WritePropertyName("SecurityInformationType");
             serializer.Serialize(writer, resourceId.SecurityInformationType);
         }
     }
     writer.WriteEndObject();
 }
示例#17
0
 public void SwitchLanguage(IResourceItem language)
 {
     Application.Current.Dispatcher.Invoke(() => _state.Switch(_finder, language.Id));
 }
示例#18
0
		private void btnOpenFile_Click(object sender, EventArgs e)
		{
			var d = new OpenFileDialog();
			if (DialogResult.OK == d.ShowDialog())
			{
				string safeFileName = d.FileName;
				this.editorEnvironment.Open(safeFileName);

				var f = this.resourceManager.EnsureFile(safeFileName);
				if (f != null)
				{
					if (f.Items != null)
					{
						foreach (var i in f.Items)
						{
							if (i.Type == this.type)
							{
								var r = this.resourceManager.ConsumeResource(i.Type, i.NameHash);
								this.list.Items.Add(r);
								this.list.SelectedItem = r;
								this.resourceManager.ReleaseResource(i.Type, i.NameHash);
								this.DialogResult = DialogResult.OK;
							}
						}
					}
				}
			}
		}
示例#19
0
		private void SetConsumedResource(IResourceItem resource)
		{
			var obj = this.Resource;
			this.ReleaseConsumedResource();
			this.consumedResource = resource;
			if (this.consumedResource != null)
			{
				var np = this.consumedResource as INotifyPropertyChanged;
				if (np != null)
				{
					np.PropertyChanged += this.ConsumedResourcePropertyChanged;
				}
			}
			if (!Equals(obj, this.Resource))
			{
				this.RaiseReferenceChanged();
			}
		}
示例#20
0
 byte[] ISystemAdapter.GetResourceContent(IResourceItem resourceItem)
 {
     return(DataResources.GetResourceContent(resourceItem));
 }
示例#21
0
 void Start()
 {
     itemManager = transform.parent.GetComponent <IResourceItem>();
 }
示例#22
0
 public void SwitchLanguage(IResourceItem language)
 {
     throw new NotImplementedException();
 }