internal static bool CanUseQuickCache(CodeGroup group) { ArrayList arrayList = new ArrayList(); arrayList.Add((object)group); for (int index = 0; index < arrayList.Count; ++index) { group = (CodeGroup)arrayList[index]; if (!(group is IUnionSemanticCodeGroup) || !PolicyManager.TestPolicyStatement(group.PolicyStatement)) { return(false); } IMembershipCondition membershipCondition = group.MembershipCondition; if (membershipCondition != null && !(membershipCondition is IConstantMembershipCondition)) { return(false); } IList children = group.Children; if (children != null && children.Count > 0) { foreach (object obj in (IEnumerable)children) { arrayList.Add(obj); } } } return(true); }
// Token: 0x06001D76 RID: 7542 RVA: 0x00066A5C File Offset: 0x00064C5C internal static bool CanUseQuickCache(CodeGroup group) { ArrayList arrayList = new ArrayList(); arrayList.Add(group); for (int i = 0; i < arrayList.Count; i++) { group = (CodeGroup)arrayList[i]; IUnionSemanticCodeGroup unionSemanticCodeGroup = group as IUnionSemanticCodeGroup; if (unionSemanticCodeGroup == null) { return(false); } if (!PolicyManager.TestPolicyStatement(group.PolicyStatement)) { return(false); } IMembershipCondition membershipCondition = group.MembershipCondition; if (membershipCondition != null && !(membershipCondition is IConstantMembershipCondition)) { return(false); } IList children = group.Children; if (children != null && children.Count > 0) { foreach (object value in children) { arrayList.Add(value); } } } return(true); }
public static void SavePolicyLevel(PolicyLevel level) { if (!AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled) { throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyExplicit")); } PolicyManager.EncodeLevel(level); }
private void EncodeLevel(string label) { for (int i = 0; i < this.PolicyLevels.Count; i++) { PolicyLevel policyLevel = (PolicyLevel)this.PolicyLevels[i]; if (policyLevel.Label.Equals(label)) { PolicyManager.EncodeLevel(policyLevel); return; } } }
private void EncodeLevel(string label) { for (int index = 0; index < this.PolicyLevels.Count; ++index) { PolicyLevel level = (PolicyLevel)this.PolicyLevels[index]; if (level.Label.Equals(label)) { PolicyManager.EncodeLevel(level); break; } } }
public static PermissionSet ResolveSystemPolicy(Evidence evidence) { if (!AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled) { throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyExplicit")); } if (PolicyManager.IsGacAssembly(evidence)) { return(new PermissionSet(PermissionState.Unrestricted)); } return(SecurityManager.polmgr.CodeGroupResolve(evidence, true)); }
internal static void EncodeLevel(PolicyLevel level) { if (level.Path == null) { throw new PolicyException(Environment.GetResourceString("Policy_UnableToSave", (object)level.Label, (object)Environment.GetResourceString("Policy_SaveNotFileBased"))); } SecurityElement securityElement1 = new SecurityElement("configuration"); SecurityElement child1 = new SecurityElement("mscorlib"); SecurityElement child2 = new SecurityElement("security"); SecurityElement child3 = new SecurityElement("policy"); securityElement1.AddChild(child1); child1.AddChild(child2); child2.AddChild(child3); child3.AddChild(level.ToXml()); try { StringBuilder stringBuilder = new StringBuilder(); Encoding utF8 = Encoding.UTF8; SecurityElement securityElement2 = new SecurityElement("xml"); securityElement2.m_type = SecurityElementType.Format; securityElement2.AddAttribute("version", "1.0"); securityElement2.AddAttribute("encoding", utF8.WebName); stringBuilder.Append(securityElement2.ToString()); stringBuilder.Append(securityElement1.ToString()); byte[] bytes = utF8.GetBytes(stringBuilder.ToString()); string path = level.Path; byte[] data = bytes; int length = data.Length; Exception exceptionForHr = Marshal.GetExceptionForHR(Config.SaveDataByte(path, data, length)); if (exceptionForHr != null) { string str = exceptionForHr != null ? exceptionForHr.Message : string.Empty; throw new PolicyException(Environment.GetResourceString("Policy_UnableToSave", (object)level.Label, (object)str), exceptionForHr); } } catch (Exception ex) { if (ex is PolicyException) { throw ex; } throw new PolicyException(Environment.GetResourceString("Policy_UnableToSave", (object)level.Label, (object)ex.Message), ex); } Config.ResetCacheData(level.ConfigId); if (!PolicyManager.CanUseQuickCache(level.RootCodeGroup)) { return; } Config.SetQuickCache(level.ConfigId, PolicyManager.GenerateQuickCache(level)); }
static private bool InitPolicy() { if (policyManagerInitialized == false) { Type type = typeof(System.Security.PolicyManager); lock (type) { polmgr = new PolicyManager(); policyManagerInitialized = true; } } return(polmgr != null); }
private static void DEBUG_OUT(String str) { #if _DEBUG if (debug) { if (to_file) { PolicyManager._DebugOut(file, str + "\n"); } else { Console.WriteLine(str); } } #endif }
private static void DEBUG_OUT(String str) { #if _DEBUG if (debug) { #if !FEATURE_CORECLR if (to_file) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(str); sb.Append((char)13); sb.Append((char)10); PolicyManager.DebugOut(file, sb.ToString()); } else #endif Console.WriteLine(str); } #endif }
private static void DEBUG_OUT(String str) { #if _DEBUG if (debug) { if (to_file) { StringBuilder sb = new StringBuilder(); sb.Append(str); sb.Append((char)13); sb.Append((char)10); PolicyManager._DebugOut(file, sb.ToString()); } else { Console.WriteLine(str); } } #endif }
static public void SavePolicyLevel(PolicyLevel level) { PolicyManager.EncodeLevel(level); }
internal static void EncodeLevel(PolicyLevel level) { if (level.Path == null) { string resourceString = Environment.GetResourceString("Policy_UnableToSave", new object[] { level.Label, Environment.GetResourceString("Policy_SaveNotFileBased") }); throw new PolicyException(resourceString); } SecurityElement securityElement = new SecurityElement("configuration"); SecurityElement securityElement2 = new SecurityElement("mscorlib"); SecurityElement securityElement3 = new SecurityElement("security"); SecurityElement securityElement4 = new SecurityElement("policy"); securityElement.AddChild(securityElement2); securityElement2.AddChild(securityElement3); securityElement3.AddChild(securityElement4); securityElement4.AddChild(level.ToXml()); try { StringBuilder stringBuilder = new StringBuilder(); Encoding utf = Encoding.UTF8; SecurityElement securityElement5 = new SecurityElement("xml"); securityElement5.m_type = SecurityElementType.Format; securityElement5.AddAttribute("version", "1.0"); securityElement5.AddAttribute("encoding", utf.WebName); stringBuilder.Append(securityElement5.ToString()); stringBuilder.Append(securityElement.ToString()); byte[] bytes = utf.GetBytes(stringBuilder.ToString()); int errorCode = Config.SaveDataByte(level.Path, bytes, bytes.Length); Exception exceptionForHR = Marshal.GetExceptionForHR(errorCode); if (exceptionForHR != null) { string text = (exceptionForHR != null) ? exceptionForHR.Message : string.Empty; throw new PolicyException(Environment.GetResourceString("Policy_UnableToSave", new object[] { level.Label, text }), exceptionForHR); } } catch (Exception ex) { if (ex is PolicyException) { throw ex; } throw new PolicyException(Environment.GetResourceString("Policy_UnableToSave", new object[] { level.Label, ex.Message }), ex); } Config.ResetCacheData(level.ConfigId); if (PolicyManager.CanUseQuickCache(level.RootCodeGroup)) { Config.SetQuickCache(level.ConfigId, PolicyManager.GenerateQuickCache(level)); } }
static private bool InitPolicy() { if(policyManagerInitialized == false) { Type type = typeof( System.Security.PolicyManager ); lock (type) { polmgr = new PolicyManager(); policyManagerInitialized = true; } } return (polmgr != null); }