Package org.eclipse.jgit.storage.file

Examples of org.eclipse.jgit.storage.file.FileBasedConfig


      // We only want the repository's configuration file, and not
      // the user file, as these parameters must be unique to this
      // repository and not inherited from other files.
      //
      File path = safeFS().resolve(getGitDir(), "config");
      FileBasedConfig cfg = new FileBasedConfig(path, safeFS());
      try {
        cfg.load();
      } catch (ConfigInvalidException err) {
        throw new IllegalArgumentException(MessageFormat.format(
            JGitText.get().repositoryConfigFileInvalid, path
                .getAbsolutePath(), err.getMessage()));
      }
View Full Code Here


    CleanupThread.deleteOnShutdown(tmp);
    if (!tmp.delete() || !tmp.mkdir())
      throw new IOException("Cannot create " + tmp);

    mockSystemReader = new MockSystemReader();
    mockSystemReader.userGitConfig = new FileBasedConfig(new File(tmp,
        "usergitconfig"), FS.DETECTED);
    ceilTestDirectories(getCeilings());
    SystemReader.setInstance(mockSystemReader);

    final long now = mockSystemReader.getCurrentTime();
View Full Code Here

      removeFromCachedRepositoryList(repositoryName);
      logger.error(MessageFormat.format("Repository \"{0}\" is missing! Removing from cache.", repositoryName));
      return null;
    }

    FileBasedConfig config = (FileBasedConfig) getRepositoryConfig(r);
    if (config.isOutdated()) {
      // reload model
      logger.debug(MessageFormat.format("Config for \"{0}\" has changed. Reloading model and updating cache.", repositoryName));
      model = loadRepositoryModel(model.name);
      removeFromCachedRepositoryList(model.name);
      addToCachedRepositoryList(model);
View Full Code Here

  }

  @Override
  public ProjectManager start() {
    // load and cache the project metadata
    projectConfigs = new FileBasedConfig(runtimeManager.getFileOrFolder(Keys.web.projectsFile, "${baseFolder}/projects.conf"), FS.detect());
    getProjectConfigs();

    return this;
  }
