private void VerifyAccess(RegistryPermissionAccess access)
 {
     if ((access & ~RegistryPermissionAccess.AllAccess) != RegistryPermissionAccess.NoAccess)
     {
         throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", new object[] { (int)access }));
     }
 }
Пример #2
0
     public void AddPathList( RegistryPermissionAccess access, AccessControlActions control, String pathList )
     {
         VerifyAccess( access );
         
         if ((access & RegistryPermissionAccess.Read) != 0)
         {
             if (m_read == null)
                 m_read = new StringExpressionSet();
             m_read.AddExpressions( pathList );
         }
         
         if ((access & RegistryPermissionAccess.Write) != 0)
         {
             if (m_write == null)
                 m_write = new StringExpressionSet();
             m_write.AddExpressions( pathList );
         }
 
         if ((access & RegistryPermissionAccess.Create) != 0)
         {
             if (m_create == null)
                 m_create = new StringExpressionSet();
             m_create.AddExpressions( pathList );
         }
     }
 public string GetPathList(RegistryPermissionAccess access)
 {
     this.VerifyAccess(access);
     this.ExclusiveAccess(access);
     if ((access & RegistryPermissionAccess.Read) != RegistryPermissionAccess.NoAccess)
     {
         if (this.m_read == null)
         {
             return("");
         }
         return(this.m_read.ToString());
     }
     if ((access & RegistryPermissionAccess.Write) != RegistryPermissionAccess.NoAccess)
     {
         if (this.m_write == null)
         {
             return("");
         }
         return(this.m_write.ToString());
     }
     if ((access & RegistryPermissionAccess.Create) == RegistryPermissionAccess.NoAccess)
     {
         return("");
     }
     if (this.m_create == null)
     {
         return("");
     }
     return(this.m_create.ToString());
 }
Пример #4
0
        public void AddPathList(RegistryPermissionAccess access, AccessControlActions control, String pathList)
        {
            VerifyAccess(access);

            if ((access & RegistryPermissionAccess.Read) != 0)
            {
                if (m_read == null)
                {
                    m_read = new StringExpressionSet();
                }
                m_read.AddExpressions(pathList);
            }

            if ((access & RegistryPermissionAccess.Write) != 0)
            {
                if (m_write == null)
                {
                    m_write = new StringExpressionSet();
                }
                m_write.AddExpressions(pathList);
            }

            if ((access & RegistryPermissionAccess.Create) != 0)
            {
                if (m_create == null)
                {
                    m_create = new StringExpressionSet();
                }
                m_create.AddExpressions(pathList);
            }
        }
Пример #5
0
		// Properties

		// Methods

		public void AddPathList (RegistryPermissionAccess access, string pathList) 
		{
			if (pathList == null)
				throw new ArgumentNullException ("pathList");

			switch (access) {
				case RegistryPermissionAccess.AllAccess:
					AddWithUnionKey (createList, pathList);
					AddWithUnionKey (readList, pathList);
					AddWithUnionKey (writeList, pathList);
					break;
				case RegistryPermissionAccess.NoAccess:
					// ??? unit tests doesn't show removal using NoAccess ???
					break;
				case RegistryPermissionAccess.Create:
					AddWithUnionKey (createList, pathList);
					break;
				case RegistryPermissionAccess.Read:
					AddWithUnionKey (readList, pathList);
					break;
				case RegistryPermissionAccess.Write:
					AddWithUnionKey (writeList, pathList);
					break;
				default:
					ThrowInvalidFlag (access, false);
					break;
			}
		}
        /// <summary>Adds access for the specified registry variables to the existing state of the permission.</summary>
        /// <param name="access">One of the <see cref="T:System.Security.Permissions.RegistryPermissionAccess" /> values. </param>
        /// <param name="pathList">A list of registry variables (semicolon-separated). </param>
        /// <exception cref="T:System.ArgumentException">The <paramref name="access" /> parameter is not a valid value of <see cref="T:System.Security.Permissions.RegistryPermissionAccess" />.-or- The <paramref name="pathList" /> parameter is not a valid string. </exception>
        public void AddPathList(RegistryPermissionAccess access, string pathList)
        {
            if (pathList == null)
            {
                throw new ArgumentNullException("pathList");
            }
            switch (access)
            {
            case RegistryPermissionAccess.NoAccess:
                return;

            case RegistryPermissionAccess.Read:
                this.AddWithUnionKey(this.readList, pathList);
                return;

            case RegistryPermissionAccess.Write:
                this.AddWithUnionKey(this.writeList, pathList);
                return;

            case RegistryPermissionAccess.Create:
                this.AddWithUnionKey(this.createList, pathList);
                return;

            case RegistryPermissionAccess.AllAccess:
                this.AddWithUnionKey(this.createList, pathList);
                this.AddWithUnionKey(this.readList, pathList);
                this.AddWithUnionKey(this.writeList, pathList);
                return;
            }
            this.ThrowInvalidFlag(access, false);
        }
	public RegistryPermission(RegistryPermissionAccess flag, String pathList)
			{
				if(pathList == null)
				{
					throw new ArgumentNullException("pathList");
				}
				if((flag & ~(RegistryPermissionAccess.AllAccess)) != 0)
				{
					throw new ArgumentException(_("Arg_RegistryAccess"));
				}
				this.state = PermissionState.None;
				String[] split = EnvironmentPermission.SplitPath(pathList);
				if((flag & RegistryPermissionAccess.Read) != 0)
				{
					readList = split;
				}
				if((flag & RegistryPermissionAccess.Write) != 0)
				{
					writeList = split;
				}
				if((flag & RegistryPermissionAccess.Create) != 0)
				{
					createList = split;
				}
			}
