Пример #1
0
  @Override
  public void replicate(ConfigManager manager, ConfigRequest request) throws IOException {
    if (!request.applies(AuthCodes.FEATURE)) {
      return;
    }
    if (!m_authCodes.isEnabled()) {
      return;
    }

    Set<Location> locations = request.locations(manager);
    Address fs = manager.getAddressManager().getSingleAddress(FreeswitchFeature.ACC_EVENT_ADDRESS);
    Domain domain = manager.getDomainManager().getDomain();
    for (Location location : locations) {
      AuthCodeSettings settings = m_authCodes.getSettings();
      File dir = manager.getLocationDataDirectory(location);
      boolean enabled = manager.getFeatureManager().isFeatureEnabled(AuthCodes.FEATURE);
      ConfigUtils.enableCfengineClass(dir, "sipxacccode.cfdat", enabled, "sipxacccode");
      Writer flat = new FileWriter(new File(dir, "sipxacccode.properties.part"));
      try {
        writeConfig(flat, settings, domain, fs.getPort());
      } finally {
        IOUtils.closeQuietly(flat);
      }
    }
  }
Пример #2
0
  @Override
  public void replicate(ConfigManager manager, ConfigRequest request) throws IOException {
    if (!request.applies(CertificateManager.FEATURE)) {
      return;
    }

    boolean chainCertificate = false;
    boolean caCertificate = false;
    File dir = manager.getGlobalDataDirectory();
    String sipCert = m_certificateManager.getCommunicationsCertificate();
    FileUtils.writeStringToFile(new File(dir, "ssl.crt"), sipCert);
    String sipKey = m_certificateManager.getCommunicationsPrivateKey();
    FileUtils.writeStringToFile(new File(dir, "ssl.key"), sipKey);
    String webCert = m_certificateManager.getWebCertificate();
    FileUtils.writeStringToFile(new File(dir, "ssl-web.crt"), webCert);
    String webKey = m_certificateManager.getWebPrivateKey();
    FileUtils.writeStringToFile(new File(dir, "ssl-web.key"), webKey);

    String chainCert = m_certificateManager.getChainCertificate();
    if (chainCert != null) {
      FileUtils.writeStringToFile(new File(dir, "server-chain.crt"), chainCert);
      chainCertificate = true;
    }
    String caCert = m_certificateManager.getCACertificate();
    if (caCert != null) {
      FileUtils.writeStringToFile(new File(dir, "ca-bundle.crt"), caCert);
      caCertificate = true;
    }
    Writer writer = new FileWriter(new File(dir, "ssl.conf"));
    try {
      write(writer, chainCertificate, caCertificate);
    } finally {
      IOUtils.closeQuietly(writer);
    }

    String domain = Domain.getDomain().getName();

    JavaKeyStore sslSip = new JavaKeyStore();
    sslSip.addKey(domain, sipCert, sipKey);
    sslSip.storeIfDifferent(new File(dir, "ssl.keystore"));

    JavaKeyStore sslWeb = new JavaKeyStore();
    sslWeb.addKey(domain, webCert, webKey);
    sslWeb.storeIfDifferent(new File(dir, "ssl-web.keystore"));

    File authDir = new File(dir, "authorities");
    authDir.mkdir();
    JavaKeyStore store = new JavaKeyStore();
    for (String authority : m_certificateManager.getAuthorities()) {
      String authCert = m_certificateManager.getAuthorityCertificate(authority);
      FileUtils.writeStringToFile(new File(authDir, authority + ".crt"), authCert);
      store.addAuthority(authority, authCert);
    }
    OutputStream authoritiesStore = null;
    try {
      store.storeIfDifferent(new File(dir, "authorities.jks"));
    } finally {
      IOUtils.closeQuietly(authoritiesStore);
    }
  }
Пример #3
0
  @Override
  public void replicate(ConfigManager manager, ConfigRequest request) throws IOException {
    if (!request.applies(LogWatcher.FEATURE)) {
      return;
    }

    File gdir = manager.getGlobalDataDirectory();
    boolean enabled = manager.getFeatureManager().isFeatureEnabled(LogWatcher.FEATURE);
    LogWatcherSettings settings = m_logWatcher.getSettings();
    Writer w = new FileWriter(new File(gdir, "sipxlogwatcher.cfdat"));
    try {
      CfengineModuleConfiguration cfg = new CfengineModuleConfiguration(w);
      cfg.writeClass(LogWatcher.FEATURE.getId(), enabled);
      cfg.write("logwatcher_", settings.getSettings().getSetting("config"));
    } finally {
      IOUtils.closeQuietly(w);
    }
  }
Пример #4
0
  @Override
  public void replicate(ConfigManager manager, ConfigRequest request) throws IOException {
    if (!request.applies(
        DialPlanContext.FEATURE,
        Ivr.FEATURE,
        Mwi.FEATURE,
        RestServer.FEATURE,
        ImBot.FEATURE,
        FreeswitchFeature.FEATURE,
        AdminContext.FEATURE,
        ApacheManager.FEATURE,
        ImManager.FEATURE)) {
      return;
    }
    Set<Location> locations = request.locations(manager);
    FeatureManager featureManager = manager.getFeatureManager();
    Address adminApi = manager.getAddressManager().getSingleAddress(AdminContext.HTTP_ADDRESS_AUTH);
    Address apacheApi = manager.getAddressManager().getSingleAddress(ApacheManager.HTTPS_ADDRESS);
    Address restApi = manager.getAddressManager().getSingleAddress(RestServer.HTTP_API);
    Address imApi = manager.getAddressManager().getSingleAddress(ImManager.XMLRPC_ADDRESS);
    Address imbotApi = manager.getAddressManager().getSingleAddress(ImBot.REST_API);
    Address fsEvent = manager.getAddressManager().getSingleAddress(FreeswitchFeature.EVENT_ADDRESS);
    IvrSettings settings = m_ivr.getSettings();
    Domain domain = manager.getDomainManager().getDomain();
    List<Location> mwiLocations =
        manager.getFeatureManager().getLocationsForEnabledFeature(Mwi.FEATURE);
    int mwiPort = m_mwi.getSettings().getHttpApiPort();
    for (Location location : locations) {
      File dir = manager.getLocationDataDirectory(location);
      boolean enabled = featureManager.isFeatureEnabled(Ivr.FEATURE, location);

      ConfigUtils.enableCfengineClass(dir, "sipxivr.cfdat", enabled, "sipxivr");
      if (!enabled) {
        continue;
      }
      File f = new File(dir, "sipxivr.properties.part");
      Writer wtr = new FileWriter(f);
      Set<String> mwiAddresses = new LinkedHashSet<String>();
      mwiAddresses.add(location.getAddress());
      for (Location mwiLocation : mwiLocations) {
        mwiAddresses.add(mwiLocation.getAddress());
      }
      try {
        write(
            wtr,
            settings,
            domain,
            location,
            StringUtils.join(mwiAddresses, ","),
            mwiPort,
            restApi,
            adminApi,
            apacheApi,
            imApi,
            imbotApi,
            fsEvent);
      } finally {
        IOUtils.closeQuietly(wtr);
      }
    }
  }