コード例 #1
0
        public IPolicyXml GetExistingPolicySetXml(string filename)
        {
            Stream inputStream = OpenPolicyFileStream(filename, out m_bDecryptXML);

            using (inputStream)
            {
                ZipFileReader zipfile = null;
                try
                {
                    zipfile = new ZipFileReader(inputStream);
                    ZipEntry zipEntry = zipfile.GetEntry("properties.xml");

                    if (zipEntry == null)
                    {
                        Logger.LogError("Failed to find the properties file in " + filename + " - this is not a valid policy set file.");
                        return null;
                    }

                    return ReadPolicyFile(zipfile, ReadEntry(zipfile, zipEntry));
                }
                catch
                {
                    Logger.LogError("Ignoring " + filename + " - Itdoes not appear to be a valid policy file.");
                }
                finally
                {
                    if (zipfile != null)
                        zipfile.Close();
                }
            }

            return null;
        }
コード例 #2
0
        private IPolicyXml ReadPolicyFile(ZipFileReader zipfile, string properties)
        {
            XmlDocument xmlDoc = new XmlDocument();
            if (m_bDecryptXML)
                properties = Crypto.Instance.DecryptXml(properties);
            xmlDoc.LoadXml(properties);

            try
            {
                XmlNode Root = xmlDoc.SelectSingleNode(@"/PolicyProperties");
                if (Root.Attributes["type"] != null)
                {
                    string type = Root.Attributes.GetNamedItem("type").Value;
                    m_runtimeType = string.Compare(type, "COMPILED") == 0;
                }
            }
            catch (Exception ex)
            {
                Logger.LogError("Unable to retrieve policy file type from policy file");
                Logger.LogError(ex);
                m_runtimeType = false;
            }

            XmlNode latestVersionNode = xmlDoc.SelectSingleNode(@"/PolicyProperties/LatestVersion");
            string latestVersion = latestVersionNode.InnerXml;

            XmlNodeList versionNodes = xmlDoc.SelectNodes(@"/PolicyProperties/Versions/Version");
            foreach (XmlNode versionNode in versionNodes)
            {
                string version = versionNode.Attributes.GetNamedItem("name").Value;
                string entry = version + "/policysetversion.xml";
                ZipEntry zipEntry = zipfile.GetEntry(entry);
                if (zipEntry == null)
                {
                    if (version == latestVersion)
                        Logger.LogError(@"Failed to find the policy set file - this is not a valid policy set file.");
                    continue;
                }

                return zipfile.ReadEntry(entry, m_encoding);
            }

            return null;
        }
コード例 #3
0
ファイル: PolicyXml.cs プロジェクト: killbug2004/WSProf
 public PolicyXml(string path, ZipFileReader zipFile)
 {
     Path = path;
     m_zipFile = zipFile;
 }