TSystems.RELOAD.Enroll.ReloadConfigResolve.ReadConfig C# (CSharp) Méthode

ReadConfig() public méthode

public ReadConfig ( ) : void
Résultat void
    public void ReadConfig() {
      TextReader tr_xml = (TextReader)GetConfigDocument();

      if (tr_xml != null) {
        //string s = tr_xml.ReadToEnd();
        XmlSerializer serializer = new XmlSerializer(typeof(overlayelement));
        m_ReloadConfig.Document = new ReloadOverlayConfiguration((overlayelement)serializer.Deserialize(tr_xml));

        try {

          var p2psipConfig = m_ReloadConfig.Document.Overlay;

          if (p2psipConfig.configuration.maxmessagesizeSpecified)
            ReloadGlobals.MAX_PACKET_BUFFER_SIZE = (int)m_ReloadConfig.Document.Overlay.configuration.maxmessagesize;

          if (p2psipConfig.configuration.reportingurl != null)
            m_ReloadConfig.ReportURL = m_ReloadConfig.Document.Overlay.configuration.reportingurl;

          if (p2psipConfig.configuration.enrollmentserver != null)
            enrollment_url = p2psipConfig.configuration.enrollmentserver[0];

          foreach (kindblock block in p2psipConfig.configuration.requiredkinds) {
            if (block.kind.name != null) {
              if (block.kind.name.ToUpper() == "SIP-REGISTRATION")
                ReloadGlobals.SIP_REGISTRATION_DATA_MODEL = ReloadGlobals.DataModelFromString(block.kind.datamodel);
              else if (block.kind.name.ToUpper() == "CERTIFICATE_BY_NODE")
                ReloadGlobals.CERTIFICATE_BY_NODE_DATA_MODEL = ReloadGlobals.DataModelFromString(block.kind.datamodel);
              else if (block.kind.name.ToUpper() == "CERTIFICATE_BY_USER")
                ReloadGlobals.CERTIFICATE_BY_USER_DATA_MODEL = ReloadGlobals.DataModelFromString(block.kind.datamodel);
            }
          }

          string rootcert = p2psipConfig.configuration.rootcert;

          if (rootcert != null && rootcert.Length > 0) {
            //remove all whitespaces and trailing new lines!!
            rootcert = rootcert.TrimStart('\n');
            rootcert = rootcert.TrimEnd('\n');
            rootcert = rootcert.Replace("  ", "");

            byte[] buffer2 = Convert.FromBase64String(rootcert);
            m_ReloadConfig.RootCertificate = new X509Certificate2(buffer2);

            // Add root certificate to trusted root certificate store
            X509Store store = new X509Store(StoreName.Root, StoreLocation.CurrentUser);
            store.Open(OpenFlags.ReadWrite);
            store.Add(m_ReloadConfig.RootCertificate);
            store.Close();
          }

          if (p2psipConfig.configuration.landmarks != null &&
    p2psipConfig.configuration.landmarks.landmarkhost.Length > 0) {
            var landmark = p2psipConfig.configuration.landmarks.landmarkhost[0].address;
          }

          ReloadGlobals.SelfSignPermitted = p2psipConfig.configuration.selfsignedpermitted.Value;
        }
        catch (Exception ex) {
          m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_ERROR, "ReadConfig: " + ex.Message);
        }
      }
    }

Usage Example

Exemple #1
0
    public bool Init() {

      try {
        if (ReloadGlobals.IgnoreSSLErrors)
          IgnoreSSLErrors();

        m_transport = new MessageTransport();

        if (ReloadGlobals.TLS)
          m_interface_flm = new ReloadFLM(ReloadConfig);
        else
          m_interface_flm = new SimpleFLM(ReloadConfig);

        ReloadConfig.Statistics.SetParams(m_interface_flm);
        m_interface_flm.ReloadFLMEventHandler += 
          new ReloadFLMEvent(m_transport.rfm_ReloadFLMEventHandler);

        ReloadConfig.State = ReloadConfig.RELOAD_State.Init;
        stateUpdates(ReloadConfig.RELOAD_State.Init);

        ReloadConfigResolve resolve = new ReloadConfigResolve(ReloadConfig);

        resolve.ReadConfig();
        if (ReloadGlobals.TLS)
          resolve.EnrollmentProcedure();
        else
          resolve.SimpleNodeIdRequest();

        m_interface_flm.Init();
        m_ReloadConfig.AccessController = new AccessController(m_ReloadConfig);
        m_topology = new TopologyPlugin(this);
        if (!m_topology.Init(this))
          return false;

        m_forwarding = new ForwardingLayer(this);
        m_transport.Init(this);

        //ReloadConfig.State = ReloadConfig.RELOAD_State.Configured;
        //stateUpdates(ReloadConfig.RELOAD_State.Configured);
        BootStrapConfig();

        m_ReloadConfig.StartJoining = DateTime.Now;
        if (m_ReloadConfig.IamClient)
          m_ReloadConfig.StartJoinMobile = DateTime2.Now;
        if (!ReloadConfig.IsBootstrap)
          Arbiter.Activate(ReloadConfig.DispatcherQueue, 
            new IterativeTask<List<BootstrapServer>>(m_BootstrapServerList,
            m_transport.PreJoinProdecure));

//        m_worker_thread.ReportProgress(100); --joscha
        InitUsageManager();
        ReloadConfig.State = ReloadConfig.RELOAD_State.Configured;
        stateUpdates(ReloadConfig.RELOAD_State.Configured);

        /* reporting service */
        Arbiter.Activate(ReloadConfig.DispatcherQueue, new IterativeTask(Reporting));
        /* chord-ping-interval */
        Arbiter.Activate(ReloadConfig.DispatcherQueue, new IterativeTask(Maintenance));
        /* chord-update-interval */
        Arbiter.Activate(ReloadConfig.DispatcherQueue, new IterativeTask(UpdateCycle));
        Arbiter.Activate(ReloadConfig.DispatcherQueue, new IterativeTask(CommandCheckTask));
      }
      catch (Exception ex) {
        ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_ERROR, "Init: " + ex.Message);
      }
      return true;
    }