James Moger
2011-10-20 5ae0b71e1e6e73e4bacf321a7d5be49fcdf4ad97
Properly handle anonymous registrations.
3 files modified
25 ■■■■■ changed files
src/com/gitblit/client/GitblitManager.java 13 ●●●●● patch | view | raw | blame | history
src/com/gitblit/client/GitblitModel.java 4 ●●● patch | view | raw | blame | history
src/com/gitblit/client/GitblitPanel.java 8 ●●●● patch | view | raw | blame | history
src/com/gitblit/client/GitblitManager.java
@@ -316,9 +316,14 @@
                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);
@@ -333,7 +338,7 @@
            StoredConfig config = getConfig();
            config.setString("servers", reg.name, "url", reg.url);
            config.setString("servers", reg.name, "account", reg.account);
            // FIXME this is pretty lame
            // FIXME this is pretty lame
            config.setString("servers", reg.name, "password",
                    Base64.encodeBytes(new String(reg.password).getBytes("UTF-8")));
            config.setString("servers", reg.name, "lastLogin", dateFormat.format(reg.lastLogin));
src/com/gitblit/client/GitblitModel.java
@@ -23,6 +23,7 @@
import java.util.Map;
import com.gitblit.GitBlitException.ForbiddenException;
import com.gitblit.GitBlitException.UnauthorizedException;
import com.gitblit.IStoredSettings;
import com.gitblit.Keys;
import com.gitblit.models.FederationModel;
@@ -68,6 +69,7 @@
            refreshUsers();
            refreshFederationRegistrations();
            isAdmin = true;
        } catch (UnauthorizedException e) {
        } catch (ForbiddenException e) {
        } catch (IOException e) {
            System.err.println(e.getMessage());
@@ -79,7 +81,7 @@
    }
    public boolean isOwner(RepositoryModel model) {
        return account.equalsIgnoreCase(model.owner);
        return account != null && account.equalsIgnoreCase(model.owner);
    }
    public IStoredSettings getSettings() {
src/com/gitblit/client/GitblitPanel.java
@@ -214,10 +214,10 @@
                }
            }
        });
        repositoriesTable.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                if (e.getClickCount() == 2 && gitblit.allowAdmin()) {
                    editRepository(getSelectedRepositories().get(0));
                }
            }
@@ -328,7 +328,7 @@
                delUser.setEnabled(selected);
            }
        });
        usersTable.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
@@ -571,7 +571,7 @@
        gitblit = null;
    }
    protected void refreshRepositories() {
    protected void refreshRepositories() {
        GitblitWorker worker = new GitblitWorker(GitblitPanel.this, RpcRequest.LIST_REPOSITORIES) {
            @Override
            protected Boolean doRequest() throws IOException {