Пример #8
0
 public RegistryPermission(RegistryPermissionAccess flag, String pathList)
 {
     if (pathList == null)
     {
         throw new ArgumentNullException("pathList");
     }
     if ((flag & ~(RegistryPermissionAccess.AllAccess)) != 0)
     {
         throw new ArgumentException(_("Arg_RegistryAccess"));
     }
     this.state = PermissionState.None;
     String[] split = EnvironmentPermission.SplitPath(pathList);
     if ((flag & RegistryPermissionAccess.Read) != 0)
     {
         readList = split;
     }
     if ((flag & RegistryPermissionAccess.Write) != 0)
     {
         writeList = split;
     }
     if ((flag & RegistryPermissionAccess.Create) != 0)
     {
         createList = split;
     }
 }
Пример #9
0
 // Add to the path list information.
 public void AddPathList(RegistryPermissionAccess flag, String pathList)
 {
     if (pathList == null)
     {
         throw new ArgumentNullException("pathList");
     }
     if ((flag & ~(RegistryPermissionAccess.AllAccess)) != 0)
     {
         throw new ArgumentException(_("Arg_RegistryAccess"));
     }
     if ((flag & RegistryPermissionAccess.Read) != 0)
     {
         readList = EnvironmentPermission.Union(readList,
                                                EnvironmentPermission.SplitPath
                                                    (pathList, Path.PathSeparator), false);
     }
     if ((flag & RegistryPermissionAccess.Write) != 0)
     {
         writeList = EnvironmentPermission.Union(writeList,
                                                 EnvironmentPermission.SplitPath
                                                     (pathList, Path.PathSeparator), false);
     }
     if ((flag & RegistryPermissionAccess.Create) != 0)
     {
         createList = EnvironmentPermission.Union(createList,
                                                  EnvironmentPermission.SplitPath
                                                      (pathList, Path.PathSeparator), false);
     }
 }
Пример #10
0
 private void VerifyAccess(RegistryPermissionAccess access)
 {
     if ((access & ~RegistryPermissionAccess.AllAccess) != 0)
     {
         throw new ArgumentException(String.Format(Environment.GetResourceString("Arg_EnumIllegalVal"), (int)access));
     }
 }
