From: James Moger Date: Thu, 20 Oct 2011 12:01:54 +0000 (-0400) Subject: Properly handle anonymous registrations. X-Git-Tag: v0.7.0~67 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5ae0b71e1e6e73e4bacf321a7d5be49fcdf4ad97;p=gitblit.git Properly handle anonymous registrations. --- diff --git a/src/com/gitblit/client/GitblitManager.java b/src/com/gitblit/client/GitblitManager.java index e5b6b43b..43cdab36 100644 --- a/src/com/gitblit/client/GitblitManager.java +++ b/src/com/gitblit/client/GitblitManager.java @@ -316,9 +316,14 @@ public class GitblitManager extends JFrame implements RegistrationsDialog.Regist 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 @@ public class GitblitManager extends JFrame implements RegistrationsDialog.Regist 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)); diff --git a/src/com/gitblit/client/GitblitModel.java b/src/com/gitblit/client/GitblitModel.java index 92b0b1ce..22d67f62 100644 --- a/src/com/gitblit/client/GitblitModel.java +++ b/src/com/gitblit/client/GitblitModel.java @@ -23,6 +23,7 @@ import java.util.List; 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 @@ public class GitblitModel implements Serializable { refreshUsers(); refreshFederationRegistrations(); isAdmin = true; + } catch (UnauthorizedException e) { } catch (ForbiddenException e) { } catch (IOException e) { System.err.println(e.getMessage()); @@ -79,7 +81,7 @@ public class GitblitModel implements Serializable { } public boolean isOwner(RepositoryModel model) { - return account.equalsIgnoreCase(model.owner); + return account != null && account.equalsIgnoreCase(model.owner); } public IStoredSettings getSettings() { diff --git a/src/com/gitblit/client/GitblitPanel.java b/src/com/gitblit/client/GitblitPanel.java index 5e7cfe10..f0d04b73 100644 --- a/src/com/gitblit/client/GitblitPanel.java +++ b/src/com/gitblit/client/GitblitPanel.java @@ -214,10 +214,10 @@ public class GitblitPanel extends JPanel implements CloseTabListener { } } }); - + 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 @@ public class GitblitPanel extends JPanel implements CloseTabListener { delUser.setEnabled(selected); } }); - + usersTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { @@ -571,7 +571,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener { gitblit = null; } - protected void refreshRepositories() { + protected void refreshRepositories() { GitblitWorker worker = new GitblitWorker(GitblitPanel.this, RpcRequest.LIST_REPOSITORIES) { @Override protected Boolean doRequest() throws IOException {