]> source.dussan.org Git - gitblit.git/commitdiff
Properly handle anonymous registrations.
authorJames Moger <james.moger@gitblit.com>
Thu, 20 Oct 2011 12:01:54 +0000 (08:01 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 20 Oct 2011 12:01:54 +0000 (08:01 -0400)
src/com/gitblit/client/GitblitManager.java
src/com/gitblit/client/GitblitModel.java
src/com/gitblit/client/GitblitPanel.java

index e5b6b43bcaae8e2f9d3beb4f37a5dcfd7897b43c..43cdab36d411ca3796b4e01ef37de51c0bfaa7fb 100644 (file)
@@ -316,9 +316,14 @@ public class GitblitManager extends JFrame implements RegistrationsDialog.Regist
                                Date lastLogin = dateFormat.parse(config.getString("servers", server, "lastLogin"));\r
                                String url = config.getString("servers", server, "url");\r
                                String account = config.getString("servers", server, "account");\r
-                               // FIXME this is pretty lame\r
-                               char[] password = new String(Base64.decode(config.getString("servers", server,\r
-                                               "password"))).toCharArray();\r
+                               char[] password;\r
+                               String pw = config.getString("servers", server, "password");\r
+                               if (StringUtils.isEmpty(pw)) {\r
+                                       password = new char[0];\r
+                               } else {\r
+                                       // FIXME this is pretty lame\r
+                                       password = new String(Base64.decode(pw)).toCharArray();\r
+                               }\r
                                GitblitRegistration reg = new GitblitRegistration(server, url, account, password);\r
                                reg.lastLogin = lastLogin;\r
                                registrations.put(reg.name, reg);\r
@@ -333,7 +338,7 @@ public class GitblitManager extends JFrame implements RegistrationsDialog.Regist
                        StoredConfig config = getConfig();\r
                        config.setString("servers", reg.name, "url", reg.url);\r
                        config.setString("servers", reg.name, "account", reg.account);\r
-                       // FIXME this is pretty lame\r
+                       // FIXME this is pretty lame                    \r
                        config.setString("servers", reg.name, "password",\r
                                        Base64.encodeBytes(new String(reg.password).getBytes("UTF-8")));\r
                        config.setString("servers", reg.name, "lastLogin", dateFormat.format(reg.lastLogin));\r
index 92b0b1cee2053c88c355d625a937bf4ba0062e5e..22d67f62e21d3e063cb85a2998f3e08c794dbdd3 100644 (file)
@@ -23,6 +23,7 @@ import java.util.List;
 import java.util.Map;\r
 \r
 import com.gitblit.GitBlitException.ForbiddenException;\r
+import com.gitblit.GitBlitException.UnauthorizedException;\r
 import com.gitblit.IStoredSettings;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.FederationModel;\r
@@ -68,6 +69,7 @@ public class GitblitModel implements Serializable {
                        refreshUsers();\r
                        refreshFederationRegistrations();\r
                        isAdmin = true;\r
+               } catch (UnauthorizedException e) {\r
                } catch (ForbiddenException e) {\r
                } catch (IOException e) {\r
                        System.err.println(e.getMessage());\r
@@ -79,7 +81,7 @@ public class GitblitModel implements Serializable {
        }\r
 \r
        public boolean isOwner(RepositoryModel model) {\r
-               return account.equalsIgnoreCase(model.owner);\r
+               return account != null && account.equalsIgnoreCase(model.owner);\r
        }\r
 \r
        public IStoredSettings getSettings() {\r
index 5e7cfe1019160cf636eeb5030c3f6bbf223e80c1..f0d04b731272af70f998c5c539b6dabe2ca88872 100644 (file)
@@ -214,10 +214,10 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                                }\r
                        }\r
                });\r
-               \r
+\r
                repositoriesTable.addMouseListener(new MouseAdapter() {\r
                        public void mouseClicked(MouseEvent e) {\r
-                               if (e.getClickCount() == 2) {\r
+                               if (e.getClickCount() == 2 && gitblit.allowAdmin()) {\r
                                        editRepository(getSelectedRepositories().get(0));\r
                                }\r
                        }\r
@@ -328,7 +328,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                                delUser.setEnabled(selected);\r
                        }\r
                });\r
-               \r
+\r
                usersTable.addMouseListener(new MouseAdapter() {\r
                        public void mouseClicked(MouseEvent e) {\r
                                if (e.getClickCount() == 2) {\r
@@ -571,7 +571,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
                gitblit = null;\r
        }\r
 \r
-       protected void refreshRepositories() {          \r
+       protected void refreshRepositories() {\r
                GitblitWorker worker = new GitblitWorker(GitblitPanel.this, RpcRequest.LIST_REPOSITORIES) {\r
                        @Override\r
                        protected Boolean doRequest() throws IOException {\r