Пример #11
0
        public void SetPathList(RegistryPermissionAccess access, string pathList)
        {
            if (pathList == null)
            {
                throw new ArgumentNullException("pathList");
            }

            string[] paths;
            switch (access)
            {
            case RegistryPermissionAccess.AllAccess:
                createList.Clear();
                readList.Clear();
                writeList.Clear();
                paths = pathList.Split(';');
                foreach (string path in paths)
                {
                    createList.Add(path);
                    readList.Add(path);
                    writeList.Add(path);
                }
                break;

            case RegistryPermissionAccess.NoAccess:
                // ??? unit tests doesn't show removal using NoAccess ???
                break;

            case RegistryPermissionAccess.Create:
                createList.Clear();
                paths = pathList.Split(';');
                foreach (string path in paths)
                {
                    createList.Add(path);
                }
                break;

            case RegistryPermissionAccess.Read:
                readList.Clear();
                paths = pathList.Split(';');
                foreach (string path in paths)
                {
                    readList.Add(path);
                }
                break;

            case RegistryPermissionAccess.Write:
                writeList.Clear();
                paths = pathList.Split(';');
                foreach (string path in paths)
                {
                    writeList.Add(path);
                }
                break;

            default:
                ThrowInvalidFlag(access, false);
                break;
            }
        }
 /// <summary>Initializes a new instance of the <see cref="T:System.Security.Permissions.RegistryPermission" /> class with the specified access to the specified registry variables.</summary>
 /// <param name="access">One of the <see cref="T:System.Security.Permissions.RegistryPermissionAccess" /> values. </param>
 /// <param name="pathList">A list of registry variables (semicolon-separated) to which access is granted. </param>
 /// <exception cref="T:System.ArgumentException">The <paramref name="access" /> parameter is not a valid value of <see cref="T:System.Security.Permissions.RegistryPermissionAccess" />.-or- The <paramref name="pathList" /> parameter is not a valid string. </exception>
 public RegistryPermission(RegistryPermissionAccess access, string pathList)
 {
     this._state     = PermissionState.None;
     this.createList = new ArrayList();
     this.readList   = new ArrayList();
     this.writeList  = new ArrayList();
     this.AddPathList(access, pathList);
 }
Пример #13
0
 public RegistryPermission(RegistryPermissionAccess access, string pathList)
 {
     _state     = PermissionState.None;
     createList = new ArrayList();
     readList   = new ArrayList();
     writeList  = new ArrayList();
     AddPathList(access, pathList);
 }
Пример #14
0
		public RegistryPermission (RegistryPermissionAccess access, string pathList)
		{
			_state = PermissionState.None;
			createList = new ArrayList ();
			readList = new ArrayList ();
			writeList = new ArrayList ();
			AddPathList (access, pathList);
		}
Пример #15
0
		public RegistryPermission (RegistryPermissionAccess access, AccessControlActions control, string pathList)
		{
			if (!Enum.IsDefined (typeof (AccessControlActions), control)) {
				string msg = String.Format (Locale.GetText ("Invalid enum {0}"), control);
				throw new ArgumentException (msg, "AccessControlActions");
			}
			_state = PermissionState.None;
			AddPathList (access, control, pathList);
		}
 /// <summary>Initializes a new instance of the <see cref="T:System.Security.Permissions.RegistryPermission" /> class with the specified access to the specified registry variables and the specified access rights to registry control information.</summary>
 /// <param name="access">One of the <see cref="T:System.Security.Permissions.RegistryPermissionAccess" /> values.</param>
 /// <param name="control">A bitwise combination of the <see cref="T:System.Security.AccessControl.AccessControlActions" />  values.</param>
 /// <param name="pathList">A list of registry variables (semicolon-separated) to which access is granted.</param>
 /// <exception cref="T:System.ArgumentException">The <paramref name="access" /> parameter is not a valid value of <see cref="T:System.Security.Permissions.RegistryPermissionAccess" />.-or- The <paramref name="pathList" /> parameter is not a valid string. </exception>
 public RegistryPermission(RegistryPermissionAccess access, AccessControlActions control, string pathList)
 {
     if (!Enum.IsDefined(typeof(AccessControlActions), control))
     {
         string message = string.Format(Locale.GetText("Invalid enum {0}"), control);
         throw new ArgumentException(message, "AccessControlActions");
     }
     this._state = PermissionState.None;
     this.AddPathList(access, control, pathList);
 }
 private void ExclusiveAccess(RegistryPermissionAccess access)
 {
     if (access == RegistryPermissionAccess.NoAccess)
     {
         throw new ArgumentException(Environment.GetResourceString("Arg_EnumNotSingleFlag"));
     }
     if ((access & (access - 1)) != RegistryPermissionAccess.NoAccess)
     {
         throw new ArgumentException(Environment.GetResourceString("Arg_EnumNotSingleFlag"));
     }
 }
