// Convert an XML value into a permissions value. public override void FromXml(SecurityElement esd) { String value; if(esd == null) { throw new ArgumentNullException("esd"); } if(esd.Attribute("version") != "1") { throw new ArgumentException(S._("Arg_PermissionVersion")); } value = esd.Attribute("Unrestricted"); if(value != null && Boolean.Parse(value)) { state = PermissionState.Unrestricted; } else { state = PermissionState.None; } value = esd.Attribute("Level"); if(value != null) { level = (PrintingPermissionLevel) Enum.Parse(typeof(PrintingPermissionLevel), value); } else { level = PrintingPermissionLevel.NoPrinting; } }
public override void FromXml(SecurityElement esd) { if (esd == null) { throw new ArgumentNullException("esd"); } string str = esd.Attribute("class"); if ((str == null) || (str.IndexOf(base.GetType().FullName) == -1)) { throw new ArgumentException(System.Drawing.SR.GetString("InvalidClassName")); } string a = esd.Attribute("Unrestricted"); if ((a != null) && string.Equals(a, "true", StringComparison.OrdinalIgnoreCase)) { this.printingLevel = PrintingPermissionLevel.AllPrinting; } else { this.printingLevel = PrintingPermissionLevel.NoPrinting; string str3 = esd.Attribute("Level"); if (str3 != null) { this.printingLevel = (PrintingPermissionLevel) Enum.Parse(typeof(PrintingPermissionLevel), str3); } } }
public override void FromXml(SecurityElement securityElement) { if (securityElement == null) { throw new ArgumentNullException("securityElement"); } string str = securityElement.Attribute("class"); if ((str == null) || (str.IndexOf(base.GetType().FullName, StringComparison.Ordinal) == -1)) { throw new ArgumentException(SecurityResources.GetResourceString("Argument_InvalidClassAttribute"), "securityElement"); } string strA = securityElement.Attribute("Unrestricted"); if ((strA != null) && (string.Compare(strA, "true", StringComparison.OrdinalIgnoreCase) == 0)) { this.m_flags = DataProtectionPermissionFlags.AllFlags; } else { this.m_flags = DataProtectionPermissionFlags.NoFlags; string str3 = securityElement.Attribute("Flags"); if (str3 != null) { DataProtectionPermissionFlags flags = (DataProtectionPermissionFlags) Enum.Parse(typeof(DataProtectionPermissionFlags), str3); VerifyFlags(flags); this.m_flags = flags; } } }
public override void FromXml(SecurityElement securityElement) { if (securityElement == null) { throw new ArgumentNullException(SR.GetString("AspNetHostingPermissionBadXml", new object[] { "securityElement" })); } if (!securityElement.Tag.Equals("IPermission")) { throw new ArgumentException(SR.GetString("AspNetHostingPermissionBadXml", new object[] { "securityElement" })); } string str = securityElement.Attribute("class"); if (str == null) { throw new ArgumentException(SR.GetString("AspNetHostingPermissionBadXml", new object[] { "securityElement" })); } if (str.IndexOf(base.GetType().FullName, StringComparison.Ordinal) < 0) { throw new ArgumentException(SR.GetString("AspNetHostingPermissionBadXml", new object[] { "securityElement" })); } if (string.Compare(securityElement.Attribute("version"), "1", StringComparison.OrdinalIgnoreCase) != 0) { throw new ArgumentException(SR.GetString("AspNetHostingPermissionBadXml", new object[] { "version" })); } string str3 = securityElement.Attribute("Level"); if (str3 == null) { this._level = AspNetHostingPermissionLevel.None; } else { this._level = (AspNetHostingPermissionLevel) Enum.Parse(typeof(AspNetHostingPermissionLevel), str3); } }
// Convert an XML value into a permissions value. public override void FromXml(SecurityElement esd) { if(esd == null) { throw new ArgumentNullException("esd"); } if(esd.Attribute("version") != "1") { throw new ArgumentException(_("Arg_PermissionVersion")); } name = esd.Attribute("Name"); String value = esd.Attribute("Version"); if(value != null) { version = new Version(value); } else { version = null; } value = esd.Attribute("PublicKeyBlob"); if(value != null) { blob = new StrongNamePublicKeyBlob(value); } else { blob = null; } }
// Convert an XML value into a permissions value. public override void FromXml(SecurityElement esd) { String value; if(esd == null) { throw new ArgumentNullException("esd"); } if(esd.Attribute("version") != "1") { throw new ArgumentException(_("Arg_PermissionVersion")); } value = esd.Attribute("Unrestricted"); if(value != null && Boolean.Parse(value)) { state = PermissionState.Unrestricted; } else { state = PermissionState.None; } value = esd.Attribute("Access"); if(value != null) { flags = (FileDialogPermissionAccess) Enum.Parse(typeof(FileDialogPermissionAccess), value); } else { flags = FileDialogPermissionAccess.None; } }
internal void FromXml(SecurityElement e) { string strA = e.Attribute("Authenticated"); if (strA != null) { this.m_authenticated = string.Compare(strA, "true", StringComparison.OrdinalIgnoreCase) == 0; } else { this.m_authenticated = false; } string str2 = e.Attribute("ID"); if (str2 != null) { this.m_id = str2; } else { this.m_id = null; } string str3 = e.Attribute("Role"); if (str3 != null) { this.m_role = str3; } else { this.m_role = null; } }
public PrincipalInfo(SecurityElement elem) { name = elem.Attribute("ID"); role = elem.Attribute("Role"); String value = elem.Attribute("Authenticated"); isAuthenticated = (value != null && Boolean.Parse(value)); }
// Convert an XML element into a permission object. public override void FromXml(SecurityElement securityElement) { String value; if(securityElement == null) { throw new ArgumentNullException("securityElement"); } if(securityElement.Attribute("version") != "1") { throw new ArgumentException (S._("Arg_PermissionVersion")); } value = securityElement.Attribute("Unrestricted"); if(value != null && Boolean.Parse(value)) { level = AspNetHostingPermissionLevel.Unrestricted; } else { value = securityElement.Attribute("Level"); if(value != null) { level = (AspNetHostingPermissionLevel) Enum.Parse(typeof(AspNetHostingPermissionLevel), value); } else { level = AspNetHostingPermissionLevel.None; } } }
public override void FromXml(SecurityElement esd) { CodeAccessPermission.ValidateElement(esd, this); String et; if (XMLUtil.IsUnrestricted(esd)) { m_unrestricted = true; return; } m_unrestricted = false; m_read = null; m_write = null; et = esd.Attribute("Read"); if (et != null) { m_read = new EnvironmentStringExpressionSet(et); } et = esd.Attribute("Write"); if (et != null) { m_write = new EnvironmentStringExpressionSet(et); } }
public void FromXml(System.Security.SecurityElement e) { // FIXME: falta ter em conta mClassName if (e.Attribute(ClassAttr) != this.GetType().AssemblyQualifiedName) { throw new ArgumentException("SecurityElement class is incorrect."); } if (e.Attribute(VersionAttr) != Version) { throw new ArgumentException("SecurityElement version is incorrect."); } ArrayList fo = new ArrayList(); foreach (SecurityElement c in e.Children) { if (c.Tag != InternalTag) { throw new ArgumentException("SecurityElement child is incorrect."); } if (c.Attribute(ClassAttr) != typeof(string).AssemblyQualifiedName) { throw new ArgumentException("SecurityElement child class is incorrect."); } if (c.Attribute(VersionAttr) != Version) { throw new ArgumentException("SecurityElement child version is incorrect."); } fo.Add(c.Attribute(ValueAttr)); } this.mOperations = new string[fo.Count]; fo.CopyTo(this.mOperations); }
public void FromXml(SecurityElement element) { if (element == null) { throw new ArgumentNullException("element"); } if (string.Compare(element.Tag, "ApplicationTrust", StringComparison.Ordinal) != 0) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidXML")); } this.m_appTrustedToRun = false; string strA = element.Attribute("TrustedToRun"); if ((strA != null) && (string.Compare(strA, "true", StringComparison.Ordinal) == 0)) { this.m_appTrustedToRun = true; } this.m_persist = false; string str2 = element.Attribute("Persist"); if ((str2 != null) && (string.Compare(str2, "true", StringComparison.Ordinal) == 0)) { this.m_persist = true; } this.m_appId = null; string applicationIdentityFullName = element.Attribute("FullName"); if ((applicationIdentityFullName != null) && (applicationIdentityFullName.Length > 0)) { this.m_appId = new System.ApplicationIdentity(applicationIdentityFullName); } this.m_psDefaultGrant = null; this.m_grantSetSpecialFlags = 0; SecurityElement element2 = element.SearchForChildByTag("DefaultGrant"); if (element2 != null) { SecurityElement et = element2.SearchForChildByTag("PolicyStatement"); if (et != null) { PolicyStatement statement = new PolicyStatement(null); statement.FromXml(et); this.m_psDefaultGrant = statement; this.m_grantSetSpecialFlags = SecurityManager.GetSpecialFlags(statement.PermissionSet, null); } } List<StrongName> list = new List<StrongName>(); SecurityElement element4 = element.SearchForChildByTag("FullTrustAssemblies"); if ((element4 != null) && (element4.InternalChildren != null)) { IEnumerator enumerator = element4.Children.GetEnumerator(); while (enumerator.MoveNext()) { StrongName item = new StrongName(); item.FromXml(enumerator.Current as SecurityElement); list.Add(item); } } this.m_fullTrustAssemblies = list.AsReadOnly(); this.m_elExtraInfo = element.SearchForChildByTag("ExtraInfo"); }
// Convert an XML value into a permissions value. public override void FromXml(SecurityElement esd) { String value; if(esd == null) { throw new ArgumentNullException("esd"); } if(esd.Attribute("version") != "1") { throw new ArgumentException(_("Arg_PermissionVersion")); } value = esd.Attribute("Unrestricted"); if(value != null && Boolean.Parse(value)) { state = PermissionState.Unrestricted; } else { state = PermissionState.None; } if(state != PermissionState.Unrestricted) { value = esd.Attribute("Allowed"); if(value != null) { usageAllowed = (IsolatedStorageContainment) Enum.Parse(typeof(IsolatedStorageContainment), value); } else { usageAllowed = IsolatedStorageContainment.None; } } else { usageAllowed = IsolatedStorageContainment.UnrestrictedIsolatedStorage; } if(usageAllowed != IsolatedStorageContainment.UnrestrictedIsolatedStorage) { value = esd.Attribute("UserQuota"); if(value != null) { userQuota = Int64.Parse(value); } else { userQuota = 0; } } else { userQuota = Int64.MaxValue; } }
// Convert an XML value into a permissions value. public override void FromXml(SecurityElement esd) { if(esd == null) { throw new ArgumentNullException("esd"); } if(esd.Attribute("version") != "1") { throw new ArgumentException(_("Arg_PermissionVersion")); } url = esd.Attribute("Url"); }
public override void FromXml(SecurityElement securityElement) { if (securityElement == null) { throw new ArgumentNullException("securityElement"); } if (!securityElement.Tag.Equals("IPermission")) { throw new ArgumentException(SR.GetString("net_not_ipermission"), "securityElement"); } string str = securityElement.Attribute("class"); if (str == null) { throw new ArgumentException(SR.GetString("net_no_classname"), "securityElement"); } if (str.IndexOf(base.GetType().FullName) < 0) { throw new ArgumentException(SR.GetString("net_no_typename"), "securityElement"); } string strA = securityElement.Attribute("Unrestricted"); if ((strA != null) && (string.Compare(strA, "true", StringComparison.OrdinalIgnoreCase) == 0)) { this.access = SmtpAccess.ConnectToUnrestrictedPort; this.unrestricted = true; } else { strA = securityElement.Attribute("Access"); if (strA != null) { if (string.Compare(strA, "Connect", StringComparison.OrdinalIgnoreCase) == 0) { this.access = SmtpAccess.Connect; } else if (string.Compare(strA, "ConnectToUnrestrictedPort", StringComparison.OrdinalIgnoreCase) == 0) { this.access = SmtpAccess.ConnectToUnrestrictedPort; } else { if (string.Compare(strA, "None", StringComparison.OrdinalIgnoreCase) != 0) { throw new ArgumentException(SR.GetString("net_perm_invalid_val_in_element"), "Access"); } this.access = SmtpAccess.None; } } } }
public override void FromXml (SecurityElement securityElement) { PermissionHelper.CheckSecurityElement (securityElement, "securityElement", version, version); if (securityElement.Tag != "IPermission") { string msg = Locale.GetText ("Invalid tag '{0}' for permission."); throw new ArgumentException (String.Format (msg, securityElement.Tag), "securityElement"); } if (securityElement.Attribute ("version") == null) { string msg = Locale.GetText ("Missing version attribute."); throw new ArgumentException (msg, "securityElement"); } if (PermissionHelper.IsUnrestricted (securityElement)) { // in case it's get fixed later... _level = AspNetHostingPermissionLevel.Unrestricted; } else { string level = securityElement.Attribute ("Level"); if (level != null) { _level = (AspNetHostingPermissionLevel) Enum.Parse ( typeof (AspNetHostingPermissionLevel), level); } else _level = AspNetHostingPermissionLevel.None; } }
internal static int CheckSecurityElement (SecurityElement se, string parameterName, int minimumVersion, int maximumVersion) { if (se == null) throw new ArgumentNullException (parameterName); if (se.Tag != "IPermission") { string msg = Locale.GetText ("Invalid tag '{0}' expected 'IPermission'."); throw new ArgumentException (String.Format (msg, se.Tag), parameterName); } // we assume minimum version if no version number is supplied int version = minimumVersion; string v = se.Attribute ("version"); if (v != null) { try { version = Int32.Parse (v); } catch (Exception e) { string msg = Locale.GetText ("Couldn't parse version from '{0}'."); msg = String.Format (msg, v); throw new ArgumentException (msg, parameterName, e); } } if ((version < minimumVersion) || (version > maximumVersion)) { string msg = Locale.GetText ("Unknown version '{0}', expected versions between ['{1}','{2}']."); msg = String.Format (msg, version, minimumVersion, maximumVersion); throw new ArgumentException (msg, parameterName); } return version; }
public override void FromXml(SecurityElement esd) { CodeAccessPermission.ValidateElement(esd, this); this.m_allowed = IsolatedStorageContainment.None; if (XMLUtil.IsUnrestricted(esd)) { this.m_allowed = IsolatedStorageContainment.UnrestrictedIsolatedStorage; } else { string str = esd.Attribute("Allowed"); if (str != null) { this.m_allowed = (IsolatedStorageContainment) Enum.Parse(typeof(IsolatedStorageContainment), str); } } if (this.m_allowed == IsolatedStorageContainment.UnrestrictedIsolatedStorage) { this.m_userQuota = 0x7fffffffffffffffL; this.m_machineQuota = 0x7fffffffffffffffL; this.m_expirationDays = 0x7fffffffffffffffL; this.m_permanentData = true; } else { string s = esd.Attribute("UserQuota"); this.m_userQuota = (s != null) ? long.Parse(s, CultureInfo.InvariantCulture) : 0L; s = esd.Attribute("MachineQuota"); this.m_machineQuota = (s != null) ? long.Parse(s, CultureInfo.InvariantCulture) : 0L; s = esd.Attribute("Expiry"); this.m_expirationDays = (s != null) ? long.Parse(s, CultureInfo.InvariantCulture) : 0L; s = esd.Attribute("Permanent"); this.m_permanentData = (s != null) ? bool.Parse(s) : false; } }
public override void FromXml(SecurityElement passedElement) { string element = passedElement.Attribute("Unrestricted"); if (null != element) { this.unrestricted = Convert.ToBoolean(element); } }
public void FromXml(SecurityElement elRoot) { PermissionToken token; elRoot.Tag.Equals("PermissionToken"); string typeStr = elRoot.Attribute("Name"); if (typeStr != null) { token = GetToken(typeStr, true); } else { token = FindTokenByIndex(int.Parse(elRoot.Attribute("Index"), CultureInfo.InvariantCulture)); } this.m_index = token.m_index; this.m_type = (PermissionTokenType) Enum.Parse(typeof(PermissionTokenType), elRoot.Attribute("Type")); this.m_strTypeName = token.m_strTypeName; }
public override void FromXml(SecurityElement e) { this.m_unrestricted = false; this.m_strongNames = null; CodeAccessPermission.ValidateElement(e, this); string strA = e.Attribute("Unrestricted"); if ((strA != null) && (string.Compare(strA, "true", StringComparison.OrdinalIgnoreCase) == 0)) { this.m_unrestricted = true; } else { StrongName2 name; string publicKey = e.Attribute("PublicKeyBlob"); string str3 = e.Attribute("Name"); string version = e.Attribute("AssemblyVersion"); List<StrongName2> list = new List<StrongName2>(); if (((publicKey != null) || (str3 != null)) || (version != null)) { name = new StrongName2((publicKey == null) ? null : new StrongNamePublicKeyBlob(publicKey), str3, (version == null) ? null : new System.Version(version)); list.Add(name); } ArrayList children = e.Children; if (children != null) { foreach (SecurityElement element in children) { publicKey = element.Attribute("PublicKeyBlob"); str3 = element.Attribute("Name"); version = element.Attribute("AssemblyVersion"); if (((publicKey != null) || (str3 != null)) || (version != null)) { name = new StrongName2((publicKey == null) ? null : new StrongNamePublicKeyBlob(publicKey), str3, (version == null) ? null : new System.Version(version)); list.Add(name); } } } if (list.Count != 0) { this.m_strongNames = list.ToArray(); } } }
public override void FromXml(SecurityElement securityElement) { if (securityElement == null) { throw new ArgumentNullException(System.Configuration.SR.GetString("ConfigurationPermissionBadXml", new object[] { "securityElement" })); } if (!securityElement.Tag.Equals("IPermission")) { throw new ArgumentException(System.Configuration.SR.GetString("ConfigurationPermissionBadXml", new object[] { "securityElement" })); } string str = securityElement.Attribute("class"); if (str == null) { throw new ArgumentException(System.Configuration.SR.GetString("ConfigurationPermissionBadXml", new object[] { "securityElement" })); } if (str.IndexOf(base.GetType().FullName, StringComparison.Ordinal) < 0) { throw new ArgumentException(System.Configuration.SR.GetString("ConfigurationPermissionBadXml", new object[] { "securityElement" })); } if (securityElement.Attribute("version") != "1") { throw new ArgumentException(System.Configuration.SR.GetString("ConfigurationPermissionBadXml", new object[] { "version" })); } string str3 = securityElement.Attribute("Unrestricted"); if (str3 == null) { this._permissionState = PermissionState.None; } else { switch (str3) { case "true": this._permissionState = PermissionState.Unrestricted; return; case "false": this._permissionState = PermissionState.None; return; } throw new ArgumentException(System.Configuration.SR.GetString("ConfigurationPermissionBadXml", new object[] { "Unrestricted" })); } }
public override void FromXml(SecurityElement securityElement) { this.access = NetworkInformationAccess.None; if (securityElement == null) { throw new ArgumentNullException("securityElement"); } if (!securityElement.Tag.Equals("IPermission")) { throw new ArgumentException(SR.GetString("net_not_ipermission"), "securityElement"); } string str = securityElement.Attribute("class"); if (str == null) { throw new ArgumentException(SR.GetString("net_no_classname"), "securityElement"); } if (str.IndexOf(base.GetType().FullName) < 0) { throw new ArgumentException(SR.GetString("net_no_typename"), "securityElement"); } string strA = securityElement.Attribute("Unrestricted"); if ((strA != null) && (string.Compare(strA, "true", StringComparison.OrdinalIgnoreCase) == 0)) { this.access = NetworkInformationAccess.Ping | NetworkInformationAccess.Read; this.unrestricted = true; } else if (securityElement.Children != null) { foreach (SecurityElement element in securityElement.Children) { strA = element.Attribute("Access"); if (string.Compare(strA, "Read", StringComparison.OrdinalIgnoreCase) == 0) { this.access |= NetworkInformationAccess.Read; } else if (string.Compare(strA, "Ping", StringComparison.OrdinalIgnoreCase) == 0) { this.access |= NetworkInformationAccess.Ping; } } } }
static public IPermission Create (SecurityElement se) { if (se == null) throw new ArgumentNullException ("se"); string className = se.Attribute ("class"); if ((className == null) || (className.Length == 0)) throw new ArgumentException ("class"); return CreatePermission (className, se); }
static public int getXmlAttrStr(SecurityElement attr, string name, ref string ret) { if (attr != null && attr.Attributes.ContainsKey(name)) { ret = attr.Attribute(name); return XML_OK; } ret = ""; return XML_FAIL; }
static public int getXmlAttrFloat(SecurityElement attr, string name, ref float ret) { if (attr != null && attr.Attributes.ContainsKey(name)) { float.TryParse(attr.Attribute(name), out ret); return XML_OK; } ret = 0; return XML_FAIL; }
internal static XamlAccessLevel FromXml(SecurityElement elem) { if (elem.Tag != "XamlAccessLevel") { throw new ArgumentException(System.Xaml.SR.Get("SecurityXmlUnexpectedTag", new object[] { elem.Tag, "XamlAccessLevel" }), "elem"); } string assemblyName = elem.Attribute("AssemblyName"); if (assemblyName == null) { throw new ArgumentException(System.Xaml.SR.Get("SecurityXmlMissingAttribute", new object[] { "AssemblyName" }), "elem"); } AssemblyName name = new AssemblyName(assemblyName); ValidateAssemblyName(name, "elem"); string typeName = elem.Attribute("TypeName"); if (typeName != null) { typeName = typeName.Trim(); } return new XamlAccessLevel(name.FullName, typeName); }
public override void FromXml(SecurityElement esd) { String value; if(esd == null) { throw new ArgumentNullException("esd"); } if(esd.Attribute("version") != "1") { throw new ArgumentException(S._("Arg_PermissionVersion")); } value = esd.Attribute("Unrestricted"); if(value != null && Boolean.Parse(value)) { restrictedState = false; } else { restrictedState = true; } }
// Convert an XML value into a permissions value. public override void FromXml(SecurityElement esd) { if(esd == null) { throw new ArgumentNullException("esd"); } if(esd.Attribute("version") != "1") { throw new ArgumentException(_("Arg_PermissionVersion")); } String value = esd.Attribute("X509v3Certificate"); if(value != null) { certificate = new X509Certificate (StrongNamePublicKeyBlob.FromHex(value)); } else { certificate = null; } }
// Convert an XML value into a permissions value. public override void FromXml(SecurityElement esd) { String value; if(esd == null) { throw new ArgumentNullException("esd"); } if(esd.Attribute("version") != "1") { throw new ArgumentException(_("Arg_PermissionVersion")); } value = esd.Attribute("Site"); if(value == null) { sites = null; } else { sites = SplitSite(value); } }
public override void FromXml(SecurityElement esd) { CodeAccessPermission.ValidateElement(esd, this); if (XMLUtil.IsUnrestricted(esd)) { SetUnrestricted(true); return; } access = FileDialogPermissionAccess.None; string accessXml = esd.Attribute("Access"); if (accessXml != null) access = (FileDialogPermissionAccess)Enum.Parse(typeof(FileDialogPermissionAccess), accessXml); }
public override void FromXml(SecurityElement securityElement) { if (securityElement == null) { throw new ArgumentNullException("securityElement"); } if (!securityElement.Tag.Equals("IPermission")) { throw new ArgumentException(SR.GetString("net_no_classname"), "securityElement"); } string str = securityElement.Attribute("class"); if (str == null) { throw new ArgumentException(SR.GetString("net_no_classname"), "securityElement"); } if (str.IndexOf(base.GetType().FullName) < 0) { throw new ArgumentException(SR.GetString("net_no_typename"), "securityElement"); } string strA = securityElement.Attribute("Unrestricted"); this.m_noRestriction = (strA != null) ? (0 == string.Compare(strA, "true", StringComparison.OrdinalIgnoreCase)) : false; }
// Token: 0x06001CB8 RID: 7352 RVA: 0x000623C8 File Offset: 0x000605C8 internal void FromXmlNameOnly(SecurityElement et) { string text = et.Attribute("Name"); this.m_name = ((text == null) ? null : text); }
// Convert an XML security element into a permission set. public virtual void FromXml(SecurityElement et) { // Validate the parameter. if (et == null) { throw new ArgumentNullException("et"); } if (et.Tag != "PermissionSet") { throw new ArgumentException(_("Invalid_PermissionXml")); } if (et.Attribute("version") != "1") { throw new ArgumentException(_("Arg_PermissionVersion")); } // Initialize the permission set from the tag. if (et.Attribute("Unrestricted") == "true") { state = PermissionState.Unrestricted; } else { state = PermissionState.None; } permissions.Clear(); #if CONFIG_REFLECTION // Process the children. ArrayList children = et.Children; String className; Type type; Object[] args; IPermission perm; args = new Object [1]; args[0] = PermissionState.None; if (children != null) { foreach (SecurityElement child in children) { if (child.Tag != "IPermission" && child.Tag != "Permission") { // Skip tags that we don't understand. continue; } className = child.Attribute("class"); if (className == null) { throw new ArgumentException (_("Invalid_PermissionXml")); } type = Type.GetType(className); if (type == null && className.IndexOf('.') == -1) { // May not have been fully-qualified. type = Type.GetType ("System.Security.Permissions." + className); } if (!typeof(IPermission).IsAssignableFrom(type)) { throw new ArgumentException (_("Invalid_PermissionXml")); } perm = (Activator.CreateInstance(type, args) as IPermission); if (perm != null) { perm.FromXml(child); AddPermission(perm); } } } #endif // CONFIG_REFLECTION }
// Compare two security elements for equality. public bool Equal(SecurityElement other) { int posn; AttrNameValue nv; // Check the easy cases first. if (other == null) { return(false); } else if (tag != other.tag || text != other.text) { return(false); } // Compare the attribute values. if (attributes == null && other.attributes != null) { return(false); } else if (attributes != null && other.attributes == null) { return(false); } else if (attributes != null) { if (attributes.Count != other.attributes.Count) { return(false); } for (posn = 0; posn < attributes.Count; ++posn) { nv = (AttrNameValue)(attributes[posn]); if (other.Attribute(nv.name) != nv.value) { return(false); } } } // Compare the children. if (children == null && other.children != null) { return(false); } else if (children != null && other.children == null) { return(false); } else if (children != null) { if (children.Count != other.children.Count) { return(false); } for (posn = 0; posn < children.Count; ++posn) { if (!((SecurityElement)(children[posn])).Equal ((SecurityElement)(other.children[posn]))) { return(false); } } } // The elements are identical. return(true); }
internal void FromXmlNameOnly(SecurityElement et) { string str = et.Attribute("Name"); this.m_name = str == null ? (string)null : str; }
internal static bool IsUnrestricted(SecurityElement se) { string text = se.Attribute("Unrestricted"); return(text != null && string.Compare(text, bool.TrueString, true, CultureInfo.InvariantCulture) == 0); }