コード例 #1
0
        /// <summary>
        /// Initialise a Manager Configuration object with CA data
        /// </summary>
        internal void Initialise()
        {
            if (InitData == null)
            {
                throw new ApplicationException("Initialisation Data not found");
            }

            CaList = new List <CA>();

            // Load the data from the manager config file
            XDocument config = XDocument.Load(InitData.configFile);

            OscaFolder   = config.Element("OSCAMGR").Element("Root").Element("location").Value;
            PolicyFolder = config.Element("OSCAMGR").Element("Policy").Element("location").Value;
            var calist = config.Element("OSCAMGR").Element("CAList").Descendants("CA");
            CA  ca;

            foreach (XElement item in calist)
            {
                ca                = new CA();
                ca.CaName         = item.Element("name").Value;
                ca.Role           = item.Element("type").Value;
                ca.ConfigLocation = item.Element("config").Value;
                ca.CaControl      = new CaControl(ca.ConfigLocation);
                CaList.Add(ca);
            }
        }
コード例 #2
0
        /// <summary>
        /// Remove a CA from the Manager Configuration
        /// </summary>
        /// <param name="ca">CA object to remove</param>
        public void RemoveCA(CA ca)
        {
            // Remove the entry from the config file
            XDocument config = XDocument.Load(InitData.configFile);
            var       calist = config.Element("OSCAMGR").Element("CAList").Descendants("CA");

            foreach (XElement item in calist)
            {
                if (item.Element("name").Value == ca.CaName)
                {
                    item.Remove();
                    break;  // Have to break here as loop is unstable when last item removed from the list
                }
            }
            config.Save(InitData.configFile);

            // Remove the entry from the list
            CaList.Remove(ca);
        }
コード例 #3
0
        /// <summary>
        /// Add a new CA to the Manager Configuration
        /// </summary>
        /// <param name="ca">CA object to add</param>
        internal void InsertCA(CA ca)
        {
            // Create a new CA entry
            XElement entry = new XElement("CA",
                                          new XElement("name", ca.CaName),
                                          new XElement("type", ca.Role),
                                          new XElement("config", ca.ConfigLocation)
                                          );

            // Insert CA entry into config file
            XDocument config = XDocument.Load(InitData.configFile);
            XElement  ep     = config.Element("OSCAMGR").Element("CAList");

            ep.Add(entry);
            config.Save(InitData.configFile);

            // Insert CA entry into Config Manager object
            ca.CaControl = new CaControl(ca.ConfigLocation);
            CaList.Add(ca);
        }