private static IApplicationTrustManager DecodeAppTrustManager() { if (File.InternalExists(ApplicationSecurityManager.s_machineConfigFile)) { string end; using (FileStream fileStream = new FileStream(ApplicationSecurityManager.s_machineConfigFile, FileMode.Open, FileAccess.Read)) end = new StreamReader((Stream)fileStream).ReadToEnd(); SecurityElement securityElement1 = SecurityElement.FromString(end).SearchForChildByTag("mscorlib"); if (securityElement1 != null) { SecurityElement securityElement2 = securityElement1.SearchForChildByTag("security"); if (securityElement2 != null) { SecurityElement securityElement3 = securityElement2.SearchForChildByTag("policy"); if (securityElement3 != null) { SecurityElement securityElement4 = securityElement3.SearchForChildByTag("ApplicationSecurityManager"); if (securityElement4 != null) { SecurityElement elTrustManager = securityElement4.SearchForChildByTag("IApplicationTrustManager"); if (elTrustManager != null) { IApplicationTrustManager applicationTrustManager = ApplicationSecurityManager.DecodeAppTrustManagerFromElement(elTrustManager); if (applicationTrustManager != null) { return(applicationTrustManager); } } } } } } } return(ApplicationSecurityManager.DecodeAppTrustManagerFromElement(ApplicationSecurityManager.CreateDefaultApplicationTrustManagerElement())); }
private static IApplicationTrustManager DecodeAppTrustManager() { if (!File.InternalExists(s_machineConfigFile)) { goto defaultTrustManager; } // A config file exists. Decode the trust manager from its Xml. String configFileStr; using (FileStream contents = new FileStream(s_machineConfigFile, FileMode.Open, FileAccess.Read)) { configFileStr = new StreamReader(contents).ReadToEnd(); } SecurityElement elRoot = SecurityElement.FromString(configFileStr); SecurityElement elMscorlib = elRoot.SearchForChildByTag("mscorlib"); if (elMscorlib == null) { goto defaultTrustManager; } SecurityElement elSecurity = elMscorlib.SearchForChildByTag("security"); if (elSecurity == null) { goto defaultTrustManager; } SecurityElement elPolicy = elSecurity.SearchForChildByTag("policy"); if (elPolicy == null) { goto defaultTrustManager; } SecurityElement elSecurityManager = elPolicy.SearchForChildByTag("ApplicationSecurityManager"); if (elSecurityManager == null) { goto defaultTrustManager; } SecurityElement elTrustManager = elSecurityManager.SearchForChildByTag("IApplicationTrustManager"); if (elTrustManager == null) { goto defaultTrustManager; } IApplicationTrustManager appTrustManager = DecodeAppTrustManagerFromElement(elTrustManager); if (appTrustManager == null) { goto defaultTrustManager; } return(appTrustManager); defaultTrustManager: return(DecodeAppTrustManagerFromElement(CreateDefaultApplicationTrustManagerElement())); }
private void CheckFromXml(IApplicationTrustManager atm) { SecurityElement se = new SecurityElement("IApplicationTrustManager"); se.AddAttribute("class", defaultTrustManagerTypeName); se.AddAttribute("version", "1"); atm.FromXml(se); // accepted CheckXml(atm.ToXml()); }
private static IApplicationTrustManager DecodeAppTrustManagerFromElement(SecurityElement elTrustManager) { new ReflectionPermission(ReflectionPermissionFlag.MemberAccess).Assert(); Type type = Type.GetType(elTrustManager.Attribute("class"), false, false); if (type == (Type)null) { return((IApplicationTrustManager)null); } IApplicationTrustManager applicationTrustManager = Activator.CreateInstance(type) as IApplicationTrustManager; if (applicationTrustManager != null) { applicationTrustManager.FromXml(elTrustManager); } return(applicationTrustManager); }
private static IApplicationTrustManager DecodeAppTrustManager() { if (File.InternalExists(s_machineConfigFile)) { string str; using (FileStream stream = new FileStream(s_machineConfigFile, FileMode.Open, FileAccess.Read)) { str = new StreamReader(stream).ReadToEnd(); } SecurityElement element2 = SecurityElement.FromString(str).SearchForChildByTag("mscorlib"); if (element2 != null) { SecurityElement element3 = element2.SearchForChildByTag("security"); if (element3 != null) { SecurityElement element4 = element3.SearchForChildByTag("policy"); if (element4 != null) { SecurityElement element5 = element4.SearchForChildByTag("ApplicationSecurityManager"); if (element5 != null) { SecurityElement elTrustManager = element5.SearchForChildByTag("IApplicationTrustManager"); if (elTrustManager != null) { IApplicationTrustManager manager = DecodeAppTrustManagerFromElement(elTrustManager); if (manager != null) { return(manager); } } } } } } } return(DecodeAppTrustManagerFromElement(CreateDefaultApplicationTrustManagerElement())); }
public void CheckToXml (IApplicationTrustManager atm) { CheckXml (atm.ToXml ()); }
private void CheckFromXml (IApplicationTrustManager atm) { SecurityElement se = new SecurityElement ("IApplicationTrustManager"); se.AddAttribute ("class", defaultTrustManagerTypeName); se.AddAttribute ("version", "1"); atm.FromXml (se); // accepted CheckXml (atm.ToXml ()); }
public void CheckToXml(IApplicationTrustManager atm) { CheckXml(atm.ToXml()); }