View Full Code Here

   */
  private synchronized void write() throws IOException {
    // Write a temporary copy of the users file
    File realmFileCopy = new File(realmFile.getAbsolutePath() + ".tmp");

    StoredConfig config = new FileBasedConfig(realmFileCopy, FS.detect());

    // write users
    for (UserModel model : users.values()) {
      if (!StringUtils.isEmpty(model.password)) {
        config.setString(USER, model.username, PASSWORD, model.password);
      }
      if (!StringUtils.isEmpty(model.cookie)) {
        config.setString(USER, model.username, COOKIE, model.cookie);
      }
      if (!StringUtils.isEmpty(model.displayName)) {
        config.setString(USER, model.username, DISPLAYNAME, model.displayName);
      }
      if (!StringUtils.isEmpty(model.emailAddress)) {
        config.setString(USER, model.username, EMAILADDRESS, model.emailAddress);
      }
      if (model.accountType != null) {
        config.setString(USER, model.username, ACCOUNTTYPE, model.accountType.name());
      }
      if (!StringUtils.isEmpty(model.organizationalUnit)) {
        config.setString(USER, model.username, ORGANIZATIONALUNIT, model.organizationalUnit);
      }
      if (!StringUtils.isEmpty(model.organization)) {
        config.setString(USER, model.username, ORGANIZATION, model.organization);
      }
      if (!StringUtils.isEmpty(model.locality)) {
        config.setString(USER, model.username, LOCALITY, model.locality);
      }
      if (!StringUtils.isEmpty(model.stateProvince)) {
        config.setString(USER, model.username, STATEPROVINCE, model.stateProvince);
      }
      if (!StringUtils.isEmpty(model.countryCode)) {
        config.setString(USER, model.username, COUNTRYCODE, model.countryCode);
      }
      if (model.disabled) {
        config.setBoolean(USER, model.username, DISABLED, true);
      }
      if (model.getPreferences() != null) {
        if (!StringUtils.isEmpty(model.getPreferences().locale)) {
          config.setString(USER, model.username, LOCALE, model.getPreferences().locale);
        }
      }

      // user roles
      List<String> roles = new ArrayList<String>();
      if (model.canAdmin) {
        roles.add(Constants.ADMIN_ROLE);
      }
      if (model.canFork) {
        roles.add(Constants.FORK_ROLE);
      }
      if (model.canCreate) {
        roles.add(Constants.CREATE_ROLE);
      }
      if (model.excludeFromFederation) {
        roles.add(Constants.NOT_FEDERATED_ROLE);
      }
      if (roles.size() == 0) {
        // we do this to ensure that user record with no password
        // is written.  otherwise, StoredConfig optimizes that account
        // away. :(
        roles.add(Constants.NO_ROLE);
      }
      config.setStringList(USER, model.username, ROLE, roles);

      // discrete repository permissions
      if (model.permissions != null && !model.canAdmin) {
        List<String> permissions = new ArrayList<String>();
        for (Map.Entry<String, AccessPermission> entry : model.permissions.entrySet()) {
          if (entry.getValue().exceeds(AccessPermission.NONE)) {
            permissions.add(entry.getValue().asRole(entry.getKey()));
          }
        }
        config.setStringList(USER, model.username, REPOSITORY, permissions);
      }

      // user preferences
      if (model.getPreferences() != null) {
        List<String> starred =  model.getPreferences().getStarredRepositories();
        if (starred.size() > 0) {
          config.setStringList(USER, model.username, STARRED, starred);
        }
      }
    }

    // write teams
    for (TeamModel model : teams.values()) {
      // team roles
      List<String> roles = new ArrayList<String>();
      if (model.canAdmin) {
        roles.add(Constants.ADMIN_ROLE);
      }
      if (model.canFork) {
        roles.add(Constants.FORK_ROLE);
      }
      if (model.canCreate) {
        roles.add(Constants.CREATE_ROLE);
      }
      if (roles.size() == 0) {
        // we do this to ensure that team record is written.
        // Otherwise, StoredConfig might optimizes that record away.
        roles.add(Constants.NO_ROLE);
      }
      config.setStringList(TEAM, model.name, ROLE, roles);
      if (model.accountType != null) {
        config.setString(TEAM, model.name, ACCOUNTTYPE, model.accountType.name());
      }

      if (!model.canAdmin) {
        // write team permission for non-admin teams
        if (model.permissions == null) {
          // null check on "final" repositories because JSON-sourced TeamModel
          // can have a null repositories object
          if (!ArrayUtils.isEmpty(model.repositories)) {
            config.setStringList(TEAM, model.name, REPOSITORY, new ArrayList<String>(
                model.repositories));
          }
        } else {
          // discrete repository permissions
          List<String> permissions = new ArrayList<String>();
          for (Map.Entry<String, AccessPermission> entry : model.permissions.entrySet()) {
            if (entry.getValue().exceeds(AccessPermission.NONE)) {
              // code:repository (e.g. RW+:~james/myrepo.git
              permissions.add(entry.getValue().asRole(entry.getKey()));
            }
          }
          config.setStringList(TEAM, model.name, REPOSITORY, permissions);
        }
      }

      // null check on "final" users because JSON-sourced TeamModel
      // can have a null users object
      if (!ArrayUtils.isEmpty(model.users)) {
        config.setStringList(TEAM, model.name, USER, new ArrayList<String>(model.users));
      }

      // null check on "final" mailing lists because JSON-sourced
      // TeamModel can have a null users object
      if (!ArrayUtils.isEmpty(model.mailingLists)) {
        config.setStringList(TEAM, model.name, MAILINGLIST, new ArrayList<String>(
            model.mailingLists));
      }

      // null check on "final" preReceiveScripts because JSON-sourced
      // TeamModel can have a null preReceiveScripts object
      if (!ArrayUtils.isEmpty(model.preReceiveScripts)) {
        config.setStringList(TEAM, model.name, PRERECEIVE, model.preReceiveScripts);
      }

      // null check on "final" postReceiveScripts because JSON-sourced
      // TeamModel can have a null postReceiveScripts object
      if (!ArrayUtils.isEmpty(model.postReceiveScripts)) {
        config.setStringList(TEAM, model.name, POSTRECEIVE, model.postReceiveScripts);
      }
    }

    config.save();
    // manually set the forceReload flag because not all JVMs support real
    // millisecond resolution of lastModified. (issue-55)
    forceReload = true;

    // If the write is successful, delete the current file and rename
View Full Code Here

      users.clear();
      cookies.clear();
      teams.clear();

      try {
        StoredConfig config = new FileBasedConfig(realmFile, FS.detect());
        config.load();
        Set<String> usernames = config.getSubsections(USER);
        for (String username : usernames) {
          UserModel user = new UserModel(username.toLowerCase());
          user.password = config.getString(USER, username, PASSWORD);
          user.displayName = config.getString(USER, username, DISPLAYNAME);
          user.emailAddress = config.getString(USER, username, EMAILADDRESS);
          user.accountType = AccountType.fromString(config.getString(USER, username, ACCOUNTTYPE));
          if (Constants.EXTERNAL_ACCOUNT.equals(user.password) && user.accountType.isLocal()) {
            user.accountType = AccountType.EXTERNAL;
          }
          user.disabled = config.getBoolean(USER, username, DISABLED, false);
          user.organizationalUnit = config.getString(USER, username, ORGANIZATIONALUNIT);
          user.organization = config.getString(USER, username, ORGANIZATION);
          user.locality = config.getString(USER, username, LOCALITY);
          user.stateProvince = config.getString(USER, username, STATEPROVINCE);
          user.countryCode = config.getString(USER, username, COUNTRYCODE);
          user.cookie = config.getString(USER, username, COOKIE);
          user.getPreferences().locale = config.getString(USER, username, LOCALE);
          if (StringUtils.isEmpty(user.cookie) && !StringUtils.isEmpty(user.password)) {
            user.cookie = StringUtils.getSHA1(user.username + user.password);
          }

          // user roles
          Set<String> roles = new HashSet<String>(Arrays.asList(config.getStringList(
              USER, username, ROLE)));
          user.canAdmin = roles.contains(Constants.ADMIN_ROLE);
          user.canFork = roles.contains(Constants.FORK_ROLE);
          user.canCreate = roles.contains(Constants.CREATE_ROLE);
          user.excludeFromFederation = roles.contains(Constants.NOT_FEDERATED_ROLE);

          // repository memberships
          if (!user.canAdmin) {
            // non-admin, read permissions
            Set<String> repositories = new HashSet<String>(Arrays.asList(config
                .getStringList(USER, username, REPOSITORY)));
            for (String repository : repositories) {
              user.addRepositoryPermission(repository);
            }
          }

          // starred repositories
          Set<String> starred = new HashSet<String>(Arrays.asList(config
              .getStringList(USER, username, STARRED)));
          for (String repository : starred) {
            UserRepositoryPreferences prefs = user.getPreferences().getRepositoryPreferences(repository);
            prefs.starred = true;
          }

          // update cache
          users.put(user.username, user);
          if (!StringUtils.isEmpty(user.cookie)) {
            cookies.put(user.cookie, user);
          }
        }

        // load the teams
        Set<String> teamnames = config.getSubsections(TEAM);
        for (String teamname : teamnames) {
          TeamModel team = new TeamModel(teamname);
          Set<String> roles = new HashSet<String>(Arrays.asList(config.getStringList(
              TEAM, teamname, ROLE)));
          team.canAdmin = roles.contains(Constants.ADMIN_ROLE);
          team.canFork = roles.contains(Constants.FORK_ROLE);
          team.canCreate = roles.contains(Constants.CREATE_ROLE);
          team.accountType = AccountType.fromString(config.getString(TEAM, teamname, ACCOUNTTYPE));

          if (!team.canAdmin) {
            // non-admin team, read permissions
            team.addRepositoryPermissions(Arrays.asList(config.getStringList(TEAM, teamname,
                REPOSITORY)));
          }
          team.addUsers(Arrays.asList(config.getStringList(TEAM, teamname, USER)));
          team.addMailingLists(Arrays.asList(config.getStringList(TEAM, teamname,
              MAILINGLIST)));
          team.preReceiveScripts.addAll(Arrays.asList(config.getStringList(TEAM,
              teamname, PRERECEIVE)));
          team.postReceiveScripts.addAll(Arrays.asList(config.getStringList(TEAM,
              teamname, POSTRECEIVE)));

          teams.put(team.name.toLowerCase(), team);

          // set the teams on the users
View Full Code Here

      // generate CA & web certificates, create certificate stores
      X509Metadata metadata = new X509Metadata("localhost", params.storePassword);
      // set default certificate values from config file
      if (certificatesConf.exists()) {
        FileBasedConfig config = new FileBasedConfig(certificatesConf, FS.detect());
        try {
          config.load();
        } catch (Exception e) {
          logger.error("Error parsing " + certificatesConf, e);
        }
        NewCertificateConfig certificateConfig = NewCertificateConfig.KEY.parse(config);
        certificateConfig.update(metadata);
      }

      metadata.notAfter = new Date(System.currentTimeMillis() + 10*TimeUtils.ONEYEAR);
      X509Utils.prepareX509Infrastructure(metadata, baseFolder, new X509Log() {
        @Override
        public void log(String message) {
          BufferedWriter writer = null;
          try {
            writer = new BufferedWriter(new FileWriter(new File(baseFolder, X509Utils.CERTS + File.separator + "log.txt"), true));
            writer.write(MessageFormat.format("{0,date,yyyy-MM-dd HH:mm}: {1}", new Date(), message));
            writer.newLine();
            writer.flush();
          } catch (Exception e) {
            LoggerFactory.getLogger(GitblitAuthority.class).error("Failed to append log entry!", e);
          } finally {
            if (writer != null) {
              try {
                writer.close();
              } catch (IOException e) {
              }
            }
          }
        }
      });

      if (serverKeyStore.exists()) {
        /*
         * HTTPS
         */
        logger.info("Setting up HTTPS transport on port " + params.securePort);
        GitblitSslContextFactory factory = new GitblitSslContextFactory(params.alias,
            serverKeyStore, serverTrustStore, params.storePassword, caRevocationList);
        if (params.requireClientCertificates) {
          factory.setNeedClientAuth(true);
        } else {
          factory.setWantClientAuth(true);
        }

        ServerConnector connector = new ServerConnector(server, factory);
        connector.setSoLingerTime(-1);
        connector.setIdleTimeout(30000);
        connector.setPort(params.securePort);
        String bindInterface = settings.getString(Keys.server.httpsBindInterface, null);
        if (!StringUtils.isEmpty(bindInterface)) {
          logger.warn(MessageFormat.format(
              "Binding HTTPS transport on port {0,number,0} to {1}", params.securePort,
              bindInterface));
          connector.setHost(bindInterface);
        }
        if (params.securePort < 1024 && !isWindows()) {
          logger.warn("Gitblit needs to run with ROOT permissions for ports < 1024!");
        }

        server.addConnector(connector);
      } else {
        logger.warn("Failed to find or load Keystore?");
        logger.warn("HTTPS transport DISABLED.");
      }
    }

    // conditionally configure the http transport
    if (params.port > 0) {
      /*
       * HTTP
       */
      logger.info("Setting up HTTP transport on port " + params.port);

      HttpConfiguration httpConfig = new HttpConfiguration();
      if (params.port > 0 && params.securePort > 0 && settings.getBoolean(Keys.server.redirectToHttpsPort, true)) {
        httpConfig.setSecureScheme("https");
        httpConfig.setSecurePort(params.securePort);
      }
          httpConfig.setSendServerVersion(false);
          httpConfig.setSendDateHeader(false);

      ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
      connector.setSoLingerTime(-1);
      connector.setIdleTimeout(30000);
      connector.setPort(params.port);
      String bindInterface = settings.getString(Keys.server.httpBindInterface, null);
      if (!StringUtils.isEmpty(bindInterface)) {
        logger.warn(MessageFormat.format("Binding HTTP transport on port {0,number,0} to {1}",
            params.port, bindInterface));
        connector.setHost(bindInterface);
      }
      if (params.port < 1024 && !isWindows()) {
        logger.warn("Gitblit needs to run with ROOT permissions for ports < 1024!");
      }

      server.addConnector(connector);
    }

    // tempDir is where the embedded Gitblit web application is expanded and
    // where Jetty creates any necessary temporary files
    File tempDir = com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$, baseFolder, params.temp);
    if (tempDir.exists()) {
      try {
        FileUtils.delete(tempDir, FileUtils.RECURSIVE | FileUtils.RETRY);
      } catch (IOException x) {
        logger.warn("Failed to delete temp dir " + tempDir.getAbsolutePath(), x);
      }
    }
    if (!tempDir.mkdirs()) {
      logger.warn("Failed to create temp dir " + tempDir.getAbsolutePath());
    }

    // Get the execution path of this class
    // We use this to set the WAR path.
    ProtectionDomain protectionDomain = GitBlitServer.class.getProtectionDomain();
    URL location = protectionDomain.getCodeSource().getLocation();

    // Root WebApp Context
    WebAppContext rootContext = new WebAppContext();
    rootContext.setContextPath(settings.getString(Keys.server.contextPath, "/"));
    rootContext.setServer(server);
    rootContext.setWar(location.toExternalForm());
    rootContext.setTempDirectory(tempDir);

    // Set cookies HttpOnly so they are not accessible to JavaScript engines
    HashSessionManager sessionManager = new HashSessionManager();
    sessionManager.setHttpOnly(true);
    // Use secure cookies if only serving https
    sessionManager.setSecureRequestOnly(params.port <= 0 && params.securePort > 0);
    rootContext.getSessionHandler().setSessionManager(sessionManager);

    // Ensure there is a defined User Service
    String realmUsers = params.userService;
    if (StringUtils.isEmpty(realmUsers)) {
      logger.error(MessageFormat.format("PLEASE SPECIFY {0}!!", Keys.realm.userService));
      return;
    }

    // Override settings from the command-line
    settings.overrideSetting(Keys.realm.userService, params.userService);
    settings.overrideSetting(Keys.git.repositoriesFolder, params.repositoriesFolder);
    settings.overrideSetting(Keys.git.daemonPort, params.gitPort);
    settings.overrideSetting(Keys.git.sshPort, params.sshPort);

    // Start up an in-memory LDAP server, if configured
    try {
      if (!StringUtils.isEmpty(params.ldapLdifFile)) {
        File ldifFile = new File(params.ldapLdifFile);
        if (ldifFile != null && ldifFile.exists()) {
          URI ldapUrl = new URI(settings.getRequiredString(Keys.realm.ldap.server));
          String firstLine = new Scanner(ldifFile).nextLine();
          String rootDN = firstLine.substring(4);
          String bindUserName = settings.getString(Keys.realm.ldap.username, "");
          String bindPassword = settings.getString(Keys.realm.ldap.password, "");

          // Get the port
          int port = ldapUrl.getPort();
          if (port == -1)
            port = 389;

          InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(rootDN);
          config.addAdditionalBindCredentials(bindUserName, bindPassword);
          config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", port));
          config.setSchema(null);

          InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
          ds.importFromLDIF(true, new LDIFReader(ldifFile));
          ds.startListening();

View Full Code Here

    }
  }

  private StoredConfig getConfig() throws IOException, ConfigInvalidException {
    File configFile  = new File(folder, X509Utils.CA_CONFIG);
    FileBasedConfig config = new FileBasedConfig(configFile, FS.detect());
    config.load();
    return config;
  }
View Full Code Here

        UserModel model = userService.getUserModel(user);
        UserCertificateModel ucm = new UserCertificateModel(model);
        map.put(user, ucm);
      }
      File certificatesConfigFile = new File(folder, X509Utils.CA_CONFIG);
      FileBasedConfig config = new FileBasedConfig(certificatesConfigFile, FS.detect());
      if (certificatesConfigFile.exists()) {
        try {
          config.load();
          // replace user certificate model with actual data
          List<UserCertificateModel> list = UserCertificateConfig.KEY.parse(config).list;
          for (UserCertificateModel ucm : list) {
            ucm.user = userService.getUserModel(ucm.user.username);
            map.put(ucm.user.username, ucm);
View Full Code Here

        File caRevocationList = new File(folder, X509Utils.CA_REVOCATION_LIST);
        File caKeystoreFile = new File(folder, X509Utils.CA_KEY_STORE);
        if (X509Utils.revoke(cert, reason, caRevocationList, caKeystoreFile, caKeystorePassword, GitblitAuthority.this)) {
          File certificatesConfigFile = new File(folder, X509Utils.CA_CONFIG);
          FileBasedConfig config = new FileBasedConfig(certificatesConfigFile, FS.detect());
          if (certificatesConfigFile.exists()) {
            try {
              config.load();
            } catch (Exception e) {
              Utils.showException(GitblitAuthority.this, e);
            }
          }
          // add serial to revoked list
          ucm.revoke(cert.getSerialNumber(), reason);
          ucm.update(config);
          try {
            config.save();
          } catch (Exception e) {
            Utils.showException(GitblitAuthority.this, e);
          }

          // refresh user
          ucm.certs = null;
          int modelIndex = table.convertRowIndexToModel(table.getSelectedRow());
          tableModel.fireTableDataChanged();
          table.getSelectionModel().setSelectionInterval(modelIndex, modelIndex);

          return true;
        }

        return false;
      }
    };

    table = Utils.newTable(tableModel, Utils.DATE_FORMAT);
    table.setRowSorter(defaultSorter);
    table.setDefaultRenderer(CertificateStatus.class, new CertificateStatusRenderer());
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

      @Override
      public void valueChanged(ListSelectionEvent e) {
        if (e.getValueIsAdjusting()) {
          return;
        }
        int row = table.getSelectedRow();
        if (row < 0) {
          return;
        }
        int modelIndex = table.convertRowIndexToModel(row);
        UserCertificateModel ucm = tableModel.get(modelIndex);
        if (ucm.certs == null) {
          ucm.certs = findCerts(folder, ucm.user.username);
        }
        userCertificatePanel.setUserCertificateModel(ucm);
      }
    });

    JPanel usersPanel = new JPanel(new BorderLayout()) {

      private static final long serialVersionUID = 1L;

      @Override
      public Insets getInsets() {
        return Utils.INSETS;
      }
    };
    usersPanel.add(new HeaderPanel(Translation.get("gb.users"), "users_16x16.png"), BorderLayout.NORTH);
    usersPanel.add(new JScrollPane(table), BorderLayout.CENTER);
    usersPanel.setMinimumSize(new Dimension(400, 10));

    certificateDefaultsButton = new JButton(new ImageIcon(getClass().getResource("/settings_16x16.png")));
    certificateDefaultsButton.setFocusable(false);
    certificateDefaultsButton.setToolTipText(Translation.get("gb.newCertificateDefaults"));
    certificateDefaultsButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        X509Metadata metadata = new X509Metadata("whocares", "whocares");
        File certificatesConfigFile = new File(folder, X509Utils.CA_CONFIG);
        FileBasedConfig config = new FileBasedConfig(certificatesConfigFile, FS.detect());
        NewCertificateConfig certificateConfig = null;
        if (certificatesConfigFile.exists()) {
          try {
            config.load();
          } catch (Exception x) {
            Utils.showException(GitblitAuthority.this, x);
          }
          certificateConfig = NewCertificateConfig.KEY.parse(config);
          certificateConfig.update(metadata);
        }
        InputVerifier verifier = new InputVerifier() {
          @Override
          public boolean verify(JComponent comp) {
            boolean returnValue;
            JTextField textField = (JTextField) comp;
            try {
              Integer.parseInt(textField.getText());
              returnValue = true;
            } catch (NumberFormatException e) {
              returnValue = false;
            }
            return returnValue;
          }
        };

        JTextField siteNameTF = new JTextField(20);
        siteNameTF.setText(gitblitSettings.getString(Keys.web.siteName, "Gitblit"));
        JPanel siteNamePanel = Utils.newFieldPanel(Translation.get("gb.siteName"),
            siteNameTF, Translation.get("gb.siteNameDescription"));

        JTextField validityTF = new JTextField(4);
        validityTF.setInputVerifier(verifier);
        validityTF.setVerifyInputWhenFocusTarget(true);
        validityTF.setText("" + certificateConfig.duration);
        JPanel validityPanel = Utils.newFieldPanel(Translation.get("gb.validity"),
            validityTF, Translation.get("gb.duration.days").replace("{0}""").trim());

        JPanel p1 = new JPanel(new GridLayout(0, 1, 5, 2));
        p1.add(siteNamePanel);
        p1.add(validityPanel);

        DefaultOidsPanel oids = new DefaultOidsPanel(metadata);

        JPanel panel = new JPanel(new BorderLayout());
        panel.add(p1, BorderLayout.NORTH);
        panel.add(oids, BorderLayout.CENTER);

        int result = JOptionPane.showConfirmDialog(GitblitAuthority.this,
            panel, Translation.get("gb.newCertificateDefaults"), JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE, new ImageIcon(getClass().getResource("/settings_32x32.png")));
        if (result == JOptionPane.OK_OPTION) {
          try {
            oids.update(metadata);
            certificateConfig.duration = Integer.parseInt(validityTF.getText());
            certificateConfig.store(config, metadata);
            config.save();

            Map<String, String> updates = new HashMap<String, String>();
            updates.put(Keys.web.siteName, siteNameTF.getText());
            gitblitSettings.saveSettings(updates);
          } catch (Exception e1) {
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.storage.file.FileBasedConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.