internal IDRole(SecurityElement e) { string elAuth = e.Attribute("Authenticated"); Authenticated = elAuth == null ? false : string.Equals(elAuth, "true", StringComparison.OrdinalIgnoreCase); ID = e.Attribute("ID"); Role = e.Attribute("Role"); }
internal static int CheckSecurityElement (SecurityElement se, string parameterName, int minimumVersion, int maximumVersion) { if (se == null) throw new ArgumentNullException (parameterName); if (se.Attribute ("class") == null) { string msg = Locale.GetText ("Missing 'class' attribute."); throw new ArgumentException (msg, 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 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 }
// 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"); Clear(); if(value != null && Boolean.Parse(value)) { state = PermissionState.Unrestricted; } else { // TODO: read the children } }
public override void FromXml (SecurityElement esd) { // General validation in CodeAccessPermission CheckSecurityElement (esd, "esd", 1, 1); // Note: we do not (yet) care about the return value // as we only accept version 1 (min/max values) string u = esd.Attribute ("Url"); if (u == null) url = String.Empty; else Url = u; }
// Implement the ISecurityPolicyEncodable interface. public void FromXml(SecurityElement et, PolicyLevel level) { if(et == null) { throw new ArgumentNullException("et"); } if(et.Tag != "IMembershipCondition") { throw new ArgumentException (_("Security_PolicyName")); } if(et.Attribute("version") != "1") { throw new ArgumentException (_("Security_PolicyVersion")); } }
// internal stuff internal static CodeGroup CreateFromXml(SecurityElement se, PolicyLevel level) { string fullClassName = se.Attribute("class"); string className = fullClassName; // many possible formats // a. "FirstMatchCodeGroup" // b. "System.Security.Policy.FirstMatchCodeGroup" // c. "System.Security.Policy.FirstMatchCodeGroup, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\"\r\n version=\"1\">\r\n <IMembershipCondition class=\"System.Security.Policy.AllMembershipCondition, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" int n = className.IndexOf(","); if (n > 0) { className = className.Substring(0, n); } n = className.LastIndexOf("."); if (n > 0) { className = className.Substring(n + 1); } // much faster than calling Activator.CreateInstance switch (className) { case "FileCodeGroup": return(new FileCodeGroup(se, level)); case "FirstMatchCodeGroup": return(new FirstMatchCodeGroup(se, level)); case "NetCodeGroup": return(new NetCodeGroup(se, level)); case "UnionCodeGroup": return(new UnionCodeGroup(se, level)); default: // unknown Type classType = Type.GetType(fullClassName); CodeGroup cg = (CodeGroup)Activator.CreateInstance(classType, true); cg.FromXml(se, level); return(cg); } }
//<Item News_ID="2" Area_ID="1" Title="北京" Content="北京" Publication="1:02" Prob="0"/> // <Item Area_ID="1" Citys="1|2|3|4" Populace="1370536875" Publication="1:0.2,2:0.3,3:0.4" Lv_Consume="3" Map_Index="2" Area_Name="中国" Area_Pic=""/> public static Map_NewsObject Load(SecurityElement element) { Map_NewsObject mapnewsObject = new Map_NewsObject(); mapnewsObject.News_ID = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("News_ID"), ""), -1); mapnewsObject.Area_ID = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Area_ID"), ""), -1); mapnewsObject.Title = StrParser.ParseStr(element.Attribute("Title"), ""); mapnewsObject.Content = StrParser.ParseStr(element.Attribute("Content"), ""); mapnewsObject.Publication = StrParser.ParseStr(element.Attribute("Publication"), ""); mapnewsObject.Prob = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Prob"), ""), -1); return(mapnewsObject); }
private Stage LoadStageFromXml(SecurityElement element) { Stage stage = new Stage { StageId = StrParser.ParseHexInt(element.Attribute("StageId"), 0), StageName = StrParser.ParseStr(element.Attribute("StageName"), ""), StageSequence = StrParser.ParseDecInt(element.Attribute("StageSequence"), 0), IsUseRobot = StrParser.ParseBool(element.Attribute("IsUseRobot"), false), EnemyRecoverHp = StrParser.ParseFloat(element.Attribute("EnemyRecoverHp"), 0f), RobotName = StrParser.ParseStr(element.Attribute("RobotName"), "") }; if (element.Children != null) { foreach (SecurityElement element2 in element.Children) { string tag = element2.Tag; if (tag != null) { if (tag == "PassRewards") { if (element2.Children != null) { foreach (SecurityElement element3 in element2.Children) { Reward item = Reward.LoadFromXml(element3); stage.PassRewards.Add(item); } } } else if (tag == "FirstPassRewards") { goto Label_014F; } } continue; Label_014F: if (element2.Children != null) { foreach (SecurityElement element4 in element2.Children) { Reward reward2 = Reward.LoadFromXml(element4); stage.FirstPassRewards.Add(reward2); } } } } return(stage); }
private void ParseSite() { lock (this) { if (m_element == null) { return; } String elSite = m_element.Attribute("Site"); if (elSite == null) { throw new ArgumentException(Environment.GetResourceString("Argument_SiteCannotBeNull")); } else { m_site = new SiteString(elSite); } m_element = null; } }
public void Union_DifferentPk() { StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob(ecma); StrongNameIdentityPermission snip = new StrongNameIdentityPermission(blob, "mono", new Version(1, 2, 3, 4)); StrongNamePublicKeyBlob blob2 = new StrongNamePublicKeyBlob(new byte [16]); StrongNameIdentityPermission diffPk = new StrongNameIdentityPermission(blob2, "mono", new Version(1, 2, 3, 4)); StrongNameIdentityPermission result = (StrongNameIdentityPermission)snip.Union(diffPk); #if NET_2_0 Assert.IsNotNull(result, "DifferentPk"); // new XML format is used to contain more than one site SecurityElement se = result.ToXml(); Assert.AreEqual(2, se.Children.Count, "Childs"); Assert.AreEqual("00000000000000000400000000000000", (se.Children [0] as SecurityElement).Attribute("PublicKeyBlob"), "Blob#1"); Assert.AreEqual("00000000000000000000000000000000", (se.Children [1] as SecurityElement).Attribute("PublicKeyBlob"), "Blob#2"); // strangely it is still versioned as 'version="1"'. Assert.AreEqual("1", se.Attribute("version"), "Version"); #else Assert.IsNull(result, "DifferentPk"); #endif }
public void FromXml(SecurityElement element, PolicyLevel level) { MembershipConditionHelper.CheckSecurityElement(element, "element", version, version); string u = element.Attribute("Url"); #if NET_2_0 if (u != null) { CheckUrl(u); url = new Url(u); } else { url = null; } #else url = (u == null) ? null : new Url(u); #endif userUrl = u; }
public override void FromXml(SecurityElement securityElement) { if (securityElement == null) { throw new ArgumentNullException("securityElement"); } if (!securityElement.Tag.Equals("IPermission")) { throw new ArgumentException(System.Transactions.SR.GetString("ArgumentWrongType"), "securityElement"); } string str = securityElement.Attribute("Unrestricted"); if (str != null) { this.unrestricted = Convert.ToBoolean(str, CultureInfo.InvariantCulture); } else { this.unrestricted = false; } }
private static bool ParseElementForObjectCreation(SecurityElement el, string requiredNamespace, out string className, out int classNameStart, out int classNameLength) { className = null; classNameStart = 0; classNameLength = 0; int length = requiredNamespace.Length; string text = el.Attribute("class"); if (text == null) { throw new ArgumentException(Environment.GetResourceString("Argument_NoClass")); } if (text.IndexOf('\'') >= 0) { text = text.Replace('\'', '"'); } if (!PermissionToken.IsMscorlibClassName(text)) { return(false); } int num = text.IndexOf(','); int num2; if (num == -1) { num2 = text.Length; } else { num2 = num; } if (num2 > length && text.StartsWith(requiredNamespace, StringComparison.Ordinal)) { className = text; classNameLength = num2 - length; classNameStart = length; return(true); } return(false); }
internal static bool ParseElementForAssemblyIdentification(SecurityElement el, out String className, out String assemblyName, // for example "WindowsBase" out String assemblyVersion) { className = null; assemblyName = null; assemblyVersion = null; String fullClassName = el.Attribute("class"); if (fullClassName == null) { return(false); } if (fullClassName.IndexOf('\'') >= 0) { fullClassName = fullClassName.Replace('\'', '\"'); } int commaIndex = fullClassName.IndexOf(','); int namespaceClassNameLength; // If the classname is tagged with assembly information, find where // the assembly information begins. if (commaIndex == -1) { return(false); } namespaceClassNameLength = commaIndex; className = fullClassName.Substring(0, namespaceClassNameLength); String assemblyFullName = fullClassName.Substring(commaIndex + 1); AssemblyName an = new AssemblyName(assemblyFullName); assemblyName = an.Name; assemblyVersion = an.Version.ToString(); return(true); }
public override void FromXml(SecurityElement securityElement) { if (securityElement == null) { throw new ArgumentNullException("securityElement"); } // LAMESPEC: it says to throw an ArgumentNullException in this case if (securityElement.Tag != "IPermission") { throw new ArgumentException("securityElement"); } string unrestricted = securityElement.Attribute("Unrestricted"); if (unrestricted != null) { this.m_noRestriction = (String.Compare(unrestricted, "true", true) == 0); if (this.m_noRestriction) { return; } } this.m_noRestriction = false; this.m_connectList = new ArrayList(); this.m_acceptList = new ArrayList(); ArrayList children = securityElement.Children; foreach (SecurityElement child in children) { if (child.Tag == "ConnectAccess") { FromXml(child.Children, NetworkAccess.Connect); } else if (child.Tag == "AcceptAccess") { FromXml(child.Children, NetworkAccess.Accept); } } }
// logic isn't identical to PermissionHelper.CheckSecurityElement // - no throw on version mismatch internal int CheckSecurityElement(SecurityElement se, string parameterName, int minimumVersion, int maximumVersion) { if (se == null) { throw new ArgumentNullException(parameterName); } // Tag is case-sensitive if (se.Tag != "IPermission") { string msg = String.Format(Locale.GetText("Invalid tag {0}"), se.Tag); throw new ArgumentException(msg, parameterName); } // Note: we do not care about the class attribute at // this stage (in fact we don't even if the class // attribute is present or not). Anyway the object has // already be created, with success, if we're loading it // 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); }
private bool LoadSceneMusicElement(SecurityElement element, out SceneMusicElement obj) { obj = new SceneMusicElement(); string attribute = element.Attribute("Name"); if (attribute != null) { obj.sceneName = attribute; } if (element.Children != null) { foreach (SecurityElement childrenElement in element.Children) { if (childrenElement.Tag == "Music") { MusicElement obj1 = null; if (!LoadMusicElement(childrenElement, out obj1)) { continue; } obj.usableMusicList.Add(obj1); } else if (childrenElement.Tag == "SoundEffect") { MusicElement obj1 = null; if (!LoadMusicElement(childrenElement, out obj1)) { continue; } obj.usableSoundEffectList.Add(obj1); } } } return(true); }
// If a domain attribute is not found in the specified FileCodeGroup, // add a child XML element identifying a custom membership condition. private static void addXmlMember(ref FileCodeGroup fileCodeGroup) { SecurityElement xmlElement = fileCodeGroup.ToXml(); SecurityElement rootElement = new SecurityElement("CodeGroup"); if (xmlElement.Attribute("domain") == null) { SecurityElement newElement = new SecurityElement("CustomMembershipCondition"); newElement.AddAttribute("class", "CustomMembershipCondition"); newElement.AddAttribute("version", "1"); newElement.AddAttribute("domain", "contoso.com"); rootElement.AddChild(newElement); fileCodeGroup.FromXml(rootElement); } Console.WriteLine("Added a custom membership condition:"); Console.WriteLine(rootElement.ToString()); }
public override void ParseXml(SecurityElement node) { if (node == null) { return; } if (IsType(node.Tag)) { attribute.position = node.Attribute("position").ToVector3Ex(); attribute.rotation = node.Attribute("rotation").ToVector3Ex(); attribute.localPosition = node.Attribute("localPosition").ToVector3Ex(); attribute.localRotation = node.Attribute("localRotation").ToVector3Ex(); attribute.localScale = node.Attribute("localScale").ToVector3Ex(); attribute.bounds = node.Attribute("bounds").ToBoundsEx(); attribute.path = node.Attribute("path"); } SetAttribute(); }
private Goods loadGoodsFromXml(SecurityElement element) { Goods goods = new Goods { goodsId = StrParser.ParseHexInt(element.Attribute("GoodsId"), 0) }; if (element.Children != null) { foreach (SecurityElement element2 in element.Children) { string tag = element2.Tag; if (tag != null) { if (tag != "Cost") { if (tag == "DiscountCost") { goto Label_0083; } if (tag == "Reward") { goto Label_0091; } } else { goods.cost = Cost.LoadFromXml(element2); } } continue; Label_0083: goods.discountCost = Cost.LoadFromXml(element2); continue; Label_0091: goods.reward = Reward.LoadFromXml(element2); } } return(goods); }
private void ParseURL() { lock (this) { if (m_element == null) { return; } String elurl = m_element.Attribute("Url"); if (elurl == null) { throw new ArgumentException(Environment.GetResourceString("Argument_UrlCannotBeNull")); } else { m_url = new URLString(elurl); } m_element = null; } }
public void FromString() { SecurityElement se = SecurityElement.FromString("<tag attribute=\"value\"><x:child attr=\"1\">mono</x:child><child/></tag>"); Assert.AreEqual("tag", se.Tag, "#A1"); Assert.IsNull(se.Text, "#A2"); Assert.AreEqual(1, se.Attributes.Count, "#A3"); Assert.AreEqual("value", se.Attribute("attribute"), "#A4"); Assert.AreEqual(2, se.Children.Count, "#A5"); SecurityElement child = (SecurityElement)se.Children [0]; Assert.AreEqual("x:child", child.Tag, "#B1"); Assert.AreEqual("mono", child.Text, "#B2"); Assert.AreEqual(1, child.Attributes.Count, "#B3"); Assert.AreEqual("1", child.Attribute("attr"), "#B4"); child = (SecurityElement)se.Children [1]; Assert.AreEqual("child", child.Tag, "#C1"); Assert.IsNull(child.Text, "#C2"); Assert.IsNull(child.Attributes, "#C3"); }
// Create and display a summary sentence // about the specified security element. private static void DisplaySummary(SecurityElement xmlElement) { // Retrieve tag name for the security element. string xmlTreeName = xmlElement.Tag.ToString(); // Retrieve tag text for the security element. string xmlTreeDescription = xmlElement.Text; // Retrieve value of the creationdate attribute. string xmlCreationDate = xmlElement.Attribute("creationdate"); // Retrieve the number of children under the security element. string childrenCount = xmlElement.Children.Count.ToString(); string outputMessage = "The security XML tree named " + xmlTreeName; outputMessage += "(" + xmlTreeDescription + ")"; outputMessage += " was created on " + xmlCreationDate + " and "; outputMessage += "contains " + childrenCount + " child elements."; Console.WriteLine(outputMessage); }
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); }
private bool LoadPromotionElement(SecurityElement element, out PromotionElement itemElement) { itemElement = new PromotionElement(); string attribute = element.Attribute("Promotion_ID"); if (attribute != null) { itemElement.Promotion_ID = StrParser.ParseDecInt(attribute, -1); } attribute = element.Attribute("LineDay_Begin"); if (attribute != null) { itemElement.LineDay_Begin = StrParser.ParseDecInt(attribute, -1); } attribute = element.Attribute("LineDay_End"); if (attribute != null) { itemElement.LineDay_End = StrParser.ParseDecInt(attribute, -1); } attribute = element.Attribute("Reward"); if (attribute != null) { itemElement.Reward = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Free_Chest"); if (attribute != null) { itemElement.Free_Chest = StrParser.ParseDecInt(attribute, -1); } attribute = element.Attribute("Original_Price"); if (attribute != null) { itemElement.Original_Price = StrParser.ParseDecInt(attribute, -1); } attribute = element.Attribute("Discount_Price"); if (attribute != null) { itemElement.Discount_Price = StrParser.ParseDecInt(attribute, -1); } return(true); }
public override void LoadFromXml(SecurityElement element) { if (element.Tag == "ArenaConfig") { this._restoreArenaChallengeTime = StrParser.ParseDateTime(element.Attribute("RestoreArenaChallengeTime")); if (element.Children != null) { foreach (SecurityElement element2 in element.Children) { string tag = element2.Tag; if (tag != null) { if (tag != "CombatCost") { if (tag == "ArenaGrade") { goto Label_0094; } if (tag == "Strategy") { goto Label_00A8; } } else { this.combatCosts.Add(Cost.LoadFromXml(element2)); } } continue; Label_0094: this.arenaGrades.Add(this.LoadArenaGradeFromXml(element2)); continue; Label_00A8: this._strategy = this.LoadRandStrategyFromXml(element2); } } } }
/// <summary>Reconstructs a permission with a specified state from an XML encoding.</summary> /// <param name="esd">The XML encoding to use to reconstruct the permission. </param> /// <exception cref="T:System.ArgumentNullException">The <paramref name="esd" /> parameter is <see langword="null" />. </exception> /// <exception cref="T:System.ArgumentException">The <paramref name="esd" /> parameter is not a valid permission element.-or- The <paramref name="esd" /> parameter's version number is not valid. </exception> // Token: 0x060026DB RID: 9947 RVA: 0x0008D1D0 File Offset: 0x0008B3D0 public override void FromXml(SecurityElement esd) { this.m_unrestricted = false; this.m_certs = null; CodeAccessPermission.ValidateElement(esd, this); string text = esd.Attribute("Unrestricted"); if (text != null && string.Compare(text, "true", StringComparison.OrdinalIgnoreCase) == 0) { this.m_unrestricted = true; return; } string text2 = esd.Attribute("X509v3Certificate"); ArrayList arrayList = new ArrayList(); if (text2 != null) { arrayList.Add(new X509Certificate(Hex.DecodeHexString(text2))); } ArrayList children = esd.Children; if (children != null) { foreach (object obj in children) { SecurityElement securityElement = (SecurityElement)obj; text2 = securityElement.Attribute("X509v3Certificate"); if (text2 != null) { arrayList.Add(new X509Certificate(Hex.DecodeHexString(text2))); } } } if (arrayList.Count != 0) { this.m_certs = (X509Certificate[])arrayList.ToArray(typeof(X509Certificate)); } }
private static bool ParseElementForObjectCreation(SecurityElement el, string requiredNamespace, out string className, out int classNameStart, out int classNameLength) { className = null; classNameStart = 0; classNameLength = 0; int length = requiredNamespace.Length; string str = el.Attribute("class"); if (str == null) { throw new ArgumentException(Environment.GetResourceString("Argument_NoClass")); } if (str.IndexOf('\'') >= 0) { str = str.Replace('\'', '"'); } if (PermissionToken.IsMscorlibClassName(str)) { int num3; int index = str.IndexOf(','); if (index == -1) { num3 = str.Length; } else { num3 = index; } if ((num3 > length) && str.StartsWith(requiredNamespace, StringComparison.Ordinal)) { className = str; classNameLength = num3 - length; classNameStart = length; return(true); } } return(false); }
/// <summary>Reconstructs a <see cref="T:System.Net.WebPermission" /> from an XML encoding.</summary> /// <param name="securityElement">The XML encoding from which to reconstruct the <see cref="T:System.Net.WebPermission" />. </param> /// <exception cref="T:System.ArgumentNullException">The <paramref name="securityElement" /> parameter is null.</exception> /// <exception cref="T:System.ArgumentException"> /// <paramref name="securityElement" /> is not a permission element for this type. </exception> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" /> /// </PermissionSet> public override void FromXml(SecurityElement securityElement) { if (securityElement == null) { throw new ArgumentNullException("securityElement"); } if (securityElement.Tag != "IPermission") { throw new ArgumentException("securityElement"); } string text = securityElement.Attribute("Unrestricted"); if (text != null) { this.m_noRestriction = (string.Compare(text, "true", true) == 0); if (this.m_noRestriction) { return; } } this.m_noRestriction = false; this.m_connectList = new ArrayList(); this.m_acceptList = new ArrayList(); ArrayList children = securityElement.Children; foreach (object obj in children) { SecurityElement securityElement2 = (SecurityElement)obj; if (securityElement2.Tag == "ConnectAccess") { this.FromXml(securityElement2.Children, NetworkAccess.Connect); } else if (securityElement2.Tag == "AcceptAccess") { this.FromXml(securityElement2.Children, NetworkAccess.Accept); } } }
// Token: 0x06002994 RID: 10644 RVA: 0x00099800 File Offset: 0x00097A00 protected override void ParseXml(SecurityElement e, PolicyLevel level) { this.ResetConnectAccess(); SecurityElement securityElement = e.SearchForChildByTag("connectAccessRules"); if (securityElement == null || securityElement.Children == null) { this.SetDefaults(); return; } foreach (object obj in securityElement.Children) { SecurityElement securityElement2 = (SecurityElement)obj; if (securityElement2.Tag.Equals("codeOrigin")) { string originScheme = securityElement2.Attribute("scheme"); bool flag = false; if (securityElement2.Children != null) { foreach (object obj2 in securityElement2.Children) { SecurityElement securityElement3 = (SecurityElement)obj2; if (securityElement3.Tag.Equals("connectAccess")) { string allowScheme = securityElement3.Attribute("scheme"); string allowPort = securityElement3.Attribute("port"); this.AddConnectAccess(originScheme, new CodeConnectAccess(allowScheme, allowPort)); flag = true; } } } if (!flag) { this.AddConnectAccess(originScheme, null); } } } }
public override void LoadFromXml(SecurityElement element) { if (element.Tag == "LevelConfig") { this.playerMaxLevel = StrParser.ParseDecInt(element.Attribute("PlayerMaxLevel"), 0); if (element.Children != null) { foreach (SecurityElement element2 in element.Children) { string tag = element2.Tag; if (tag != null) { if (tag != "Level") { if (tag == "PlayerLevelSet") { goto Label_0096; } if (tag == "GiveMeFiveConfig") { goto Label_009F; } } else { this.levels.Add(this.LoadLevelFromXml(element2)); } } continue; Label_0096: this.LoadPlayerLevelSetFromXml(element2); continue; Label_009F: this.giveMeFiveConfig = this.LoadGiveMeFiveConfigFromXml(element2); } } } }
/// <summary>Reconstructs a permission with a specified state from an XML encoding.</summary> /// <param name="esd">The XML encoding to use to reconstruct the permission. </param> /// <exception cref="T:System.ArgumentNullException">The <paramref name="esd" /> parameter is <see langword="null" />. </exception> /// <exception cref="T:System.ArgumentException">The <paramref name="esd" /> parameter is not a valid permission element.-or- The <paramref name="esd" /> parameter's version number is not valid. </exception> // Token: 0x06002673 RID: 9843 RVA: 0x0008B5C4 File Offset: 0x000897C4 public override void FromXml(SecurityElement esd) { this.m_unrestricted = false; this.m_urls = null; CodeAccessPermission.ValidateElement(esd, this); string text = esd.Attribute("Unrestricted"); if (text != null && string.Compare(text, "true", StringComparison.OrdinalIgnoreCase) == 0) { this.m_unrestricted = true; return; } string text2 = esd.Attribute("Url"); List <URLString> list = new List <URLString>(); if (text2 != null) { list.Add(new URLString(text2, true)); } ArrayList children = esd.Children; if (children != null) { foreach (object obj in children) { SecurityElement securityElement = (SecurityElement)obj; text2 = securityElement.Attribute("Url"); if (text2 != null) { list.Add(new URLString(text2, true)); } } } if (list.Count != 0) { this.m_urls = list.ToArray(); } }
// If a class attribute is not found in the specified PolicyStatement, // add a child XML element with an added class attribute. private static void addXmlMember(ref PolicyStatement policyStatement) { //<Snippet6> SecurityElement xmlElement = policyStatement.ToXml(); //</Snippet6> if (xmlElement.Attribute("class") == null) { //<Snippet7> SecurityElement newElement = new SecurityElement("PolicyStatement"); newElement.AddAttribute("class", policyStatement.ToString()); newElement.AddAttribute("version", "1.1"); newElement.AddChild(new SecurityElement("PermissionSet")); policyStatement.FromXml(newElement); //</Snippet7> Console.Write("Added the class attribute and modified its "); Console.WriteLine("version number.\n" + newElement.ToString()); } }
/// <summary>从 XML 编码重新构造具有指定状态的权限。</summary> /// <param name="esd">用于重新构造权限的 XML 编码。</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="esd" /> 参数为 null。</exception> /// <exception cref="T:System.ArgumentException"> /// <paramref name="esd" /> 参数不是有效的权限元素。- 或 -<paramref name="esd" /> 参数的版本号无效。</exception> public override void FromXml(SecurityElement esd) { this.m_zones = 0U; CodeAccessPermission.ValidateElement(esd, (IPermission)this); string str = esd.Attribute("Zone"); if (str != null) { this.SecurityZone = (SecurityZone)Enum.Parse(typeof(SecurityZone), str); } if (esd.Children == null) { return; } foreach (SecurityElement child in esd.Children) { int num = (int)Enum.Parse(typeof(SecurityZone), child.Attribute("Zone")); if (num != -1) { this.m_zones = this.m_zones | (uint)(1 << num); } } }
public static GirlSkillObject Load(SecurityElement element) { GirlSkillObject girlskillgobject = new GirlSkillObject(); girlskillgobject.SkillID = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Skill_ID"), ""), -1); girlskillgobject.GroupID = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Group_ID"), ""), -1); girlskillgobject.Skill_Name = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Skill_Name"), ""), -1); girlskillgobject.Skill_Icon = StrParser.ParseStr(element.Attribute("Skill_Icon"), ""); girlskillgobject.Skill_Type = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Skill_Type"), ""), -1); girlskillgobject.Skill_Level = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Skill_Level"), ""), -1); girlskillgobject.Skill_Time = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Skill_Time"), ""), -1); girlskillgobject.Reward_Type = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Reward_Type"), ""), -1); girlskillgobject.Reward_Is_Percent = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Reward_Is_Percent"), ""), -1); girlskillgobject.Reward_Count = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Reward_Count"), ""), -1); girlskillgobject.Reward_Describe = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Reward_Describe"), ""), -1); girlskillgobject.Condition_Type = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Condition_Type"), ""), -1); girlskillgobject.Condition_Item = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Condition_Item"), ""), -1); girlskillgobject.Condition_Count = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Condition_Count"), ""), -1); girlskillgobject.Condition_Describe = StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("Condition_Describe"), ""), -1); // girlcgobject.CG_ID= StrParser.ParseDecInt(StrParser.ParseStr(element.Attribute("CG_ID"),""),-1); // girlcgobject.CGIcon = StrParser.ParseStr(element.Attribute ("Icon"), ""); return(girlskillgobject); }
internal static int CheckSecurityElement (SecurityElement se, string parameterName, int minimumVersion, int maximumVersion) { if (se == null) throw new ArgumentNullException (parameterName); // Tag is case-sensitive if (se.Tag != XmlTag) { string msg = String.Format (Locale.GetText ("Invalid tag {0}, expected {1}."), se.Tag, XmlTag); throw new ArgumentException (msg, parameterName); } // Note: we do not care about the class attribute at // this stage (in fact we don't even if the class // attribute is present or not). Anyway the object has // already be created, with success, if we're loading it // 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; }
private static Object ObjectFromXml (SecurityElement elObject) { BCLDebug.Assert(elObject != null, "You need to pass in a security element"); if (elObject.Attribute("class") != null) { ISecurityEncodable encodableObj = XMLUtil.CreateCodeGroup(elObject) as ISecurityEncodable; if (encodableObj != null) { encodableObj.FromXml(elObject); return encodableObj; } } string objectData = elObject.Attribute("Data"); MemoryStream stream = new MemoryStream(Hex.DecodeHexString(objectData)); BinaryFormatter formatter = new BinaryFormatter(); return formatter.Deserialize(stream); }
public void FromXml (SecurityElement element) { if (element == null) throw new ArgumentNullException ("element"); if (element.Tag != "ApplicationTrust") throw new ArgumentException ("element"); string s = element.Attribute ("FullName"); if (s != null) _appid = new ApplicationIdentity (s); else _appid = null; _defaultPolicy = null; SecurityElement defaultGrant = element.SearchForChildByTag ("DefaultGrant"); if (defaultGrant != null) { for (int i=0; i < defaultGrant.Children.Count; i++) { SecurityElement se = (defaultGrant.Children [i] as SecurityElement); if (se.Tag == "PolicyStatement") { DefaultGrantSet.FromXml (se, null); break; } } } if (!Boolean.TryParse (element.Attribute ("TrustedToRun"), out _trustrun)) _trustrun = false; if (!Boolean.TryParse (element.Attribute ("Persist"), out _persist)) _persist = false; _xtranfo = null; SecurityElement xtra = element.SearchForChildByTag ("ExtraInfo"); if (xtra != null) { s = xtra.Attribute ("Data"); if (s != null) { byte[] data = CryptoConvert.FromHex (s); using (MemoryStream ms = new MemoryStream (data)) { BinaryFormatter bf = new BinaryFormatter (); _xtranfo = bf.Deserialize (ms); } } } }
public void FromXml (SecurityElement e, PolicyLevel level) { MembershipConditionHelper.CheckSecurityElement (e, "e", version, version); _site = e.Attribute ("Site"); // PolicyLevel isn't used as there's no need to resolve NamedPermissionSet references }
public override void FromXml (SecurityElement esd) { // General validation in CodeAccessPermission CheckSecurityElement (esd, "esd", version, version); // Note: we do not (yet) care about the return value // as we only accept version 1 (min/max values) if (IsUnrestricted (esd)) _state = PermissionState.Unrestricted; string read = esd.Attribute ("Read"); if ((read != null) && (read.Length > 0)) SetPathList (EnvironmentPermissionAccess.Read, read); string write = esd.Attribute ("Write"); if ((write != null) && (write.Length > 0)) SetPathList (EnvironmentPermissionAccess.Write, write); }
public override void FromXml (SecurityElement esd) { // General validation in CodeAccessPermission CheckSecurityElement (esd, "esd", version, version); // Note: we do not (yet) care about the return value // as we only accept version 1 (min/max values) if (IsUnrestricted (esd)) { m_Unrestricted = true; } else{ m_Unrestricted = false; string fileList = esd.Attribute ("Read"); string[] files; if (fileList != null){ files = fileList.Split (';'); AddPathList (FileIOPermissionAccess.Read, files); } fileList = esd.Attribute ("Write"); if (fileList != null){ files = fileList.Split (';'); AddPathList (FileIOPermissionAccess.Write, files); } fileList = esd.Attribute ("Append"); if (fileList != null){ files = fileList.Split (';'); AddPathList (FileIOPermissionAccess.Append, files); } fileList = esd.Attribute ("PathDiscovery"); if (fileList != null){ files = fileList.Split (';'); AddPathList (FileIOPermissionAccess.PathDiscovery, files); } } }
// Implement the ISecurityPolicyEncodable interface. public void FromXml(SecurityElement et, PolicyLevel level) { if(et == null) { throw new ArgumentNullException("et"); } if(et.Tag != "IMembershipCondition") { throw new ArgumentException(_("Security_PolicyName")); } if(et.Attribute("version") != "1") { throw new ArgumentException(_("Security_PolicyVersion")); } String value = et.Attribute("Site"); if(value != null) { site = value; } else { throw new ArgumentException(_("Arg_InvalidSite")); } }
protected override void ParseXml (SecurityElement e, PolicyLevel level) { string a = e.Attribute ("Access"); if (a != null) m_access = (FileIOPermissionAccess) Enum.Parse (typeof (FileIOPermissionAccess), a, true); else m_access = FileIOPermissionAccess.NoAccess; }
public override void FromXml (SecurityElement esd) { // General validation in CodeAccessPermission CheckSecurityElement (esd, "esd", version, version); // Note: we do not (yet) care about the return value // as we only accept version 1 (min/max values) if (IsUnrestricted (esd)) { _access = FileDialogPermissionAccess.OpenSave; } else { string a = esd.Attribute ("Access"); if (a == null) _access = FileDialogPermissionAccess.None; else { _access = (FileDialogPermissionAccess) Enum.Parse ( typeof (FileDialogPermissionAccess), a); } } }
public override void FromXml (SecurityElement securityElement) { CodeAccessPermission.ValidateElement(securityElement, this); if (XMLUtil.IsUnrestricted(securityElement)) { m_flags = KeyContainerPermissionFlags.AllFlags; m_accessEntries = new KeyContainerPermissionAccessEntryCollection(m_flags); return; } m_flags = KeyContainerPermissionFlags.NoFlags; string strFlags = securityElement.Attribute("Flags"); if (strFlags != null) { KeyContainerPermissionFlags flags = (KeyContainerPermissionFlags) Enum.Parse(typeof(KeyContainerPermissionFlags), strFlags); VerifyFlags(flags); m_flags = flags; } m_accessEntries = new KeyContainerPermissionAccessEntryCollection(m_flags); if (securityElement.InternalChildren != null && securityElement.InternalChildren.Count != 0) { IEnumerator enumerator = securityElement.Children.GetEnumerator(); while (enumerator.MoveNext()) { SecurityElement current = (SecurityElement) enumerator.Current; if (current != null) { if (String.Equals(current.Tag, "AccessList")) AddAccessEntries(current); } } } }
public override void FromXml (SecurityElement securityElement) { if (securityElement == null) throw new ArgumentNullException("securityElement"); string className = securityElement.Attribute("class"); if (className == null || className.IndexOf(this.GetType().FullName, StringComparison.Ordinal) == -1) throw new ArgumentException(SR.GetString(SR.Argument_InvalidClassAttribute), "securityElement"); string unrestricted = securityElement.Attribute("Unrestricted"); if (unrestricted != null && String.Compare(unrestricted, "true", StringComparison.OrdinalIgnoreCase) == 0) { m_flags = StorePermissionFlags.AllFlags; return; } m_flags = StorePermissionFlags.NoFlags; String strFlags = securityElement.Attribute("Flags"); if (strFlags != null) { StorePermissionFlags flags = (StorePermissionFlags) Enum.Parse(typeof(StorePermissionFlags), strFlags); VerifyFlags(flags); m_flags = flags; } }
public override void FromXml (SecurityElement esd) { // General validation in CodeAccessPermission CheckSecurityElement (esd, "esd", version, version); // Note: we do not (yet) care about the return value // as we only accept version 1 (min/max values) m_userQuota = 0; m_machineQuota = 0; m_expirationDays = 0; m_permanentData = false; m_allowed = IsolatedStorageContainment.None; if (IsUnrestricted (esd)) { UsageAllowed = IsolatedStorageContainment.UnrestrictedIsolatedStorage; } else { string a = esd.Attribute ("Allowed"); if (a != null) { UsageAllowed = (IsolatedStorageContainment) Enum.Parse ( typeof (IsolatedStorageContainment), a); } a = esd.Attribute ("UserQuota"); if (a != null) { m_userQuota = Int64.Parse (a, CultureInfo.InvariantCulture); } } }
internal void FromXml (SecurityElement element) { if (element == null) throw new ArgumentNullException(nameof(element)); if (String.Compare(element.Tag, "StrongName", StringComparison.Ordinal) != 0) throw new ArgumentException(Environment.GetResourceString("Argument_InvalidXML")); Contract.EndContractBlock(); m_publicKeyBlob = null; m_version = null; string key = element.Attribute("Key"); if (key != null) m_publicKeyBlob = new StrongNamePublicKeyBlob(System.Security.Util.Hex.DecodeHexString(key)); m_name = element.Attribute("Name"); string version = element.Attribute("Version"); if (version != null) m_version = new Version(version); }
// must be called after CheckSecurityElement (i.e. se != null) internal static bool IsUnrestricted (SecurityElement se) { string value = se.Attribute ("Unrestricted"); if (value == null) return false; return (String.Compare (value, Boolean.TrueString, true, CultureInfo.InvariantCulture) == 0); }
public override void FromXml (SecurityElement e) { // General validation in CodeAccessPermission PermissionHelper.CheckSecurityElement (e, "e", version, version); // Note: we do not (yet) care about the return value // as we only accept version 1 (min/max values) _flags = (DataProtectionPermissionFlags) Enum.Parse ( typeof (DataProtectionPermissionFlags), e.Attribute ("Flags")); }
public void FromXml (SecurityElement e, PolicyLevel level) { MembershipConditionHelper.CheckSecurityElement (e, "e", version, version); string u = e.Attribute ("Url"); #if NET_2_0 if (u != null) { CheckUrl (u); url = new Url (u); } else { url = null; } #else url = (u == null) ? null : new Url (u); #endif userUrl = u; }
private static IApplicationTrustManager DecodeAppTrustManagerFromElement (SecurityElement elTrustManager) { new ReflectionPermission(ReflectionPermissionFlag.MemberAccess).Assert(); string trustManagerName = elTrustManager.Attribute("class"); Type tmClass = Type.GetType(trustManagerName, false, false); if (tmClass == null) return null; IApplicationTrustManager appTrustManager = Activator.CreateInstance(tmClass) as IApplicationTrustManager; if (appTrustManager != null) appTrustManager.FromXml(elTrustManager); return appTrustManager; }
public override void FromXml (SecurityElement esd) { // General validation in CodeAccessPermission CheckSecurityElement (esd, "esd", version, version); // Note: we do not (yet) care about the return value // as we only accept version 1 (min/max values) if (IsUnrestricted (esd)) { flags = SecurityPermissionFlag.AllFlags; } else { string f = esd.Attribute ("Flags"); if (f == null) { flags = SecurityPermissionFlag.NoFlags; } else { flags = (SecurityPermissionFlag) Enum.Parse ( typeof (SecurityPermissionFlag), f); } } }
public void FromXml(SecurityElement elem) { if (elem == null) throw new ArgumentNullException(nameof(elem)); if (elem.Tag == null || !elem.Tag.Equals("Permission") && !elem.Tag.Equals("IPermission")) throw new ArgumentException(SR.Argument_NotAPermissionElement); string version = elem.Attribute("version"); if (version == null || (version != null && !version.Equals("1"))) throw new ArgumentException(SR.Argument_InvalidXMLBadVersion); if (elem.Children != null && elem.Children.Count != 0) { int numChildren = elem.Children.Count; int count = 0; _idArray = new IDRole[numChildren]; foreach (object curr in elem.Children) { _idArray[count++] = new IDRole((SecurityElement)curr); } } else _idArray = new IDRole[0]; }
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")); #if FEATURE_CLICKONCE m_appTrustedToRun = false; string isAppTrustedToRun = element.Attribute("TrustedToRun"); if (isAppTrustedToRun != null && String.Compare(isAppTrustedToRun, "true", StringComparison.Ordinal) == 0) { m_appTrustedToRun = true; } m_persist = false; string persist = element.Attribute("Persist"); if (persist != null && String.Compare(persist, "true", StringComparison.Ordinal) == 0) { m_persist = true; } m_appId = null; string fullName = element.Attribute("FullName"); if (fullName != null && fullName.Length > 0) { m_appId = new ApplicationIdentity(fullName); } #endif // FEATURE_CLICKONCE m_psDefaultGrant = null; m_grantSetSpecialFlags = 0; SecurityElement elDefaultGrant = element.SearchForChildByTag("DefaultGrant"); if (elDefaultGrant != null) { SecurityElement elDefaultGrantPS = elDefaultGrant.SearchForChildByTag("PolicyStatement"); if (elDefaultGrantPS != null) { PolicyStatement ps = new PolicyStatement(null); ps.FromXml(elDefaultGrantPS); m_psDefaultGrant = ps; m_grantSetSpecialFlags = SecurityManager.GetSpecialFlags(ps.PermissionSet, null); } } List<StrongName> fullTrustAssemblies = new List<StrongName>(); SecurityElement elFullTrustAssemblies = element.SearchForChildByTag("FullTrustAssemblies"); if (elFullTrustAssemblies != null && elFullTrustAssemblies.InternalChildren != null) { IEnumerator enumerator = elFullTrustAssemblies.Children.GetEnumerator(); while (enumerator.MoveNext()) { StrongName fullTrustAssembly = new StrongName(); fullTrustAssembly.FromXml(enumerator.Current as SecurityElement); fullTrustAssemblies.Add(fullTrustAssembly); } } m_fullTrustAssemblies = fullTrustAssemblies.AsReadOnly(); #if FEATURE_CLICKONCE m_elExtraInfo = element.SearchForChildByTag("ExtraInfo"); #endif // FEATURE_CLICKONCE }
private SNIP FromSecurityElement (SecurityElement se) { string name = se.Attribute ("Name"); StrongNamePublicKeyBlob publickey = StrongNamePublicKeyBlob.FromString (se.Attribute ("PublicKeyBlob")); string v = se.Attribute ("AssemblyVersion"); Version assemblyVersion = (v == null) ? null : new Version (v); return new SNIP (publickey, name, assemblyVersion); }
public override void FromXml (SecurityElement e) { // General validation in CodeAccessPermission PermissionHelper.CheckSecurityElement (e, "e", version, version); // Note: we do not (yet) care about the return value // as we only accept version 1 (min/max values) string s = e.Attribute ("Flags"); if (s == null) _flags = StorePermissionFlags.NoFlags; else _flags = (StorePermissionFlags) Enum.Parse (typeof (StorePermissionFlags), s); }
public void FromXml (SecurityElement e, PolicyLevel level) { MembershipConditionHelper.CheckSecurityElement (e, "e", version, version); hash_value = CryptoConvert.FromHex (e.Attribute ("HashValue")); string algorithm = e.Attribute ("HashAlgorithm"); hash_algorithm = (algorithm == null) ? null : HashAlgorithm.Create (algorithm); }
public override void FromXml (SecurityElement esd) { // General validation in CodeAccessPermission CheckSecurityElement (esd, "esd", version, version); // Note: we do not (yet) care about the return value // as we only accept version 1 (min/max values) if (IsUnrestricted (esd)) { _window = UIPermissionWindow.AllWindows; _clipboard = UIPermissionClipboard.AllClipboard; } else { string w = esd.Attribute ("Window"); if (w == null) _window = UIPermissionWindow.NoWindows; else _window = (UIPermissionWindow) Enum.Parse (typeof (UIPermissionWindow), w); string c = esd.Attribute ("Clipboard"); if (c == null) _clipboard = UIPermissionClipboard.NoClipboard; else _clipboard = (UIPermissionClipboard) Enum.Parse (typeof (UIPermissionClipboard), c); } }