예제 #1
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);
    }
  }
예제 #2
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);
    }
  }