Advertisement
ELFs

WebBrowserPermissions @20001ED

Nov 13th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.65 KB | None | 0 0
  1. ========================//ELF\\=====================================
  2. #XMPP: hakt@xmpp.jp
  3. #Wire: @hakt
  4. =====================================================================
  5. using System;
  6. using MS.Internal.WindowsBase;
  7.  
  8. namespace System.Security.Permissions
  9. {
  10.     /// <summary>The <see cref="T:System.Security.Permissions.WebBrowserPermission" /> object controls the ability to create the WebBrowser control.</summary>
  11.     // Token: 0x020001ED RID: 493
  12.     [Serializable]
  13.     public sealed class WebBrowserPermission : CodeAccessPermission, IUnrestrictedPermission
  14.     {
  15.         /// <summary>Initializes a new instance of the <see cref="T:System.Security.Permissions.WebBrowserPermission" /> class.</summary>
  16.         // Token: 0x0600145D RID: 5213 RVA: 0x00049D58 File Offset: 0x00047F58
  17.         public WebBrowserPermission()
  18.         {
  19.             this._webBrowserPermissionLevel = WebBrowserPermissionLevel.Safe;
  20.         }
  21.  
  22.         /// <summary>Initializes a new instance of the <see cref="T:System.Security.Permissions.WebBrowserPermission" /> class by specifying a permission state.</summary>
  23.         /// <param name="state">An enumerated value of <see cref="T:System.Security.Permissions.PermissionState" />.</param>
  24.         // Token: 0x0600145E RID: 5214 RVA: 0x00049D67 File Offset: 0x00047F67
  25.         public WebBrowserPermission(PermissionState state)
  26.         {
  27.             if (state == PermissionState.Unrestricted)
  28.             {
  29.                 this._webBrowserPermissionLevel = WebBrowserPermissionLevel.Unrestricted;
  30.                 return;
  31.             }
  32.             if (state == PermissionState.None)
  33.             {
  34.                 this._webBrowserPermissionLevel = WebBrowserPermissionLevel.None;
  35.                 return;
  36.             }
  37.             throw new ArgumentException(SR.Get("InvalidPermissionState"));
  38.         }
  39.  
  40.         /// <summary>Initializes a new instance of the <see cref="T:System.Security.Permissions.WebBrowserPermission" /> class by specifying the Web browser permission level.</summary>
  41.         /// <param name="webBrowserPermissionLevel">An enumerated value of <see cref="T:System.Security.Permissions.WebBrowserPermissionLevel" />.</param>
  42.         // Token: 0x0600145F RID: 5215 RVA: 0x00049D95 File Offset: 0x00047F95
  43.         public WebBrowserPermission(WebBrowserPermissionLevel webBrowserPermissionLevel)
  44.         {
  45.             WebBrowserPermission.VerifyWebBrowserPermissionLevel(webBrowserPermissionLevel);
  46.             this._webBrowserPermissionLevel = webBrowserPermissionLevel;
  47.         }
  48.  
  49.         /// <summary>Returns a value indicating whether the current permission is unrestricted.</summary>
  50.         /// <returns>
  51.         ///     <see langword="true" /> if the <see cref="P:System.Security.Permissions.WebBrowserPermission.Level" /> property is set to <see cref="F:System.Security.Permissions.WebBrowserPermissionLevel.Unrestricted" />; otherwise, <see langword="false" />.</returns>
  52.         // Token: 0x06001460 RID: 5216 RVA: 0x00049DAA File Offset: 0x00047FAA
  53.         public bool IsUnrestricted()
  54.         {
  55.             return this._webBrowserPermissionLevel == WebBrowserPermissionLevel.Unrestricted;
  56.         }
  57.  
  58.         /// <summary>Determines whether the current permission is a subset of the specified permission.</summary>
  59.         /// <param name="target">A permission that is to be tested for the subset relationship. This permission must be of the same type as the current permission.</param>
  60.         /// <returns>
  61.         ///     <see langword="true" /> if the current permission is a subset of the specified permission; otherwise, <see langword="false" />.</returns>
  62.         // Token: 0x06001461 RID: 5217 RVA: 0x00049DB8 File Offset: 0x00047FB8
  63.         public override bool IsSubsetOf(IPermission target)
  64.         {
  65.             if (target == null)
  66.             {
  67.                 return this._webBrowserPermissionLevel == WebBrowserPermissionLevel.None;
  68.             }
  69.             WebBrowserPermission webBrowserPermission = target as WebBrowserPermission;
  70.             if (webBrowserPermission != null)
  71.             {
  72.                 return this._webBrowserPermissionLevel <= webBrowserPermission._webBrowserPermissionLevel;
  73.             }
  74.             throw new ArgumentException(SR.Get("TargetNotWebBrowserPermissionLevel"));
  75.         }
  76.  
  77.         /// <summary>Creates and returns a permission that is the intersection of the current permission and the specified permission.</summary>
  78.         /// <param name="target">A permission to intersect with the current permission. It must be of the same type as the current permission.</param>
  79.         /// <returns>The intersection of two permissions is a permission that describes the state that they both describe in common. Only a demand that passes both original permissions will be valid for the intersected permission.</returns>
  80.         // Token: 0x06001462 RID: 5218 RVA: 0x00049E00 File Offset: 0x00048000
  81.         public override IPermission Intersect(IPermission target)
  82.         {
  83.             if (target == null)
  84.             {
  85.                 return null;
  86.             }
  87.             WebBrowserPermission webBrowserPermission = target as WebBrowserPermission;
  88.             if (webBrowserPermission == null)
  89.             {
  90.                 throw new ArgumentException(SR.Get("TargetNotWebBrowserPermissionLevel"));
  91.             }
  92.             WebBrowserPermissionLevel webBrowserPermissionLevel = (this._webBrowserPermissionLevel < webBrowserPermission._webBrowserPermissionLevel) ? this._webBrowserPermissionLevel : webBrowserPermission._webBrowserPermissionLevel;
  93.             if (webBrowserPermissionLevel == WebBrowserPermissionLevel.None)
  94.             {
  95.                 return null;
  96.             }
  97.             return new WebBrowserPermission(webBrowserPermissionLevel);
  98.         }
  99.  
  100.         /// <summary>Creates a permission that is the union of the current permission and the specified permission.</summary>
  101.         /// <param name="target">A permission to combine with the current permission. It must be of the same type as the current permission.</param>
  102.         /// <returns>A new permission that represents the union of the current permission and the specified permission.</returns>
  103.         // Token: 0x06001463 RID: 5219 RVA: 0x00049E54 File Offset: 0x00048054
  104.         public override IPermission Union(IPermission target)
  105.         {
  106.             if (target == null)
  107.             {
  108.                 return this.Copy();
  109.             }
  110.             WebBrowserPermission webBrowserPermission = target as WebBrowserPermission;
  111.             if (webBrowserPermission == null)
  112.             {
  113.                 throw new ArgumentException(SR.Get("TargetNotWebBrowserPermissionLevel"));
  114.             }
  115.             WebBrowserPermissionLevel webBrowserPermissionLevel = (this._webBrowserPermissionLevel > webBrowserPermission._webBrowserPermissionLevel) ? this._webBrowserPermissionLevel : webBrowserPermission._webBrowserPermissionLevel;
  116.             if (webBrowserPermissionLevel == WebBrowserPermissionLevel.None)
  117.             {
  118.                 return null;
  119.             }
  120.             return new WebBrowserPermission(webBrowserPermissionLevel);
  121.         }
  122.  
  123.         /// <summary>Creates and returns an identical copy of the current permission.</summary>
  124.         /// <returns>A copy of the current permission.</returns>
  125.         // Token: 0x06001464 RID: 5220 RVA: 0x00049EAD File Offset: 0x000480AD
  126.         public override IPermission Copy()
  127.         {
  128.             return new WebBrowserPermission(this._webBrowserPermissionLevel);
  129.         }
  130.  
  131.         /// <summary>Creates an XML encoding of the permission and its current state.</summary>
  132.         /// <returns>An XML encoding of the permission, including any state information.</returns>
  133.         // Token: 0x06001465 RID: 5221 RVA: 0x00049EBC File Offset: 0x000480BC
  134.         public override SecurityElement ToXml()
  135.         {
  136.             SecurityElement securityElement = new SecurityElement("IPermission");
  137.             securityElement.AddAttribute("class", base.GetType().AssemblyQualifiedName);
  138.             securityElement.AddAttribute("version", "1");
  139.             if (this.IsUnrestricted())
  140.             {
  141.                 securityElement.AddAttribute("Unrestricted", bool.TrueString);
  142.             }
  143.             else
  144.             {
  145.                 securityElement.AddAttribute("Level", this._webBrowserPermissionLevel.ToString());
  146.             }
  147.             return securityElement;
  148.         }
  149.  
  150.         /// <summary>Reconstructs a permission with a specified state from an XML encoding.</summary>
  151.         /// <param name="securityElement">The XML encoding to use to reconstruct the permission.</param>
  152.         // Token: 0x06001466 RID: 5222 RVA: 0x00049F34 File Offset: 0x00048134
  153.         public override void FromXml(SecurityElement securityElement)
  154.         {
  155.             if (securityElement == null)
  156.             {
  157.                 throw new ArgumentNullException("securityElement");
  158.             }
  159.             string text = securityElement.Attribute("class");
  160.             if (text == null || text.IndexOf(base.GetType().FullName, StringComparison.Ordinal) == -1)
  161.             {
  162.                 throw new ArgumentNullException("securityElement");
  163.             }
  164.             string text2 = securityElement.Attribute("Unrestricted");
  165.             if (text2 != null && bool.Parse(text2))
  166.             {
  167.                 this._webBrowserPermissionLevel = WebBrowserPermissionLevel.Unrestricted;
  168.                 return;
  169.             }
  170.             this._webBrowserPermissionLevel = WebBrowserPermissionLevel.None;
  171.             string text3 = securityElement.Attribute("Level");
  172.             if (text3 != null)
  173.             {
  174.                 this._webBrowserPermissionLevel = (WebBrowserPermissionLevel)Enum.Parse(typeof(WebBrowserPermissionLevel), text3);
  175.                 return;
  176.             }
  177.             throw new ArgumentException(SR.Get("BadXml", new object[]
  178.             {
  179.                 "level"
  180.             }));
  181.         }
  182.  
  183.         /// <summary>Gets or sets the current value of the Web browser permission level.</summary>
  184.         /// <returns>The current value of the Web browser permission level.</returns>
  185.         // Token: 0x17000421 RID: 1057
  186.         // (get) Token: 0x06001467 RID: 5223 RVA: 0x00049FEC File Offset: 0x000481EC
  187.         // (set) Token: 0x06001468 RID: 5224 RVA: 0x00049FF4 File Offset: 0x000481F4
  188.         public WebBrowserPermissionLevel Level
  189.         {
  190.             get
  191.             {
  192.                 return this._webBrowserPermissionLevel;
  193.             }
  194.             set
  195.             {
  196.                 WebBrowserPermission.VerifyWebBrowserPermissionLevel(value);
  197.                 this._webBrowserPermissionLevel = value;
  198.             }
  199.         }
  200.  
  201.         // Token: 0x06001469 RID: 5225 RVA: 0x0004A003 File Offset: 0x00048203
  202.         internal static void VerifyWebBrowserPermissionLevel(WebBrowserPermissionLevel level)
  203.         {
  204.             if (level < WebBrowserPermissionLevel.None || level > WebBrowserPermissionLevel.Unrestricted)
  205.             {
  206.                 throw new ArgumentException(SR.Get("InvalidPermissionLevel"));
  207.             }
  208.         }
  209.  
  210.         // Token: 0x0400154E RID: 5454
  211.         private WebBrowserPermissionLevel _webBrowserPermissionLevel;
  212.     }
  213. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement