| | |
| | | import java.awt.event.WindowEvent;
|
| | | import java.io.File;
|
| | | import java.io.IOException;
|
| | | import java.net.ConnectException;
|
| | | import java.text.MessageFormat;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | |
| | | passwordField.getPassword());
|
| | | if (!StringUtils.isEmpty(originalName) && !originalName.equals(reg.name)) {
|
| | | // delete old registration
|
| | | registrations.remove(originalName);
|
| | | try {
|
| | | StoredConfig config = getConfig();
|
| | | config.unsetSection("servers", originalName);
|
| | |
| | | registrations.put(reg.name, reg);
|
| | | rebuildRecentMenu();
|
| | | } catch (Throwable t) {
|
| | | Utils.showException(GitblitManager.this, t);
|
| | | Throwable cause = t.getCause();
|
| | | if (cause instanceof ConnectException) {
|
| | | JOptionPane.showMessageDialog(GitblitManager.this, cause.getMessage(),
|
| | | Translation.get("gb.error"), JOptionPane.ERROR_MESSAGE);
|
| | | } else {
|
| | | Utils.showException(GitblitManager.this, t);
|
| | | }
|
| | | } finally {
|
| | | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
| | | }
|
| | |
| | | if (list.size() > maxRecentCount) {
|
| | | list = list.subList(0, maxRecentCount);
|
| | | }
|
| | | for (final GitblitRegistration reg : list) {
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | final GitblitRegistration reg = list.get(i);
|
| | | JMenuItem item = new JMenuItem(reg.name, icon);
|
| | | item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1 + i, KeyEvent.CTRL_DOWN_MASK,
|
| | | false));
|
| | | item.addActionListener(new ActionListener() {
|
| | | public void actionPerformed(ActionEvent e) {
|
| | | login(reg);
|
| | |
| | | Date lastLogin = dateFormat.parse(config.getString("servers", server, "lastLogin"));
|
| | | String url = config.getString("servers", server, "url");
|
| | | String account = config.getString("servers", server, "account");
|
| | | // FIXME this is pretty lame
|
| | | char[] password = new String(Base64.decode(config.getString("servers", server,
|
| | | "password"))).toCharArray();
|
| | | char[] password;
|
| | | String pw = config.getString("servers", server, "password");
|
| | | if (StringUtils.isEmpty(pw)) {
|
| | | password = new char[0];
|
| | | } else {
|
| | | // FIXME this is pretty lame
|
| | | password = new String(Base64.decode(pw)).toCharArray();
|
| | | }
|
| | | GitblitRegistration reg = new GitblitRegistration(server, url, account, password);
|
| | | reg.lastLogin = lastLogin;
|
| | | registrations.put(reg.name, reg);
|
| | |
| | | StoredConfig config = getConfig();
|
| | | for (GitblitRegistration reg : list) {
|
| | | config.unsetSection("servers", reg.name);
|
| | | registrations.remove(reg.name);
|
| | | }
|
| | | config.save();
|
| | | success = true;
|