Пример #18
0
        // Get a specific path list.
        public String GetPathList(RegistryPermissionAccess flag)
        {
            switch (flag)
            {
            case RegistryPermissionAccess.Read:
            {
                if (readList != null)
                {
                    return(String.Join
                               (Path.PathSeparator.ToString(), readList));
                }
                else
                {
                    return(String.Empty);
                }
            }
            // Not reached.

            case RegistryPermissionAccess.Write:
            {
                if (writeList != null)
                {
                    return(String.Join
                               (Path.PathSeparator.ToString(), writeList));
                }
                else
                {
                    return(String.Empty);
                }
            }
            // Not reached.

            case RegistryPermissionAccess.Create:
            {
                if (createList != null)
                {
                    return(String.Join
                               (Path.PathSeparator.ToString(), createList));
                }
                else
                {
                    return(String.Empty);
                }
            }
            // Not reached.

            default:
            {
                throw new ArgumentException(_("Arg_RegistryAccess"));
            }
                // Not reached.
            }
        }
Пример #19
0
 /// <summary>
 /// Checks whether the user has the given permission to operate on the given registry key.
 /// </summary>
 public static bool HavePermissionsOnKey(RegistryPermissionAccess p_rpaAccessLevel, string strRegKey)
 {
     try
     {
         RegistryPermission rpPermission = new RegistryPermission(p_rpaAccessLevel, strRegKey);
         rpPermission.Demand();
         return(true);
     }
     catch (SecurityException)
     {
         return(false);
     }
 }
Пример #20
0
 protected bool HavePermissionsOnKey(RegistryPermissionAccess accessLevel, string key)
 {
     try
     {
         RegistryPermission r = new RegistryPermission(accessLevel, key);
         r.Demand();
         return(true);
     }
     catch (SecurityException)
     {
         return(false);
     }
 }
Пример #21
0
 protected bool HavePermissionsOnKey(RegistryPermissionAccess accessLevel, string key)
 {
     try
     {
         RegistryPermission r = new RegistryPermission(accessLevel, key);
         r.Demand();
         return true;
     }
     catch (SecurityException)
     {
         return false;
     }
 }
Пример #22
0
 public static bool HavePermissionsOnKey(this RegistryPermission reg, RegistryPermissionAccess accessLevel, string key)
 {
     try
     {
         RegistryPermission r = new RegistryPermission(accessLevel, key);
         r.Demand();
         return true;
     }
     catch (SecurityException)
     {
         return false;
     }
 }
Пример #23
0
 public static bool HavePermissionsOnKey(this RegistryPermission reg, RegistryPermissionAccess accessLevel, string key)
 {
     try
     {
         RegistryPermission r = new RegistryPermission(accessLevel, key);
         r.Demand();
         return(true);
     }
     catch (SecurityException)
     {
         return(false);
     }
 }
Пример #24
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        public void AddPathList(RegistryPermissionAccess access, AccessControlActions control, String pathList)
        {
            VerifyAccess(access);

            if ((access & RegistryPermissionAccess.Read) != 0)
            {
                if (m_read == null)
                {
                    m_read = new StringExpressionSet();
                }
                m_read.AddExpressions(pathList);
            }

            if ((access & RegistryPermissionAccess.Write) != 0)
            {
                if (m_write == null)
                {
                    m_write = new StringExpressionSet();
                }
                m_write.AddExpressions(pathList);
            }

            if ((access & RegistryPermissionAccess.Create) != 0)
            {
                if (m_create == null)
                {
                    m_create = new StringExpressionSet();
                }
                m_create.AddExpressions(pathList);
            }

#if FEATURE_MACL
            if ((control & AccessControlActions.View) != 0)
            {
                if (m_viewAcl == null)
                {
                    m_viewAcl = new StringExpressionSet();
                }
                m_viewAcl.AddExpressions(pathList);
            }

            if ((control & AccessControlActions.Change) != 0)
            {
                if (m_changeAcl == null)
                {
                    m_changeAcl = new StringExpressionSet();
                }
                m_changeAcl.AddExpressions(pathList);
            }
#endif
        }
        internal void ThrowInvalidFlag(RegistryPermissionAccess flag, bool context)
        {
            string text;

            if (context)
            {
                text = Locale.GetText("Unknown flag '{0}'.");
            }
            else
            {
                text = Locale.GetText("Invalid flag '{0}' in this context.");
            }
            throw new ArgumentException(string.Format(text, flag), "flag");
        }
