// snippet moved from FileIOPermission (nickd) to be reused in all derived classes internal static SecurityElement Element (Type type, int version) { SecurityElement se = new SecurityElement ("IPermission"); se.AddAttribute ("class", type.FullName + ", " + type.Assembly.ToString ().Replace ('\"', '\'')); se.AddAttribute ("version", version.ToString ()); return se; }
public SignatureDescription(SecurityElement el) { if(el == null) { throw new ArgumentNullException("el"); } foreach(SecurityElement e in el.Children) { if(e.Tag == "Deformatter") { deformatter = e.Text; } else if(e.Tag == "Digest") { digest = e.Text; } else if(e.Tag == "Formatter") { formatter = e.Text; } else if(e.Tag == "Key") { key = e.Text; } } }
// Convert this object into a string. public override String ToString() { SecurityElement element = new SecurityElement ("System.Security.Policy.PermissionRequestEvidence"); SecurityElement child; element.AddAttribute("version", "1"); if(request != null) { child = new SecurityElement("Request"); child.AddChild(request.ToXml()); element.AddChild(child); } if(optional != null) { child = new SecurityElement("Optional"); child.AddChild(optional.ToXml()); element.AddChild(child); } if(denied != null) { child = new SecurityElement("Denied"); child.AddChild(denied.ToXml()); element.AddChild(child); } return element.ToString(); }
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 }
public static void ApplicationTrustCallMethods() { ApplicationTrust at = new ApplicationTrust(); SecurityElement se = new SecurityElement(""); at.FromXml(se); se = at.ToXml(); }
public static Boolean Test() { Boolean bRes = true; SecurityElement el = new SecurityElement("whatever"); // el.Text = "<Key>RSA</Key><Digest>SHA1</Digest><Formatter>System.Security.Cryptography.RSAPKCS1SignatureFormatter</Formatter><Deformatter>System.Security.Cryptography.RSAPKCS1SignatureFormatter</Deformatter>"; SecurityElement el_key = new SecurityElement("Key"); el_key.Text = "RSA"; SecurityElement el_digest = new SecurityElement("Digest"); el_digest.Text = "SHA1"; SecurityElement el_form = new SecurityElement("Formatter"); el_form.Text = "System.Security.Cryptography.RSAPKCS1SignatureFormatter"; SecurityElement el_deform = new SecurityElement("Deformatter"); el_deform.Text = "System.Security.Cryptography.RSAPKCS1SignatureDeformatter"; el.AddChild(el_key); el.AddChild(el_digest); el.AddChild(el_form); el.AddChild(el_deform); SignatureDescription sd_empty = new SignatureDescription(); SignatureDescription sd = new SignatureDescription(el); Console.WriteLine(sd.CreateDigest()); Console.WriteLine(sd.CreateFormatter(RSA.Create())); Console.WriteLine(sd.CreateDeformatter(RSA.Create())); return bRes; }
public SecurityElement ToXml( PolicyLevel level ) { SecurityElement root = new SecurityElement( "IMembershipCondition" ); System.Security.Util.XMLUtil.AddClassAttribute( root, this.GetType(), this.GetType().FullName ); root.AddAttribute( "version", "1" ); return root; }
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 override void FromXml (SecurityElement securityElement) { // General validation in CodeAccessPermission CheckSecurityElement (securityElement, "securityElement", version, version); // Note: we do not (yet) care about the return value // as we only accept version 1 (min/max values) }
// Test the constructor. public void TestSecurityElementConstructor() { SecurityElement e; try { e = new SecurityElement(null); Fail("Constructor (1)"); } catch(ArgumentNullException) { // Success. } try { e = new SecurityElement(""); Fail("Constructor (2)"); } catch(ArgumentException) { // Success. } try { e = new SecurityElement("<"); Fail("Constructor (3)"); } catch(ArgumentException) { // Success. } try { e = new SecurityElement("a", "<"); Fail("Constructor (4)"); } catch(ArgumentException) { // Success. } try { e = new SecurityElement("&"); Fail("Constructor (5)"); } catch(ArgumentException) { // Success. } e = new SecurityElement("foo", "bar"); AssertEquals("Constructor (6)", "foo", e.Tag); AssertEquals("Constructor (7)", "bar", e.Text); e = new SecurityElement("foo"); AssertEquals("Constructor (8)", "foo", e.Tag); AssertNull("Constructor (9)", e.Text); e = new SecurityElement("foo", "&"); AssertEquals("Constructor (10)", "foo", e.Tag); AssertEquals("Constructor (11)", "&", e.Text); }
public void FromXml( SecurityElement e, PolicyLevel level ) { if (e == null) throw new ArgumentNullException("e"); if (!e.Tag.Equals( "IMembershipCondition" )) throw new ArgumentException( Environment.GetResourceString( "Argument_MembershipConditionElement" ) ); }
public SignatureDescription(SecurityElement el) { if (el == null) throw new ArgumentNullException("el"); Contract.EndContractBlock(); _strKey = el.SearchForTextOfTag("Key"); _strDigest = el.SearchForTextOfTag("Digest"); _strFormatter = el.SearchForTextOfTag("Formatter"); _strDeformatter = el.SearchForTextOfTag("Deformatter"); }
} //Union() public override SecurityElement ToXml() { SecurityElement s = new SecurityElement("IPermission"); s.AddAttribute("class","myperm, myperm, Version=1.0.1.0, Culture=neutral, PublicKeyToken=0e8dcc8628396732"); s.AddAttribute("version", "1"); s.AddAttribute("Unrestricted", "true"); return s; } //ToXml()
public SignatureDescription(SecurityElement el) { if (el == null) throw new ArgumentNullException(nameof(el)); KeyAlgorithm = el.SearchForTextOfTag("Key"); DigestAlgorithm = el.SearchForTextOfTag("Digest"); FormatterAlgorithm = el.SearchForTextOfTag("Formatter"); DeformatterAlgorithm = el.SearchForTextOfTag("Deformatter"); }
public void Constructor_SecurityElement_Empty() { SecurityElement se = new SecurityElement("xml"); SignatureDescription sig = new SignatureDescription(se); Assert.Null(sig.KeyAlgorithm); Assert.Null(sig.DigestAlgorithm); Assert.Null(sig.FormatterAlgorithm); Assert.Null(sig.DeformatterAlgorithm); }
public void FromXmlWrongVersion() { PrincipalPermission p = new PrincipalPermission(PermissionState.None); SecurityElement se = p.ToXml(); // can't modify - so we create our own SecurityElement se2 = new SecurityElement(se.Tag, se.Text); se2.AddAttribute("class", se.Attribute("class")); se2.AddAttribute("version", "2"); Assert.Throws<ArgumentException>(() => p.FromXml(se2)); }
public static void PermissionRequestEvidenceCallMethods() { PermissionSet ps = new PermissionSet(new PermissionState()); PermissionRequestEvidence pre = new PermissionRequestEvidence(ps, ps, ps); PermissionRequestEvidence obj = pre.Copy(); string str = ps.ToString(); SecurityElement se = new SecurityElement(""); ps.FromXml(se); se = ps.ToXml(); }
private static SecurityElement GetAllConfig() { if (m_allConfig == null) { SecurityElement doc = SecurityElement.FromString(StreamingAssetHelper.ReadFileText(Path.Combine("config", "all_platform_config.xml"))); m_allConfig = doc.SearchForChildByTag(GetPlatForm()); } return m_allConfig; }
public SecurityElement ToXml(PolicyLevel level) { SecurityElement element; element = new SecurityElement("IMembershipCondition"); element.AddAttribute ("class", SecurityElement.Escape(typeof(AllMembershipCondition). AssemblyQualifiedName)); element.AddAttribute("version", "1"); return element; }
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) string s = esd.Attribute ("Site"); if (s != null) Site = s; }
public static void NamedPermissionSetCallMethods() { NamedPermissionSet nps = new NamedPermissionSet("Test"); PermissionSet ps = nps.Copy(); NamedPermissionSet nps2 = nps.Copy("Test"); nps.Equals(nps2); int hash = nps.GetHashCode(); SecurityElement se = new SecurityElement(""); nps.FromXml(se); se = nps.ToXml(); }
public override string ToString () { SecurityElement se = new SecurityElement ("System.Security.Policy.Publisher"); se.AddAttribute ("version", "1"); SecurityElement cert = new SecurityElement ("X509v3Certificate"); string data = m_cert.GetRawCertDataString (); if (data != null) cert.Text = data; se.AddChild (cert); return se.ToString (); }
public static void EnvironmentPermissionCallMethods() { EnvironmentPermission ep = new EnvironmentPermission(new Permissions.EnvironmentPermissionAccess(), "testpath"); ep.AddPathList(new Permissions.EnvironmentPermissionAccess(), "testpath"); string path = ep.GetPathList(new Permissions.EnvironmentPermissionAccess()); bool isunrestricted = ep.IsUnrestricted(); ep.SetPathList(new Permissions.EnvironmentPermissionAccess(), "testpath2"); SecurityElement se = new SecurityElement(""); ep.FromXml(se); se = ep.ToXml(); }
public static void GacIdentityPermissionCallMethods() { GacIdentityPermission gip = new GacIdentityPermission(); IPermission ip = gip.Copy(); IPermission ip2 = gip.Intersect(ip); bool issubset = gip.IsSubsetOf(ip); IPermission ip3 = gip.Union(ip2); SecurityElement se = new SecurityElement(""); gip.FromXml(se); se = gip.ToXml(); }
public static void FileDialogPermissionCallMethods() { FileDialogPermission fdp = new FileDialogPermission(new Permissions.FileDialogPermissionAccess()); IPermission ip = fdp.Copy(); IPermission ip2 = fdp.Intersect(ip); bool issubset = fdp.IsSubsetOf(ip); bool isunrestricted = fdp.IsUnrestricted(); IPermission ip3 = fdp.Union(ip2); SecurityElement se = new SecurityElement(""); fdp.FromXml(se); se = fdp.ToXml(); }
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; }
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) string cert = (esd.Attributes ["X509v3Certificate"] as string); if (cert != null) { byte[] rawcert = CryptoConvert.FromHex (cert); x509 = new X509Certificate (rawcert); } }
public static void PolicyStatementCallMethods() { Policy.PolicyStatement ps = new Policy.PolicyStatement(new PermissionSet(new PermissionState())); Policy.PolicyStatement ps2 = ps.Copy(); bool equals = ps.Equals(ps2); int hash = ps.GetHashCode(); SecurityElement se = new SecurityElement(""); Policy.PolicyLevel pl = (Policy.PolicyLevel)Activator.CreateInstance(typeof(Policy.PolicyLevel), true); ps.FromXml(se); ps.FromXml(se, pl); se = ps.ToXml(); se = ps.ToXml(pl); }
internal SecurityElement ToXml() { SecurityElement root = new SecurityElement( "System.Security.Policy.ApplicationDirectory" ); // If you hit this assert then most likely you are trying to change the name of this class. // This is ok as long as you change the hard coded string above and change the assert below. Contract.Assert( this.GetType().FullName.Equals( "System.Security.Policy.ApplicationDirectory" ), "Class name changed!" ); root.AddAttribute( "version", "1" ); if (m_appDirectory != null) root.AddChild( new SecurityElement( "Directory", m_appDirectory.ToString() ) ); return root; }
private static string _UnescapedAttribute(string escaped) { return(SecurityElement.FromString($"<t a=\"{escaped}\" />").Attribute("a")); }
internal static string Line(string line) { return(ToNBSP(SecurityElement.Escape(line))); }
/// <summary> /// Encodes a Xml string. /// </summary> /// <param name="str">The string to decode.</param> /// <returns>A decoded string.</returns> public static string XmlEncode(string str) { return(SecurityElement.Escape(str)); }
public void OnChars(string ch) { current.Text = SecurityElement.Escape(ch); }
private bool LoadTrainElement(SecurityElement element, out TrainElement itemElement) { itemElement = new TrainElement(); string attribute = element.Attribute("Train_ID"); if (attribute != null) { itemElement.Train_ID = StrParser.ParseDecInt(attribute, -1); } attribute = element.Attribute("Train_Name"); if (attribute != null) { itemElement.Train_Name = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Train_Type"); if (attribute != null) { itemElement.Train_Type = StrParser.ParseDecInt(attribute, -1); } attribute = element.Attribute("Train_Lv"); if (attribute != null) { itemElement.Train_Lv = StrParser.ParseDecInt(attribute, -1); } attribute = element.Attribute("Need_Rate"); if (attribute != null) { itemElement.Need_Rate = StrParser.ParseDecInt(attribute, -1); } attribute = element.Attribute("Need_Money"); if (attribute != null) { itemElement.Need_Money = StrParser.ParseDecInt(attribute, -1); } attribute = element.Attribute("Get_Act"); if (attribute != null) { itemElement.Get_Act = StrParser.ParseDecInt(attribute, -1); } attribute = element.Attribute("Get_Sport"); if (attribute != null) { itemElement.Get_Sport = StrParser.ParseDecInt(attribute, -1); } attribute = element.Attribute("Get_Knowledge"); if (attribute != null) { itemElement.Get_Knowledge = StrParser.ParseDecInt(attribute, -1); } attribute = element.Attribute("Get_Deportment"); if (attribute != null) { itemElement.Get_Deportment = StrParser.ParseDecInt(attribute, -1); } attribute = element.Attribute("Get_Fatigue"); if (attribute != null) { itemElement.Get_Fatigue = StrParser.ParseDecInt(attribute, -1); } return(true); }
public static void Call(string subscriptionKey, string issueTokenUrl, string endpointUrl, string voiceName, string locale, string script, string outputFile, bool isSSML) { const string SsmlPattern = @"<speak version=""1.0"" xmlns=""http://www.w3.org/2001/10/synthesis"" xmlns:mstts=""http://www.w3.org/2001/mstts"" xml:lang=""{0}"">" + @"<voice name = ""{1}"">{2}</voice>" + @"</speak>"; string ssml = ""; string token = APIHelper.GetToken(issueTokenUrl, subscriptionKey); HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(endpointUrl); string ImpressionGUID = Guid.NewGuid().ToString(); webRequest.ContentType = "application/ssml+xml"; webRequest.Headers.Add("X-MICROSOFT-OutputFormat", "riff-16khz-16bit-mono-pcm"); webRequest.Headers["Authorization"] = "Bearer " + token; webRequest.Headers.Add("X-FD-ClientID", ImpressionGUID); webRequest.Headers.Add("X-FD-ImpressionGUID", ImpressionGUID); webRequest.UserAgent = "TTSClient"; webRequest.Method = "POST"; if (isSSML) { ssml = script; } else { ssml = string.Format(CultureInfo.InvariantCulture, SsmlPattern, locale, voiceName, SecurityElement.Escape(script)); } byte[] btBodys = Encoding.UTF8.GetBytes(ssml); webRequest.ContentLength = btBodys.Length; webRequest.GetRequestStream().Write(btBodys, 0, btBodys.Length); webRequest.Timeout = 6000000; using (var response = webRequest.GetResponse() as HttpWebResponse) { var sstream = response.GetResponseStream(); using (FileStream fs = new FileStream(outputFile, FileMode.Create, FileAccess.Write)) { sstream.CopyTo(fs); } } }
/// <summary> /// Command line parser. /// </summary> /// <param name="args">The command line arguments</param> /// <returns>A structure with information about the run</returns> private static CommandLineData ParseCommandLine(string[] args) { try { int i = 0; CommandLineData ret = new CommandLineData(); while (i < args.Length) { if (args[i].StartsWith("-")) { switch (args[i]) { //The partial trust PermissionSet case "-ps": PermSetNames permSet = (PermSetNames)Enum.Parse(typeof(PermSetNames), args[++i], true); ret.permission = PTRunnerLib.GetStandardPermission(permSet); break; //Add full trust assembly case "-af": Assembly asm = Assembly.LoadFrom(args[++i]); ret.fullTrustAssemblies.Add(asm); break; case "-xml": StreamReader sr = new StreamReader(args[++i]); SecurityElement elem = SecurityElement.FromString(sr.ReadToEnd()); ret.permission = new PermissionSet(PermissionState.None); ret.permission.FromXml(elem); break; default: Console.WriteLine("{0} - unknonw option", args[i]); Usage(); return(null); } ++i; } else { break; } } if (i < args.Length) { //This are the arguments for the program that will be run ret.programName = args[i++]; int argsSize = args.Length - i; ret.arguments = new string[argsSize]; if (argsSize > 0) { Array.Copy(args, i, ret.arguments, 0, argsSize); } if (ret.permission == null) { ret.permission = PTRunnerLib.GetStandardPermission(PermSetNames.Execution); } return(ret); } } catch (Exception ex) { Console.WriteLine(":RUNNER: Got exception while parsing command line: {0}", ex.Message); } Usage(); return(null); }
public void FromXml(SecurityElement e) { this.FromXml(e, null); }
public override void FromXml(SecurityElement securityElement) { }
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary><param name="e">The XML encoding to use to reconstruct the security object. </param><exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception><exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception> public void FromXml(SecurityElement e) { throw new NotImplementedException(); }
public void FromXml(SecurityElement element) { }
/// <summary>用 XML 编码重新构造具有指定状态的安全对象。</summary> /// <param name="e">用于重新构造安全对象的 XML 编码。</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="e" /> 参数为 null。</exception> /// <exception cref="T:System.ArgumentException"> /// <paramref name="e" /> 参数不是有效的应用程序目录成员条件元素。</exception> public void FromXml(SecurityElement e) { this.FromXml(e, (PolicyLevel)null); }
public async Task <IReadOnlyList <EntityVersion <WebResourceName, string> > > GetVersions(IEnumerable <WebResourceName> eventUrls) { var requestBody = @"<?xml version=""1.0""?> <C:calendar-multiget xmlns:C=""urn:ietf:params:xml:ns:caldav"" xmlns:D=""DAV:""> <D:prop> <D:getetag/> </D:prop> " + String.Join("\r\n", eventUrls.Select(u => string.Format("<D:href>{0}</D:href>", SecurityElement.Escape(u.OriginalAbsolutePath)))) + @" </C:calendar-multiget>"; var responseXml = await _webDavClient.ExecuteWebDavRequestAndReadResponse( _serverUrl, "REPORT", 1, null, null, "application/xml", requestBody ); XmlNodeList responseNodes = responseXml.XmlDocument.SelectNodes("/D:multistatus/D:response", responseXml.XmlNamespaceManager); var entities = new List <EntityVersion <WebResourceName, string> >(); if (responseNodes == null) { return(entities); } // ReSharper disable once LoopCanBeConvertedToQuery // ReSharper disable once PossibleNullReferenceException foreach (XmlElement responseElement in responseNodes) { var urlNode = responseElement.SelectSingleNode("D:href", responseXml.XmlNamespaceManager); var etagNode = responseElement.SelectSingleNode("D:propstat/D:prop/D:getetag", responseXml.XmlNamespaceManager); if (urlNode != null && etagNode != null) { entities.Add(EntityVersion.Create(new WebResourceName(urlNode.InnerText), HttpUtility.GetQuotedEtag(etagNode.InnerText))); } } return(entities); }
/// <summary> /// Replaces invalid XML characters in a string with their valid XML equivalent. /// </summary> /// <param name="str">The string within which to escape invalid characters.</param> /// <returns>The input string with invalid characters replaced.</returns> public static string ConvertInvalidXMLCharacters(string str) { return(SecurityElement.Escape(str)); }
public void FromXml(SecurityElement e) { _impl.FromXml(e); }
private static bool DefineResourceFetchingProperty(string propertyName, string resourceName, ResourceData data, CodeTypeDeclaration srClass, bool internalClass, bool useStatic) { CodeMethodReturnStatement statement; CodeMemberProperty property = new CodeMemberProperty { Name = propertyName, HasGet = true, HasSet = false }; Type baseType = data.Type; if (baseType == null) { return(false); } if (baseType == typeof(MemoryStream)) { baseType = typeof(UnmanagedMemoryStream); } while (!baseType.IsPublic) { baseType = baseType.BaseType; } CodeTypeReference targetType = new CodeTypeReference(baseType); property.Type = targetType; if (internalClass) { property.Attributes = MemberAttributes.Assembly; } else { property.Attributes = MemberAttributes.Public; } if (useStatic) { property.Attributes |= MemberAttributes.Static; } CodePropertyReferenceExpression targetObject = new CodePropertyReferenceExpression(null, "ResourceManager"); CodeFieldReferenceExpression expression2 = new CodeFieldReferenceExpression(useStatic ? null : new CodeThisReferenceExpression(), "resourceCulture"); bool flag = baseType == typeof(string); bool flag2 = (baseType == typeof(UnmanagedMemoryStream)) || (baseType == typeof(MemoryStream)); string methodName = "GetObject"; if (flag) { methodName = "GetString"; string valueIfString = data.ValueIfString; if (valueIfString == null) { valueIfString = string.Empty; } if (valueIfString.Length > 0x200) { valueIfString = Microsoft.Build.Tasks.SR.GetString("StringPropertyTruncatedComment", new object[] { valueIfString.Substring(0, 0x200) }); } valueIfString = SecurityElement.Escape(valueIfString); string text = string.Format(CultureInfo.CurrentCulture, Microsoft.Build.Tasks.SR.GetString("StringPropertyComment"), new object[] { valueIfString }); property.Comments.Add(new CodeCommentStatement("<summary>", true)); property.Comments.Add(new CodeCommentStatement(text, true)); property.Comments.Add(new CodeCommentStatement("</summary>", true)); } else if (flag2) { methodName = "GetStream"; } CodeExpression expression = new CodeMethodInvokeExpression(targetObject, methodName, new CodeExpression[] { new CodePrimitiveExpression(resourceName), expression2 }); if (flag || flag2) { statement = new CodeMethodReturnStatement(expression); } else { CodeVariableDeclarationStatement statement2 = new CodeVariableDeclarationStatement(typeof(object), "obj", expression); property.GetStatements.Add(statement2); statement = new CodeMethodReturnStatement(new CodeCastExpression(targetType, new CodeVariableReferenceExpression("obj"))); } property.GetStatements.Add(statement); srClass.Members.Add(property); return(true); }
public abstract void FromXml(SecurityElement elem);
public static bool ConvertXlsxPropertiesToXML(Properties prop, out SecurityElement client, out SecurityElement server) { List <Properties> clientProps = new List <Properties>(); prop.GetNamespaces(CLIENT_XLSX_NODE_TAG, ref clientProps, false, true); List <Properties> serverProps = new List <Properties>(); prop.GetNamespaces(SERVER_XLSX_NODE_TAG, ref serverProps, false, true); client = new SecurityElement(prop.mNamespace); foreach (Properties clientProp in clientProps) { SecurityElement parent = new SecurityElement(clientProp.Parent.mNamespace + "s"); client.AddChild(parent); clientProp.WriteProperties(parent); } server = new SecurityElement(prop.mNamespace); foreach (Properties serverProp in serverProps) { SecurityElement parent = new SecurityElement(serverProp.Parent.mNamespace + "s"); server.AddChild(parent); serverProp.WriteProperties(parent); } return(true); }
private void AppendDeviceProperties(StringBuilder builder) { builder.Append("<UDN>uuid:" + SecurityElement.Escape(_serverUdn) + "</UDN>"); builder.Append("<dlna:X_DLNACAP>" + SecurityElement.Escape(_profile.XDlnaCap ?? string.Empty) + "</dlna:X_DLNACAP>"); builder.Append("<dlna:X_DLNADOC xmlns:dlna=\"urn:schemas-dlna-org:device-1-0\">M-DMS-1.50</dlna:X_DLNADOC>"); builder.Append("<dlna:X_DLNADOC xmlns:dlna=\"urn:schemas-dlna-org:device-1-0\">" + SecurityElement.Escape(_profile.XDlnaDoc ?? string.Empty) + "</dlna:X_DLNADOC>"); builder.Append("<friendlyName>" + SecurityElement.Escape(GetFriendlyName()) + "</friendlyName>"); builder.Append("<deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>"); builder.Append("<manufacturer>" + SecurityElement.Escape(_profile.Manufacturer ?? string.Empty) + "</manufacturer>"); builder.Append("<manufacturerURL>" + SecurityElement.Escape(_profile.ManufacturerUrl ?? string.Empty) + "</manufacturerURL>"); builder.Append("<modelName>" + SecurityElement.Escape(_profile.ModelName ?? string.Empty) + "</modelName>"); builder.Append("<modelDescription>" + SecurityElement.Escape(_profile.ModelDescription ?? string.Empty) + "</modelDescription>"); builder.Append("<modelNumber>" + SecurityElement.Escape(_profile.ModelNumber ?? string.Empty) + "</modelNumber>"); builder.Append("<modelURL>" + SecurityElement.Escape(_profile.ModelUrl ?? string.Empty) + "</modelURL>"); builder.Append("<serialNumber>" + SecurityElement.Escape(_profile.SerialNumber ?? string.Empty) + "</serialNumber>"); builder.Append("<presentationURL>" + SecurityElement.Escape(_serverAddress) + "</presentationURL>"); if (!EnableAbsoluteUrls) { //builder.Append("<URLBase>" + SecurityElement.Escape(_serverAddress) + "</URLBase>"); } if (!string.IsNullOrWhiteSpace(_profile.SonyAggregationFlags)) { builder.Append("<av:aggregationFlags xmlns:av=\"urn:schemas-sony-com:av\">" + SecurityElement.Escape(_profile.SonyAggregationFlags) + "</av:aggregationFlags>"); } }
/// <summary>When overridden in a derived class, reconstructs properties and internal state specific to a derived code group from the specified <see cref="T:System.Security.SecurityElement" />.</summary><param name="e">The XML encoding to use to reconstruct the security object. </param><param name="level">The policy level within which the code group exists. </param> protected virtual void ParseXml(SecurityElement e, PolicyLevel level) { throw new NotImplementedException(); }
private bool LoadItemElement(SecurityElement element, out TaskObject itemElement) { itemElement = new TaskObject(); string attribute = element.Attribute("Task_ID"); if (attribute != null) { itemElement.Task_ID = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Name"); if (attribute != null) { itemElement.Name = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Talk_ID"); if (attribute != null) { itemElement.Talk_ID = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Task_Desc"); if (attribute != null) { itemElement.Task_Desc = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("City_ID"); if (attribute != null) { itemElement.City_ID = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Task_Category"); if (attribute != null) { itemElement.Task_Category = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Task_Type"); if (attribute != null) { itemElement.Task_Type = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Publish_Type"); if (attribute != null) { itemElement.Publish_Type = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Artist_ID"); if (attribute != null) { itemElement.Artist_ID = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Is_Branch"); if (attribute != null) { itemElement.Is_Branch = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Parent_Task_ID"); if (attribute != null) { itemElement.Parent_Task_ID = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Next_Task_ID"); if (attribute != null) { itemElement.Next_Task_ID = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Require_Condition"); if (attribute != null) { itemElement.Require_Condition = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Visible_Condition"); if (attribute != null) { itemElement.Visible_Condition = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Need_Energy"); if (attribute != null) { itemElement.Need_Energy = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Need_Acting"); if (attribute != null) { itemElement.Need_Acting = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Need_Score"); if (attribute != null) { itemElement.Need_Score = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Progress_Count"); if (attribute != null) { itemElement.Progress_Count = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Can_Use_Items"); if (attribute != null) { itemElement.Can_Use_Items = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Is_Single"); if (attribute != null) { itemElement.Is_Single = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Need_Friend_Sex"); if (attribute != null) { itemElement.Need_Friend_Sex = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Posture_Group"); if (attribute != null) { itemElement.Posture_Group = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Male_Appearance_Effect"); if (attribute != null) { itemElement.Male_Appearance_Effect = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Female_Appearance_Effect"); if (attribute != null) { itemElement.Female_Appearance_Effect = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Max_Dress_Style_Score"); if (attribute != null) { itemElement.Max_Dress_Style_Score = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Rewards"); if (attribute != null) { itemElement.Rewards = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Time"); if (attribute != null) { itemElement.CountDownTime = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Type_Icon"); if (attribute != null) { itemElement.Type_Icon = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Sex_Icon"); if (attribute != null) { itemElement.Sex_Icon = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Tex_Background"); if (attribute != null) { itemElement.Tex_Background = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Scene_Background"); if (attribute != null) { itemElement.Scene_Background = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("CameraAnimition"); if (attribute != null) { itemElement.CameraAnimition = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("CharacterOneAnimition"); if (attribute != null) { itemElement.CharacterOneAnimition = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("CharacterTwoAnimition"); if (attribute != null) { itemElement.CharacterTwoAnimition = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("MusicName"); if (attribute != null) { itemElement.MusicName = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Style_Effect"); if (attribute != null) { itemElement.Style_Effect = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Style_Percent"); if (attribute != null) { itemElement.Style_Percent = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Material_Effect"); if (attribute != null) { itemElement.Material_Effect = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Material_Percent"); if (attribute != null) { itemElement.Material_Percent = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Theme_Effect"); if (attribute != null) { itemElement.Theme_Effect = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Theme_Percent"); if (attribute != null) { itemElement.Theme_Percent = StrParser.ParseDecInt(attribute, 0); } attribute = element.Attribute("Dress_Part_Effect"); if (attribute != null) { itemElement.Dress_Part_Effect = StrParser.ParseStr(attribute, ""); } attribute = element.Attribute("Dress_Part_Percent"); if (attribute != null) { itemElement.Dress_Part_Percent = StrParser.ParseDecInt(attribute, 0); } return(true); }
public void FromXml(SecurityElement e, PolicyLevel level) { }
public void LoadXml(string xml) { this.root = null; this.stack.Clear(); base.Parse(new StringReader(xml), this); }
/// <summary>Reconstructs a security object with a specified state from an XML encoding.</summary><param name="e">The XML encoding to use to reconstruct the security object. </param><param name="level">The policy level context, used to resolve named permission set references. </param><exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is null. </exception><exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid membership condition element. </exception> public void FromXml(SecurityElement e, PolicyLevel level) { throw new NotImplementedException(); }
/// <summary> /// Replace XML string to another /// </summary> /// <param name="doc"></param> /// <param name="oldText"></param> /// <param name="newText"></param> public static void ReplaceXML(XmlDocument doc, string oldText, string newText) { string newTextFormated = SecurityElement.Escape(newText); doc.InnerXml = doc.InnerXml.Replace(oldText, newTextFormated); }
public void OnEndElement(string name) { this.current = (SecurityElement)this.stack.Pop(); }
public override void FromXml(SecurityElement securityElement) { throw new NotImplementedException(); }
public void FromXml(SecurityElement e, PolicyLevel level) { MembershipConditionHelper.CheckSecurityElement(e, "e", version, version); // PolicyLevel isn't used as there's no need to resolve NamedPermissionSet references }
public static string Escape(this string s) { return(SecurityElement.Escape(s)); }
private static bool load_xml(byte[] pBuffer) { try { Debug.Check(pBuffer != null); string xml = System.Text.Encoding.UTF8.GetString(pBuffer); SecurityParser xmlDoc = new SecurityParser(); xmlDoc.LoadXml(xml); SecurityElement rootNode = xmlDoc.ToXml(); if (rootNode.Children == null || rootNode.Tag != "agents" && rootNode.Children.Count != 1) { return(false); } string versionStr = rootNode.Attribute("version"); Debug.Check(!string.IsNullOrEmpty(versionStr)); foreach (SecurityElement bbNode in rootNode.Children) { if (bbNode.Tag == "agent" && bbNode.Children != null) { string agentType = bbNode.Attribute("type").Replace("::", "."); AgentProperties bb = new AgentProperties(agentType); agent_type_blackboards[agentType] = bb; foreach (SecurityElement propertiesNode in bbNode.Children) { if (propertiesNode.Tag == "properties" && propertiesNode.Children != null) { foreach (SecurityElement propertyNode in propertiesNode.Children) { if (propertyNode.Tag == "property") { string name = propertyNode.Attribute("name"); string type = propertyNode.Attribute("type").Replace("::", "."); string memberStr = propertyNode.Attribute("member"); bool bIsMember = false; if (!string.IsNullOrEmpty(memberStr) && memberStr == "true") { bIsMember = true; } string isStatic = propertyNode.Attribute("static"); bool bIsStatic = false; if (!string.IsNullOrEmpty(isStatic) && isStatic == "true") { bIsStatic = true; } //string agentTypeMember = agentType; string agentTypeMember = null; string valueStr = null; if (!bIsMember) { valueStr = propertyNode.Attribute("defaultvalue"); } else { agentTypeMember = propertyNode.Attribute("agent").Replace("::", "."); } bb.AddProperty(type, bIsStatic, name, valueStr, agentTypeMember); } } } else if (propertiesNode.Tag == "methods" && propertiesNode.Children != null) { Agent.CTagObjectDescriptor objectDesc = Agent.GetDescriptorByName(agentType); foreach (SecurityElement methodNode in propertiesNode.Children) { if (methodNode.Tag == "method") { //string eventStr = methodNode.Attribute("isevent"); //bool bEvent = (eventStr == "true"); //string taskStr = methodNode.Attribute("istask"); //bool bTask = (taskStr == "true"); //skip those other custom method string methodName = methodNode.Attribute("name"); //string type = methodNode.Attribute("returntype").Replace("::", "."); //string isStatic = methodNode.Attribute("static"); //string agentTypeStr = methodNode.Attribute("agent").Replace("::", "."); CCustomMethod customeMethod = new CTaskMethod(agentType, methodName); if (methodNode.Children != null) { foreach (SecurityElement paramNode in methodNode.Children) { if (paramNode.Tag == "parameter") { string paramName = paramNode.Attribute("name"); Debug.Check(!string.IsNullOrEmpty(paramName)); string paramType = paramNode.Attribute("type"); //string paramFullName = string.Format("{0}::{1}", paramType, paramName); customeMethod.AddParamType(paramType); } } } objectDesc.ms_methods.Add(customeMethod); } } //end of for methodNode } //end of methods } //end of for propertiesNode } } //end of for bbNode return(true); } catch (Exception e) { Debug.Check(false, e.Message); } Debug.Check(false); return(false); }