本文整理汇总了C#中System.Security.Policy.PolicyLevel类的典型用法代码示例。如果您正苦于以下问题:C# PolicyLevel类的具体用法?C# PolicyLevel怎么用?C# PolicyLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PolicyLevel类属于System.Security.Policy命名空间,在下文中一共展示了PolicyLevel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromXml
public void FromXml (SecurityElement e, PolicyLevel level)
{
MembershipConditionHelper.CheckSecurityElement (e, "e", version, version);
if (!Boolean.TryParse (e.Attribute ("LookAtDir"), out _lookAtDir))
_lookAtDir = false;
// PolicyLevel isn't used as there's no need to resolve NamedPermissionSet references
}
示例2: ToXml
public SecurityElement ToXml(PolicyLevel level)
{
SecurityElement element = new SecurityElement("IMembershipCondition");
XMLUtil.AddClassAttribute(element, base.GetType(), "System.Security.Policy.AllMembershipCondition");
element.AddAttribute("version", "1");
return element;
}
示例3: CreateAppDomain
public AppDomain CreateAppDomain( PolicyLevel policyLevel )
{
var domain = AppDomain.CreateDomain( "medium", AppDomain.CurrentDomain.Evidence );
domain.SetAppDomainPolicy( policyLevel );
return domain;
}
示例4: ToXml
public SecurityElement ToXml( PolicyLevel level )
{
SecurityElement root = new SecurityElement( "IMembershipCondition" );
System.Security.Util.XMLUtil.AddClassAttribute( root, this.GetType(), this.GetType().FullName );
root.AddAttribute( "version", "1" );
return root;
}
示例5: FromXml
public void FromXml( SecurityElement e, PolicyLevel level )
{
if (e == null)
throw new ArgumentNullException("e");
if (!e.Tag.Equals( "IMembershipCondition" ))
throw new ArgumentException( Environment.GetResourceString( "Argument_MembershipConditionElement" ) );
}
示例6: ListPermissionSets
private static void ListPermissionSets(PolicyLevel pLevel)
{
IList namedPermissions = pLevel.NamedPermissionSets;
IEnumerator namedPermission = namedPermissions.GetEnumerator();
while (namedPermission.MoveNext())
{
Console.WriteLine("\t" + ((NamedPermissionSet)namedPermission.Current).Name);
}
}
示例7: ToXml
public SecurityElement ToXml( PolicyLevel level )
{
SecurityElement root = new SecurityElement( "IMembershipCondition" );
System.Security.Util.XMLUtil.AddClassAttribute( root, this.GetType(), "System.Security.Policy.AllMembershipCondition" );
// If you hit this assert then most likely you are trying to change the name of this class.
// This is ok as long as you change the hard coded string above and change the assert below.
Contract.Assert( this.GetType().FullName.Equals( "System.Security.Policy.AllMembershipCondition" ), "Class name changed!" );
root.AddAttribute( "version", "1" );
return root;
}
示例8: ParseXml
protected override void ParseXml(SecurityElement e, PolicyLevel level)
{
string str = e.Attribute("Access");
if (str != null)
{
this.m_access = (FileIOPermissionAccess) Enum.Parse(typeof(FileIOPermissionAccess), str);
}
else
{
this.m_access = FileIOPermissionAccess.NoAccess;
}
}
示例9: FromXml
public void FromXml(SecurityElement e, PolicyLevel level)
{
if (e == null)
{
throw new ArgumentNullException("e");
}
if (!e.Tag.Equals("IMembershipCondition"))
{
throw new ArgumentException(Environment.GetResourceString("Argument_MembershipConditionElement"));
}
lock (this)
{
this.m_zone = System.Security.SecurityZone.NoZone;
this.m_element = e;
}
}
示例10: FromXml
public void FromXml (SecurityElement e, PolicyLevel level)
{
_se = e;
}
示例11: FindCodeGroup
static CodeGroup FindCodeGroup (string name, ref CodeGroup parent, ref PolicyLevel pl)
{
if (name.Length < 1)
return null;
// Notes:
// - labels starts with numbers (e.g. 1.2.1)
// - names cannot start with numbers (A-Z, 0-9 and _)
bool label = Char.IsDigit (name, 0);
// More notes
// - we can't remove the root code group
// - we remove only one group (e.g. name)
for (int i=0; i < Levels.Count; i++) {
pl = (PolicyLevel) Levels [i];
parent = pl.RootCodeGroup;
CodeGroup cg = null;
if (label)
cg = FindCodeGroupByLabel (name, "1", ref parent);
else
cg = FindCodeGroupByName (name, ref parent);
if (cg != null)
return cg;
}
Console.WriteLine ("CodeGroup with {0} '{1}' was not found!",
label ? "label" : "name", name);
return null;
}
示例12: ShowResolveGroup
static void ShowResolveGroup (PolicyLevel pl, Evidence e)
{
Console.WriteLine ("{0}Level: {1}{0}", Environment.NewLine, pl.Label);
CodeGroup cg = pl.ResolveMatchingCodeGroups (e);
Console.WriteLine ("Code Groups:{0}", Environment.NewLine);
ShowCodeGroup (cg, "1");
Console.WriteLine ();
}
示例13: ResolvePolicyLevel
internal static bool ResolvePolicyLevel (ref PermissionSet ps, PolicyLevel pl, Evidence evidence)
{
PolicyStatement pst = pl.Resolve (evidence);
if (pst != null) {
if (ps == null) {
// only for initial (first) policy level processed
ps = pst.PermissionSet;
} else {
ps = ps.Intersect (pst.PermissionSet);
if (ps == null) {
// null is equals to None - exist that null can throw NullReferenceException ;-)
ps = new PermissionSet (PermissionState.None);
}
}
if ((pst.Attributes & PolicyStatementAttribute.LevelFinal) == PolicyStatementAttribute.LevelFinal)
return true;
}
return false;
}
示例14: InitializePolicyHierarchy
private static void InitializePolicyHierarchy ()
{
string machinePolicyPath = Path.GetDirectoryName (Environment.GetMachineConfigPath ());
// note: use InternalGetFolderPath to avoid recursive policy initialization
string userPolicyPath = Path.Combine (Environment.UnixGetFolderPath (Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create), "mono");
PolicyLevel enterprise = new PolicyLevel ("Enterprise", PolicyLevelType.Enterprise);
_level = enterprise;
enterprise.LoadFromFile (Path.Combine (machinePolicyPath, "enterprisesec.config"));
PolicyLevel machine = new PolicyLevel ("Machine", PolicyLevelType.Machine);
_level = machine;
machine.LoadFromFile (Path.Combine (machinePolicyPath, "security.config"));
PolicyLevel user = new PolicyLevel ("User", PolicyLevelType.User);
_level = user;
user.LoadFromFile (Path.Combine (userPolicyPath, "security.config"));
ArrayList al = new ArrayList ();
al.Add (enterprise);
al.Add (machine);
al.Add (user);
_hierarchy = ArrayList.Synchronized (al);
_level = null;
}
示例15: SavePolicyLevel
public static void SavePolicyLevel (PolicyLevel level)
{
// Yes this will throw a NullReferenceException, just like MS (see FDBK13121)
level.Save ();
}