Пример #26
0
        [System.Security.SecuritySafeCritical]  // auto-generated 
        public void SetPathList( RegistryPermissionAccess access, String pathList )
        { 
            VerifyAccess( access );

            m_unrestricted = false;
 
            if ((access & RegistryPermissionAccess.Read) != 0)
                m_read = null; 
 
            if ((access & RegistryPermissionAccess.Write) != 0)
                m_write = null; 

            if ((access & RegistryPermissionAccess.Create) != 0)
                m_create = null;
 
            AddPathList( access, pathList );
        } 
Пример #27
0
 public void AddPathList(RegistryPermissionAccess access, AccessControlActions control, string pathList)
 {
     this.VerifyAccess(access);
     if ((access & RegistryPermissionAccess.Read) != RegistryPermissionAccess.NoAccess)
     {
         if (this.m_read == null)
         {
             this.m_read = new StringExpressionSet();
         }
         this.m_read.AddExpressions(pathList);
     }
     if ((access & RegistryPermissionAccess.Write) != RegistryPermissionAccess.NoAccess)
     {
         if (this.m_write == null)
         {
             this.m_write = new StringExpressionSet();
         }
         this.m_write.AddExpressions(pathList);
     }
     if ((access & RegistryPermissionAccess.Create) != RegistryPermissionAccess.NoAccess)
     {
         if (this.m_create == null)
         {
             this.m_create = new StringExpressionSet();
         }
         this.m_create.AddExpressions(pathList);
     }
     if ((control & AccessControlActions.View) != AccessControlActions.None)
     {
         if (this.m_viewAcl == null)
         {
             this.m_viewAcl = new StringExpressionSet();
         }
         this.m_viewAcl.AddExpressions(pathList);
     }
     if ((control & AccessControlActions.Change) == AccessControlActions.None)
     {
         return;
     }
     if (this.m_changeAcl == null)
     {
         this.m_changeAcl = new StringExpressionSet();
     }
     this.m_changeAcl.AddExpressions(pathList);
 }
 public void SetPathList(RegistryPermissionAccess access, string pathList)
 {
     this.VerifyAccess(access);
     this.m_unrestricted = false;
     if ((access & RegistryPermissionAccess.Read) != RegistryPermissionAccess.NoAccess)
     {
         this.m_read = null;
     }
     if ((access & RegistryPermissionAccess.Write) != RegistryPermissionAccess.NoAccess)
     {
         this.m_write = null;
     }
     if ((access & RegistryPermissionAccess.Create) != RegistryPermissionAccess.NoAccess)
     {
         this.m_create = null;
     }
     this.AddPathList(access, pathList);
 }
Пример #29
0
        /// <include file='doc\RegistryPermission.uex' path='docs/doc[@for="RegistryPermission.SetPathList"]/*' />
        public void SetPathList(RegistryPermissionAccess access, String pathList)
        {
            VerifyAccess(access);

            if ((access & RegistryPermissionAccess.Read) != 0)
            {
                m_read = null;
            }

            if ((access & RegistryPermissionAccess.Write) != 0)
            {
                m_write = null;
            }

            if ((access & RegistryPermissionAccess.Create) != 0)
            {
                m_create = null;
            }

            AddPathList(access, pathList);
        }
        /// <summary>Gets paths for all registry variables with the specified <see cref="T:System.Security.Permissions.RegistryPermissionAccess" />.</summary>
        /// <returns>A list of the registry variables (semicolon-separated) with the specified <see cref="T:System.Security.Permissions.RegistryPermissionAccess" />.</returns>
        /// <param name="access">One of the <see cref="T:System.Security.Permissions.RegistryPermissionAccess" /> values that represents a single type of registry variable access. </param>
        /// <exception cref="T:System.ArgumentException">
        ///   <paramref name="access" /> is not a valid value of <see cref="T:System.Security.Permissions.RegistryPermissionAccess" />.-or- <paramref name="access" /> is <see cref="F:System.Security.Permissions.RegistryPermissionAccess.AllAccess" />, which represents more than one type of registry variable access, or <see cref="F:System.Security.Permissions.RegistryPermissionAccess.NoAccess" />, which does not represent any type of registry variable access. </exception>
        public string GetPathList(RegistryPermissionAccess access)
        {
            switch (access)
            {
            case RegistryPermissionAccess.NoAccess:
            case RegistryPermissionAccess.AllAccess:
                this.ThrowInvalidFlag(access, true);
                goto IL_6E;

            case RegistryPermissionAccess.Read:
                return(this.GetPathList(this.readList));

            case RegistryPermissionAccess.Write:
                return(this.GetPathList(this.writeList));

            case RegistryPermissionAccess.Create:
                return(this.GetPathList(this.createList));
            }
            this.ThrowInvalidFlag(access, false);
IL_6E:
            return(null);
        }
