[Serializable] |
1. Enterprise: security policy for all managed code in an enterprise.
2. Machine: security policy for all managed code run on the computer.
3. User: security policy for all managed code run by the user.
4. Application domain: security policy for all managed code in an application.
A policy level consists of a set of code groups organized into a single rooted tree (see CodeGroup), a set of named permission sets that are referenced by the code groups to specify permissions to be granted to code belonging to the code group, and a list of fully-trusted assemblies.
Use SecurityManager.PolicyHierarchy to enumerate the policy levels.
FullTrustAssemblies | Read-only Gets a list of StrongNameMembershipCondition objects used to determine whether an assembly is a member of the group of assemblies used to evaluate security policy. |
Label | Read-only Gets a descriptive label for the policy level. |
NamedPermissionSets | Read-only Gets a list of named permission sets defined for the policy level. |
RootCodeGroup | Read-write Gets or sets the root code group for the policy level. |
StoreLocation | Read-only Gets the path where the policy file is stored. |
AddFullTrustAssembly | Overloaded:AddFullTrustAssembly(StrongName sn) Adds a StrongNameMembershipCondition corresponding to the specified StrongName to the list of StrongNameMembershipCondition objects used to determine whether an assembly is a member of the group of assemblies that should not be evaluated. |
AddFullTrustAssembly | Overloaded:AddFullTrustAssembly(StrongNameMembershipCondition snMC) Adds the specified StrongNameMembershipCondition to the list of StrongNameMembershipCondition objects used to determine whether an assembly is a member of the group of assemblies that should not be evaluated. |
AddNamedPermissionSet | Adds a NamedPermissionSet to the current policy level. |
ChangeNamedPermissionSet | Replaces a NamedPermissionSet in the current policy level with the specified PermissionSet. |
CreateAppDomainLevel | Creates a new policy level for use at the application domain policy level. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
FromXml | Reconstructs a security object with a given state from an XML encoding. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetNamedPermissionSet | Returns the NamedPermissionSet in the current policy level with the specified name. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
Recover | Replaces the configuration file for this PolicyLevel with the last backup (reflecting the state of policy prior to the last time it was saved) and returns it to the state of the last save. |
RemoveFullTrustAssembly | Overloaded:RemoveFullTrustAssembly(StrongName sn) Removes an assembly with the specified StrongName from the list of assemblies the policy level uses to evaluate policy. |
RemoveFullTrustAssembly | Overloaded:RemoveFullTrustAssembly(StrongNameMembershipCondition snMC) Removes an assembly with the specified StrongNameMembershipCondition from the list of assemblies the policy level uses to evaluate policy. |
RemoveNamedPermissionSet | Overloaded:RemoveNamedPermissionSet(NamedPermissionSet permSet) Removes the specified NamedPermissionSet from the current policy level. |
RemoveNamedPermissionSet | Overloaded:RemoveNamedPermissionSet(string name) Removes the NamedPermissionSet with the specified name from the current policy level. |
Reset | Returns the current policy level to the default state. |
Resolve | Resolves policy based on evidence for the policy level, and returns the resulting PolicyStatement. |
ResolveMatchingCodeGroups | Resolves policy at the policy level and returns the root of a code group tree that matches the evidence. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
ToXml | Creates an XML encoding of the security object and its current state. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public IList FullTrustAssemblies {get;}
|
public string Label {get;}
|
//Write out names (labels) of all policy levels. IEnumerator levels = SecurityManager.PolicyHierarchy(); while (levels.MoveNext()) { PolicyLevel level = (PolicyLevel)levels.Current; Console.WriteLine(level.Label); }
public IList NamedPermissionSets {get;}
|
//Write out names of permission sets in all policy levels. IEnumerator levels = SecurityManager.PolicyHierarchy(); while (levels.MoveNext()) { PolicyLevel level = (PolicyLevel)levels.Current; Console.WriteLine("Policy Level: {0}", level.Label); IEnumerator sets = level.NamedPermissionSets.GetEnumerator(); while (sets.MoveNext()) { NamedPermissionSet pset = (NamedPermissionSet)sets.Current; Console.WriteLine("\tPermission set: {0}", pset.Name); } }
public CodeGroup RootCodeGroup {get; set;}
|
//Write out type of membership condition of root code group in all policy levels. IEnumerator levels = SecurityManager.PolicyHierarchy(); while (levels.MoveNext()) { PolicyLevel level = (PolicyLevel)levels.Current; Console.WriteLine ("Policy Level: {0}", level.Label); CodeGroup group = level.RootCodeGroup; Console.WriteLine ("\tRoot CodeGroup type: {0}", group.MembershipCondition.ToString()); }
public string StoreLocation {get;}
|
public void AddFullTrustAssembly( |
sn
Exception Type | Condition |
---|---|
ArgumentNullException | The sn parameter is null. |
ArgumentException | The StrongName specified by the sn parameter already has full trust. |
public void AddFullTrustAssembly( |
snMC
Exception Type | Condition |
---|---|
ArgumentNullException | The snMC parameter is null. |
ArgumentException | The StrongNameMembershipCondition specified by the snMC parameter already has full trust. |
public void AddNamedPermissionSet( |
permSet
Exception Type | Condition |
---|---|
ArgumentNullException | The permSet parameter is null. |
ArgumentException | The permSet parameter has the same name as an existing NamedPermissionSet in the PolicyLevel. |
public NamedPermissionSet ChangeNamedPermissionSet( |
name
pSet
Exception Type | Condition |
---|---|
ArgumentException | The name parameter is null. -or- The pSet parameter is null. |
ArgumentException | The name parameter is equal to the name of a reserved permission set. -or- The PermissionSet specified by the pSet parameter cannot be found. |
public static PolicyLevel CreateAppDomainLevel(); |
~PolicyLevel(); |
public void FromXml( |
e
Exception Type | Condition |
---|---|
ArgumentNullException | The e parameter is null. |
ArgumentException | The SecurityElement specified by the e parameter is invalid. |
public virtual int GetHashCode(); |
public NamedPermissionSet GetNamedPermissionSet( |
name
Exception Type | Condition |
---|---|
ArgumentNullException | The name parameter is null. |
public Type GetType(); |
protected object MemberwiseClone(); |
public void Recover(); |
Exception Type | Condition |
---|---|
PolicyException | The policy level does not have a valid configuration file. |
This method is used by the caspol -recover option (see ).
public void RemoveFullTrustAssembly( |
sn
Exception Type | Condition |
---|---|
ArgumentNullException | The sn parameter is null. |
ArgumentException | The assembly with the StrongName specified by the sn parameter does not have full trust. |
public void RemoveFullTrustAssembly( |
snMC
Exception Type | Condition |
---|---|
ArgumentNullException | The snMC parameter is null. |
ArgumentException | The StrongNameMembershipCondition specified by the snMC parameter does not have full trust. |
public NamedPermissionSet RemoveNamedPermissionSet( |
permSet
Exception Type | Condition |
---|---|
ArgumentException | The NamedPermissionSet specified by the permSet parameter was not found. |
ArgumentNullException | The permSet parameter is null. |
public NamedPermissionSet RemoveNamedPermissionSet( |
name
Exception Type | Condition |
---|---|
ArgumentException | The name parameter is equal to the name of a reserved permission set. -or- A NamedPermissionSet with the specified name cannot be found. |
ArgumentNullException | The name parameter is null. |
public void Reset(); |
public PolicyStatement Resolve( |
evidence
Exception Type | Condition |
---|---|
PolicyException | The policy level contains multiple matching code groups marked as exclusive. |
ArgumentNullException | The evidence parameter is null. |
In granting permissions to code, security policy uses the resolved policy statements for all applicable policy levels, together with the code request for permissions.
evidence
Exception Type | Condition |
---|---|
PolicyException | The policy level contains multiple matching code groups marked as exclusive. |
ArgumentNullException | The evidence parameter is null. |
Since this method returns a code group that can have child code groups, it is possible for an administrator to examine the code group and its child code groups and determine which code groups match.
public virtual string ToString(); |
public SecurityElement ToXml(); |