Esempio n. 1
0
 /**
  * Returns the list of all users available to the login service.
  *
  * @return list of all usernames
  */
 @Override
 public List<String> getAllUsernames() {
   List<String> names = new ArrayList<String>(userService.getAllUsernames());
   return names;
 }
Esempio n. 2
0
  private void load(File folder) {
    this.folder = folder;
    this.userService = loadUsers(folder);
    System.out.println(Constants.baseFolder$ + " set to " + folder);
    if (userService == null) {
      JOptionPane.showMessageDialog(
          this,
          MessageFormat.format("Sorry, {0} doesn't look like a Gitblit GO installation.", folder));
    } else {
      // build empty certificate model for all users
      Map<String, UserCertificateModel> map = new HashMap<String, UserCertificateModel>();
      for (String user : userService.getAllUsernames()) {
        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);
          }
        } catch (IOException e) {
          e.printStackTrace();
        } catch (ConfigInvalidException e) {
          e.printStackTrace();
        }
      }

      tableModel.list = new ArrayList<UserCertificateModel>(map.values());
      Collections.sort(tableModel.list);
      tableModel.fireTableDataChanged();
      Utils.packColumns(table, Utils.MARGIN);

      File caKeystore = new File(folder, X509Utils.CA_KEY_STORE);
      if (!caKeystore.exists()) {

        if (!X509Utils.unlimitedStrength) {
          // prompt to confirm user understands JCE Standard Strength encryption
          int res =
              JOptionPane.showConfirmDialog(
                  GitblitAuthority.this,
                  Translation.get("gb.jceWarning"),
                  Translation.get("gb.warning"),
                  JOptionPane.YES_NO_OPTION,
                  JOptionPane.WARNING_MESSAGE);
          if (res != JOptionPane.YES_OPTION) {
            if (Desktop.isDesktopSupported()) {
              if (Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
                try {
                  Desktop.getDesktop()
                      .browse(
                          URI.create(
                              "http://www.oracle.com/technetwork/java/javase/downloads/index.html"));
                } catch (IOException e) {
                }
              }
            }
            System.exit(1);
          }
        }

        // show certificate defaults dialog
        certificateDefaultsButton.doClick();

        // create "localhost" ssl certificate
        prepareX509Infrastructure();
      }
    }
  }