Пример #31
0
        public String GetPathList(RegistryPermissionAccess access)
        {
            // SafeCritical: these are registry paths, which means we're not leaking file system information here
            VerifyAccess(access);
            ExclusiveAccess(access);

            if ((access & RegistryPermissionAccess.Read) != 0)
            {
                if (m_read == null)
                {
                    return("");
                }
                return(m_read.UnsafeToString());
            }

            if ((access & RegistryPermissionAccess.Write) != 0)
            {
                if (m_write == null)
                {
                    return("");
                }
                return(m_write.UnsafeToString());
            }

            if ((access & RegistryPermissionAccess.Create) != 0)
            {
                if (m_create == null)
                {
                    return("");
                }
                return(m_create.UnsafeToString());
            }

            /* not reached */

            return("");
        }
Пример #32
0
        public string GetPathList(RegistryPermissionAccess access)
        {
            switch (access)
            {
            case RegistryPermissionAccess.AllAccess:
            case RegistryPermissionAccess.NoAccess:
                ThrowInvalidFlag(access, true);
                break;

            case RegistryPermissionAccess.Create:
                return(GetPathList(createList));

            case RegistryPermissionAccess.Read:
                return(GetPathList(readList));

            case RegistryPermissionAccess.Write:
                return(GetPathList(writeList));

            default:
                ThrowInvalidFlag(access, false);
                break;
            }
            return(null);            // never reached
        }
Пример #33
0
        // Properties

        // Methods

        public void AddPathList(RegistryPermissionAccess access, string pathList)
        {
            if (pathList == null)
            {
                throw new ArgumentNullException("pathList");
            }

            switch (access)
            {
            case RegistryPermissionAccess.AllAccess:
                AddWithUnionKey(createList, pathList);
                AddWithUnionKey(readList, pathList);
                AddWithUnionKey(writeList, pathList);
                break;

            case RegistryPermissionAccess.NoAccess:
                // ??? unit tests doesn't show removal using NoAccess ???
                break;

            case RegistryPermissionAccess.Create:
                AddWithUnionKey(createList, pathList);
                break;

            case RegistryPermissionAccess.Read:
                AddWithUnionKey(readList, pathList);
                break;

            case RegistryPermissionAccess.Write:
                AddWithUnionKey(writeList, pathList);
                break;

            default:
                ThrowInvalidFlag(access, false);
                break;
            }
        }
Пример #34
0
        /// <include file='doc\RegistryPermission.uex' path='docs/doc[@for="RegistryPermission.GetPathList"]/*' />
        public String GetPathList(RegistryPermissionAccess access)
        {
            VerifyAccess(access);
            ExclusiveAccess(access);

            if ((access & RegistryPermissionAccess.Read) != 0)
            {
                if (m_read == null)
                {
                    return("");
                }
                return(m_read.ToString());
            }

            if ((access & RegistryPermissionAccess.Write) != 0)
            {
                if (m_write == null)
                {
                    return("");
                }
                return(m_write.ToString());
            }

            if ((access & RegistryPermissionAccess.Create) != 0)
            {
                if (m_create == null)
                {
                    return("");
                }
                return(m_create.ToString());
            }

            /* not reached */

            return("");
        }
