private bool ParseMembershipCondition(bool safeLoad) { lock (this) { IMembershipCondition condition = null; SecurityElement el = this.m_element.SearchForChildByTag("IMembershipCondition"); if (el == null) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidXMLElement"), new object[] { "IMembershipCondition", base.GetType().FullName })); } try { condition = XMLUtil.CreateMembershipCondition(el); if (condition == null) { return(false); } } catch (Exception exception) { throw new ArgumentException(Environment.GetResourceString("Argument_MembershipConditionElement"), exception); } condition.FromXml(el, this.m_parentLevel); this.m_membershipCondition = condition; return(true); } }
private bool ParseMembershipCondition(bool safeLoad) { lock (this) { IMembershipCondition membershipCondition = null; SecurityElement elMembershipCondition = m_element.SearchForChildByTag("IMembershipCondition"); if (elMembershipCondition != null) { try { membershipCondition = System.Security.Util.XMLUtil.CreateMembershipCondition(elMembershipCondition, safeLoad); if (membershipCondition == null) { return(false); } } catch (Exception ex) { throw new ArgumentException(Environment.GetResourceString("Argument_MembershipConditionElement"), ex); } membershipCondition.FromXml(elMembershipCondition, m_parentLevel); } else { throw new ArgumentException(String.Format(Environment.GetResourceString("Argument_InvalidXMLElement"), "IMembershipCondition", this.GetType().FullName)); } m_membershipCondition = membershipCondition; return(true); } }
private bool ParseMembershipCondition(bool safeLoad) { bool result; lock (this) { IMembershipCondition membershipCondition = null; SecurityElement securityElement = this.m_element.SearchForChildByTag("IMembershipCondition"); if (securityElement == null) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidXMLElement"), "IMembershipCondition", base.GetType().FullName)); } try { membershipCondition = XMLUtil.CreateMembershipCondition(securityElement); if (membershipCondition == null) { return(false); } } catch (Exception innerException) { throw new ArgumentException(Environment.GetResourceString("Argument_MembershipConditionElement"), innerException); } membershipCondition.FromXml(securityElement, this.m_parentLevel); this.m_membershipCondition = membershipCondition; result = true; } return(result); }
public void FromXml(SecurityElement e, PolicyLevel level) { if (null == e) { throw new ArgumentNullException("e"); } PermissionSet ps = null; string psetname = e.Attribute("PermissionSetName"); if ((psetname != null) && (level != null)) { ps = level.GetNamedPermissionSet(psetname); } else { SecurityElement pset = e.SearchForChildByTag("PermissionSet"); if (pset != null) { Type classType = Type.GetType(pset.Attribute("class")); ps = (PermissionSet)Activator.CreateInstance(classType, true); ps.FromXml(pset); } else { ps = new PermissionSet(new PermissionSet(PermissionState.None)); } } m_policy = new PolicyStatement(ps); m_children.Clear(); if ((e.Children != null) && (e.Children.Count > 0)) { foreach (SecurityElement se in e.Children) { if (se.Tag == "CodeGroup") { this.AddChild(CodeGroup.CreateFromXml(se, level)); } } } m_membershipCondition = null; SecurityElement mc = e.SearchForChildByTag("IMembershipCondition"); if (mc != null) { string className = mc.Attribute("class"); Type classType = Type.GetType(className); if (classType == null) { classType = Type.GetType("System.Security.Policy." + className); } m_membershipCondition = (IMembershipCondition)Activator.CreateInstance(classType, true); m_membershipCondition.FromXml(mc, level); } m_name = e.Attribute("Name"); m_description = e.Attribute("Description"); // seems like we might need this to Resolve() in subclasses m_level = level; ParseXml(e, level); }
public void FromXml(SecurityElement et, PolicyLevel level) { SecurityElement child; String className; Type type; ArrayList list; CodeGroup group; if(et == null) { throw new ArgumentNullException("et"); } if(et.Tag != "CodeGroup") { throw new ArgumentException (_("Security_CodeGroupName")); } if(et.Attribute("version") != "1") { throw new ArgumentException (_("Security_PolicyVersion")); } name = et.Attribute("Name"); description = et.Attribute("Description"); // Load the membership condition information for the group. child = et.SearchForChildByTag("IMembershipCondition"); if(child != null) { 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.Policy." + className); } if(!typeof(IMembershipCondition).IsAssignableFrom(type)) { throw new ArgumentException (_("Invalid_PermissionXml")); } membershipCondition = (Activator.CreateInstance(type) as IMembershipCondition); if(membershipCondition != null) { membershipCondition.FromXml(child, level); } } else { throw new ArgumentException (_("Arg_InvalidMembershipCondition")); } // Load the children within this code group. list = new ArrayList(); foreach(SecurityElement elem in et.Children) { if(elem.Tag != "CodeGroup") { 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.Policy." + className); } if(!typeof(CodeGroup).IsAssignableFrom(type)) { throw new ArgumentException (_("Invalid_PermissionXml")); } group = (Activator.CreateInstance(type) as CodeGroup); if(group != null) { group.FromXml(elem, level); list.Add(group); } } children = list; // Parse subclass-specific data from the element. ParseXml(et, level); }
public void FromXml (SecurityElement e, PolicyLevel level) { if (null == e) throw new ArgumentNullException("e"); PermissionSet ps = null; string psetname = e.Attribute ("PermissionSetName"); if ((psetname != null) && (level != null)) { ps = level.GetNamedPermissionSet (psetname); } else { SecurityElement pset = e.SearchForChildByTag ("PermissionSet"); if (pset != null) { Type classType = Type.GetType (pset.Attribute ("class")); ps = (PermissionSet) Activator.CreateInstance (classType, true); ps.FromXml (pset); } else { ps = new PermissionSet (new PermissionSet (PermissionState.None)); } } m_policy = new PolicyStatement (ps); m_children.Clear (); if ((e.Children != null) && (e.Children.Count > 0)) { foreach (SecurityElement se in e.Children) { if (se.Tag == "CodeGroup") { this.AddChild (CodeGroup.CreateFromXml (se, level)); } } } m_membershipCondition = null; SecurityElement mc = e.SearchForChildByTag ("IMembershipCondition"); if (mc != null) { string className = mc.Attribute ("class"); Type classType = Type.GetType (className); if (classType == null) classType = Type.GetType ("System.Security.Policy." + className); m_membershipCondition = (IMembershipCondition) Activator.CreateInstance (classType, true); m_membershipCondition.FromXml (mc, level); } m_name = e.Attribute("Name"); m_description = e.Attribute("Description"); // seems like we might need this to Resolve() in subclasses //m_level = level; ParseXml (e, level); }
public void FromXml(SecurityElement et, PolicyLevel level) { SecurityElement child; String className; Type type; ArrayList list; CodeGroup group; if (et == null) { throw new ArgumentNullException("et"); } if (et.Tag != "CodeGroup") { throw new ArgumentException (_("Security_CodeGroupName")); } if (et.Attribute("version") != "1") { throw new ArgumentException (_("Security_PolicyVersion")); } name = et.Attribute("Name"); description = et.Attribute("Description"); // Load the membership condition information for the group. child = et.SearchForChildByTag("IMembershipCondition"); if (child != null) { 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.Policy." + className); } if (!typeof(IMembershipCondition).IsAssignableFrom(type)) { throw new ArgumentException (_("Invalid_PermissionXml")); } membershipCondition = (Activator.CreateInstance(type) as IMembershipCondition); if (membershipCondition != null) { membershipCondition.FromXml(child, level); } } else { throw new ArgumentException (_("Arg_InvalidMembershipCondition")); } // Load the children within this code group. list = new ArrayList(); foreach (SecurityElement elem in et.Children) { if (elem.Tag != "CodeGroup") { 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.Policy." + className); } if (!typeof(CodeGroup).IsAssignableFrom(type)) { throw new ArgumentException (_("Invalid_PermissionXml")); } group = (Activator.CreateInstance(type) as CodeGroup); if (group != null) { group.FromXml(elem, level); list.Add(group); } } children = list; // Parse subclass-specific data from the element. ParseXml(et, level); }