Example #1
0
 public FileIOPermission(FileIOPermissionAccess flag, String pathList)
 {
     if (pathList == null)
     {
         throw new ArgumentNullException("pathList");
     }
     if ((flag & ~(FileIOPermissionAccess.AllAccess)) != 0)
     {
         throw new ArgumentException(_("Arg_FileIOAccess"));
     }
     this.state = PermissionState.None;
     String[] split = EnvironmentPermission.SplitPath(pathList);
     if ((flag & FileIOPermissionAccess.Read) != 0)
     {
         readList = split;
     }
     if ((flag & FileIOPermissionAccess.Write) != 0)
     {
         writeList = split;
     }
     if ((flag & FileIOPermissionAccess.Append) != 0)
     {
         appendList = split;
     }
     if ((flag & FileIOPermissionAccess.PathDiscovery) != 0)
     {
         discoveryList = split;
     }
     allLocalFiles = FileIOPermissionAccess.NoAccess;
     allFiles      = FileIOPermissionAccess.NoAccess;
 }
Example #2
0
        // Convert an XML value into a permissions value.
        public override void FromXml(SecurityElement esd)
        {
            String value;

            if (esd == null)
            {
                throw new ArgumentNullException("esd");
            }
            if (esd.Attribute("version") != "1")
            {
                throw new ArgumentException(_("Arg_PermissionVersion"));
            }
            value = esd.Attribute("Unrestricted");
            if (value != null && Boolean.Parse(value))
            {
                state = PermissionState.Unrestricted;
            }
            else
            {
                state = PermissionState.None;
            }
            if (state != PermissionState.Unrestricted)
            {
                readList = EnvironmentPermission.SplitPath
                               (esd.Attribute("Read"), ';');
                writeList = EnvironmentPermission.SplitPath
                                (esd.Attribute("Write"), ';');
                appendList = EnvironmentPermission.SplitPath
                                 (esd.Attribute("Append"), ';');
                discoveryList = EnvironmentPermission.SplitPath
                                    (esd.Attribute("PathDiscovery"), ';');
            }
        }
Example #3
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;
     }
 }
Example #4
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);
     }
 }
Example #5
0
 // Create a permission object that corresponds to this attribute.
 public override IPermission CreatePermission()
 {
     if (Unrestricted)
     {
         return(new EnvironmentPermission
                    (PermissionState.Unrestricted));
     }
     else
     {
         return(new EnvironmentPermission
                    (PermissionState.None,
                    EnvironmentPermission.SplitPath(read),
                    EnvironmentPermission.SplitPath(write)));
     }
 }
Example #6
0
 // Create a permission object that corresponds to this attribute.
 public override IPermission CreatePermission()
 {
     if (Unrestricted)
     {
         return(new FileIOPermission
                    (PermissionState.Unrestricted));
     }
     else
     {
         return(new FileIOPermission
                    (PermissionState.None,
                    EnvironmentPermission.SplitPath(read),
                    EnvironmentPermission.SplitPath(write),
                    EnvironmentPermission.SplitPath(append),
                    EnvironmentPermission.SplitPath(pathDiscovery),
                    FileIOPermissionAccess.NoAccess,
                    FileIOPermissionAccess.NoAccess));
     }
 }