Пример #35
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        public void AddPathList( RegistryPermissionAccess access, AccessControlActions control, String pathList )
        { 
            VerifyAccess( access );
 
            if ((access & RegistryPermissionAccess.Read) != 0) 
            {
                if (m_read == null) 
                    m_read = new StringExpressionSet();
                m_read.AddExpressions( pathList );
            }
 
            if ((access & RegistryPermissionAccess.Write) != 0)
            { 
                if (m_write == null) 
                    m_write = new StringExpressionSet();
                m_write.AddExpressions( pathList ); 
            }

            if ((access & RegistryPermissionAccess.Create) != 0)
            { 
                if (m_create == null)
                    m_create = new StringExpressionSet(); 
                m_create.AddExpressions( pathList ); 
            }
 
#if !FEATURE_PAL && FEATURE_MACL
            if ((control & AccessControlActions.View) != 0)
            {
                if (m_viewAcl == null) 
                    m_viewAcl = new StringExpressionSet();
                m_viewAcl.AddExpressions( pathList ); 
            } 

            if ((control & AccessControlActions.Change) != 0) 
            {
                if (m_changeAcl == null)
                    m_changeAcl = new StringExpressionSet();
                m_changeAcl.AddExpressions( pathList ); 
            }
#endif 
        } 
Пример #36
0
		internal void ThrowInvalidFlag (RegistryPermissionAccess flag, bool context) 
		{
			string msg = null;
			if (context)
				msg = Locale.GetText ("Unknown flag '{0}'.");
			else
				msg = Locale.GetText ("Invalid flag '{0}' in this context.");
			throw new ArgumentException (String.Format (msg, flag), "flag");
		}
 public RegistryPermission(RegistryPermissionAccess access, string pathList)
 {
 }
Пример #38
0
		public string GetPathList (RegistryPermissionAccess access)
		{
			switch (access) {
				case RegistryPermissionAccess.AllAccess:
				case RegistryPermissionAccess.NoAccess:
					ThrowInvalidFlag (access, true);
					break;
				case RegistryPermissionAccess.Create:
					return GetPathList (createList);
				case RegistryPermissionAccess.Read:
					return GetPathList (readList);
				case RegistryPermissionAccess.Write:
					return GetPathList (writeList);
				default:
					ThrowInvalidFlag (access, false);
					break;
			}
			return null; // never reached
		}
Пример #39
0
		public void SetPathList (RegistryPermissionAccess access, string pathList)
		{
			if (pathList == null)
				throw new ArgumentNullException ("pathList");

			string[] paths;
			switch (access) {
				case RegistryPermissionAccess.AllAccess:
					createList.Clear ();
					readList.Clear ();
					writeList.Clear ();
					paths = pathList.Split (';');
					foreach (string path in paths) {
						createList.Add (path);
						readList.Add (path);
						writeList.Add (path);
					}
					break;
				case RegistryPermissionAccess.NoAccess:
					// ??? unit tests doesn't show removal using NoAccess ???
					break;
				case RegistryPermissionAccess.Create:
					createList.Clear ();
					paths = pathList.Split (';');
					foreach (string path in paths) {
						createList.Add (path);
					}
					break;
				case RegistryPermissionAccess.Read:
					readList.Clear ();
					paths = pathList.Split (';');
					foreach (string path in paths) {
						readList.Add (path);
					}
					break;
				case RegistryPermissionAccess.Write:
					writeList.Clear ();
					paths = pathList.Split (';');
					foreach (string path in paths) {
						writeList.Add (path);
					}
					break;
				default:
					ThrowInvalidFlag (access, false);
					break;
			}
		}
 public RegistryPermission(RegistryPermissionAccess access, System.Security.AccessControl.AccessControlActions control, string pathList)
 {
 }
Пример #41
0
		public void AddPathList (RegistryPermissionAccess access, AccessControlActions control, string pathList) 
		{
			throw new NotImplementedException ();
		}
Пример #42
0
 [System.Security.SecuritySafeCritical]  // auto-generated
 public RegistryPermission( RegistryPermissionAccess access, String pathList )
 {
     SetPathList( access, pathList ); 
 }
Пример #43
0
 [System.Security.SecuritySafeCritical]  // auto-generated
 public RegistryPermission( RegistryPermissionAccess access, AccessControlActions control, String pathList ) 
 {
     m_unrestricted = false;
     AddPathList( access, control, pathList );
 } 
Пример #44
0
 // Read Key Permission
 private void GetKeyReadPermission(out RegistryPermissionAccess access, out string path) {
    access = RegistryPermissionAccess.Read;
    path   = keyName + "\\.";
 }
 public RegistryPermission(RegistryPermissionAccess access, string pathList)
 {
 }
