Mercurial > hg > ucis.core
comparison Xml/PolicyFile.cs @ 0:3ab940a0c7a0
Initial commit
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Tue, 11 Sep 2012 16:28:53 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3ab940a0c7a0 |
---|---|
1 using System; | |
2 using System.Collections.Generic; | |
3 using System.Text; | |
4 using UCIS.Net; | |
5 | |
6 namespace UCIS.Xml { | |
7 public class XmlPolicyFile : XmlServer.IModule { | |
8 private string[] pHosts; | |
9 private string pPorts; | |
10 | |
11 public XmlPolicyFile(string[] Hosts) : this(Hosts, null) { } | |
12 public XmlPolicyFile(string[] Hosts, int[] Ports) { | |
13 pHosts = Hosts; | |
14 if (Ports != null) { | |
15 pPorts = ""; | |
16 foreach (int Port in Ports) { | |
17 pPorts += "," + Port.ToString(); | |
18 } | |
19 pPorts = pPorts.Substring(1); | |
20 } else { | |
21 pPorts = null; | |
22 } | |
23 } | |
24 | |
25 public void Accept(XmlSocket Socket, System.Xml.XmlDocument FirstMessage) { | |
26 Socket.WriterSettings.OmitXmlDeclaration = false; | |
27 | |
28 Socket.WriteStartDocument(); | |
29 Socket.WriteDocType("cross-domain-policy", null, "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd", null); | |
30 Socket.WriteStartElement("cross-domain-policy"); | |
31 | |
32 foreach (string Host in pHosts) { | |
33 Socket.WriteStartElement("allow-access-from"); | |
34 Socket.WriteAttributeString("domain", Host); | |
35 if (pPorts != null) Socket.WriteAttributeString("to-ports", pPorts); | |
36 Socket.WriteEndElement(); | |
37 } | |
38 | |
39 Socket.WriteEndElement(); | |
40 Socket.WriteEndDocument(); | |
41 } | |
42 } | |
43 } |