The Labs \ Source Viewer \ SSCLI \ System.Security \ HostSecurityManagerOptions

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. //
  16. // A HostSecurityManager gives a hosting application the chance to
  17. // participate in the security decisions in the AppDomain.
  18. //
  19. namespace System.Security
  20. {
  21.     using System.Collections;
  22.     using System.Reflection;
  23.     using System.Security;
  24.     using System.Security.Permissions;
  25.     using System.Security.Policy;
  26.     using System.Runtime.Hosting;
  27.    
  28.     [Flags(), Serializable()]
  29.     [System.Runtime.InteropServices.ComVisible(true)]
  30.     public enum HostSecurityManagerOptions
  31.     {
  32.         None = 0,
  33.         HostAppDomainEvidence = 1,
  34.         HostPolicyLevel = 2,
  35.         HostAssemblyEvidence = 4,
  36.         HostDetermineApplicationTrust = 8,
  37.         HostResolvePolicy = 16,
  38.         AllFlags = 31
  39.     }
  40.    
  41.     [Serializable()]
  42.     [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
  43.     [SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)]
  44.     [System.Runtime.InteropServices.ComVisible(true)]
  45.     public class HostSecurityManager
  46.     {
  47.         public HostSecurityManager()
  48.         {
  49.         }
  50.        
  51.         // The host can choose which events he wants to participate in. This property can be set when
  52.         // the host only cares about a subset of the capabilities exposed through the HostSecurityManager.
  53.         public virtual HostSecurityManagerOptions Flags {
  54. // We use AllFlags as the default.
  55.             get { return HostSecurityManagerOptions.AllFlags; }
  56.         }
  57.        
  58.         // provide policy for the AppDomain.
  59.         public virtual PolicyLevel DomainPolicy {
  60.             get { return null; }
  61.         }
  62.        
  63.         public virtual Evidence ProvideAppDomainEvidence(Evidence inputEvidence)
  64.         {
  65.             // The default implementation does not modify the input evidence.
  66.             return inputEvidence;
  67.         }
  68.        
  69.         public virtual Evidence ProvideAssemblyEvidence(Assembly loadedAssembly, Evidence inputEvidence)
  70.         {
  71.             // The default implementation does not modify the input evidence.
  72.             return inputEvidence;
  73.         }
  74.        
  75.        
  76.         public virtual PermissionSet ResolvePolicy(Evidence evidence)
  77.         {
  78.             return SecurityManager.PolicyManager.ResolveHelper(evidence);
  79.         }
  80.     }
  81. }

Developer Fusion