Пример #46
0
 private void GetSubTreeReadWritePermission(string subkeyName, out RegistryPermissionAccess access, out string path) {
     access = RegistryPermissionAccess.Write | RegistryPermissionAccess.Read;
     path   = keyName + "\\" + subkeyName;
 }
Пример #47
0
 private void GetSubKeyWritePermission(string subkeyName, out RegistryPermissionAccess access, out string path) {
     // If we want to open a subkey of a read-only key as writeable, we need to do the check.
     access = RegistryPermissionAccess.Write;
     path   = keyName + "\\" + subkeyName + "\\.";
 }
Пример #48
0
 [System.Security.SecuritySafeCritical]  // auto-generated
 public void AddPathList( RegistryPermissionAccess access, String pathList ) 
 { 
     AddPathList( access, AccessControlActions.None, pathList );
 } 
Пример #49
0
     public String GetPathList( RegistryPermissionAccess access )
     {
         // SafeCritical: these are registry paths, which means we're not leaking file system information here
         VerifyAccess( access );
         ExclusiveAccess( access );
 
         if ((access & RegistryPermissionAccess.Read) != 0)
         {
             if (m_read == null)
             {
                 return "";
             }
             return m_read.UnsafeToString();
         }
         
         if ((access & RegistryPermissionAccess.Write) != 0)
         {
             if (m_write == null)
             {
                 return "";
             }
             return m_write.UnsafeToString();
         }
 
         if ((access & RegistryPermissionAccess.Create) != 0)
         {
             if (m_create == null)
             {
                 return "";
             }
             return m_create.UnsafeToString();
         }
         
         /* not reached */
         
         return "";
     }     
 public void SetPathList(RegistryPermissionAccess access, string pathList)
 {
 }
Пример #51
0
 private void GetSubKeyCreatePermission(string subkeyName, out RegistryPermissionAccess access, out string path) {
     access = RegistryPermissionAccess.Create;
     path   = keyName + "\\" + subkeyName + "\\."; 
 }
Пример #52
0
        public String GetPathList( RegistryPermissionAccess access ) 
        {
            VerifyAccess( access );
            ExclusiveAccess( access );
 
            if ((access & RegistryPermissionAccess.Read) != 0)
            { 
                if (m_read == null) 
                {
                    return ""; 
                }
                return m_read.ToString();
            }
 
            if ((access & RegistryPermissionAccess.Write) != 0)
            { 
                if (m_write == null) 
                {
                    return ""; 
                }
                return m_write.ToString();
            }
 
            if ((access & RegistryPermissionAccess.Create) != 0)
            { 
                if (m_create == null) 
                {
                    return ""; 
                }
                return m_create.ToString();
            }
 
            /* not reached */
 
            return ""; 
        }
Пример #53
0
 private void GetValueCreatePermission(string valueName, out RegistryPermissionAccess access, out string path) {
     access = RegistryPermissionAccess.Create;
     path   = keyName+"\\"+valueName;
 }
 public string GetPathList(RegistryPermissionAccess access)
 {
   return default(string);
 }
Пример #55
0
 private void VerifyAccess( RegistryPermissionAccess access )
 {
     if ((access & ~RegistryPermissionAccess.AllAccess) != 0)
         throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)access)); 
 }
        public RegistryPermission (RegistryPermissionAccess access, string pathList) {

          return default(RegistryPermission);
        }
 public RegistryPermission(RegistryPermissionAccess access, System.Security.AccessControl.AccessControlActions control, string pathList)
 {
 }
Пример #58
0
        private void ExclusiveAccess( RegistryPermissionAccess access ) 
        {
            if (access == RegistryPermissionAccess.NoAccess) 
            {
                throw new ArgumentException( Environment.GetResourceString("Arg_EnumNotSingleFlag") );
            }
 
            if (((int) access & ((int)access-1)) != 0)
            { 
                throw new ArgumentException( Environment.GetResourceString("Arg_EnumNotSingleFlag") ); 
            }
        } 
 public void SetPathList(RegistryPermissionAccess access, string pathList)
 {
 }
 public string GetPathList(RegistryPermissionAccess access)
 {
     return(default(string));
 }