From c658df9e87d65b08d5482cf04489cb0532ff83dd Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Sat, 13 Oct 2012 10:50:35 -0400
Subject: [PATCH] Merge branch 'master' of https://github.com/Mrbytes/gitblit

---
 src/com/gitblit/client/EditRepositoryDialog.java |   67 ++++++++++++++++++++++++++++++---
 1 files changed, 60 insertions(+), 7 deletions(-)

diff --git a/src/com/gitblit/client/EditRepositoryDialog.java b/src/com/gitblit/client/EditRepositoryDialog.java
index f6a315b..e15b154 100644
--- a/src/com/gitblit/client/EditRepositoryDialog.java
+++ b/src/com/gitblit/client/EditRepositoryDialog.java
@@ -35,6 +35,7 @@
 import java.util.Set;
 
 import javax.swing.BoxLayout;
+import javax.swing.ButtonGroup;
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.ImageIcon;
 import javax.swing.JButton;
@@ -46,6 +47,7 @@
 import javax.swing.JList;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
+import javax.swing.JRadioButton;
 import javax.swing.JRootPane;
 import javax.swing.JScrollPane;
 import javax.swing.JTabbedPane;
@@ -55,6 +57,7 @@
 import javax.swing.ScrollPaneConstants;
 
 import com.gitblit.Constants.AccessRestrictionType;
+import com.gitblit.Constants.AuthorizationControl;
 import com.gitblit.Constants.FederationStrategy;
 import com.gitblit.models.RepositoryModel;
 import com.gitblit.utils.ArrayUtils;
@@ -98,6 +101,14 @@
 	private JTextField mailingListsField;
 
 	private JComboBox accessRestriction;
+	
+	private JRadioButton allowAuthenticated;
+	
+	private JRadioButton allowNamed;
+	
+	private JCheckBox allowForks;
+
+	private JCheckBox verifyCommitter;
 
 	private JComboBox federationStrategy;
 
@@ -206,6 +217,24 @@
 		accessRestriction = new JComboBox(AccessRestrictionType.values());
 		accessRestriction.setRenderer(new AccessRestrictionRenderer());
 		accessRestriction.setSelectedItem(anRepository.accessRestriction);
+		
+		boolean authenticated = anRepository.authorizationControl != null 
+				&& AuthorizationControl.AUTHENTICATED.equals(anRepository.authorizationControl);
+		allowAuthenticated = new JRadioButton(Translation.get("gb.allowAuthenticatedDescription"));
+		allowAuthenticated.setSelected(authenticated);
+		allowNamed = new JRadioButton(Translation.get("gb.allowNamedDescription"));
+		allowNamed.setSelected(!authenticated);
+		
+		ButtonGroup group = new ButtonGroup();
+		group.add(allowAuthenticated);
+		group.add(allowNamed);
+		
+		JPanel authorizationPanel = new JPanel(new GridLayout(0, 1));
+		authorizationPanel.add(allowAuthenticated);
+		authorizationPanel.add(allowNamed);
+		
+		allowForks = new JCheckBox(Translation.get("gb.allowForksDescription"), anRepository.allowForks);
+		verifyCommitter = new JCheckBox(Translation.get("gb.verifyCommitterDescription"), anRepository.verifyCommitter);
 
 		// federation strategies - remove ORIGIN choice if this repository has
 		// no origin.
@@ -240,18 +269,28 @@
 						skipSizeCalculation));
 		fieldsPanel.add(newFieldPanel(Translation.get("gb.skipSummaryMetrics"),
 				skipSummaryMetrics));
-		fieldsPanel
-				.add(newFieldPanel(Translation.get("gb.isFrozen"), isFrozen));
 		fieldsPanel.add(newFieldPanel(Translation.get("gb.mailingLists"),
 				mailingListsField));
 
+		JPanel clonePushPanel = new JPanel(new GridLayout(0, 1));
+		clonePushPanel
+		.add(newFieldPanel(Translation.get("gb.isFrozen"), isFrozen));
+		clonePushPanel
+		.add(newFieldPanel(Translation.get("gb.allowForks"), allowForks));
+		clonePushPanel
+		.add(newFieldPanel(Translation.get("gb.verifyCommitter"), verifyCommitter));
+
 		usersPalette = new JPalette<String>();
+		JPanel northAccessPanel = new JPanel(new BorderLayout(5, 5));
+		northAccessPanel.add(newFieldPanel(Translation.get("gb.accessRestriction"),
+				accessRestriction), BorderLayout.NORTH);
+		northAccessPanel.add(newFieldPanel(Translation.get("gb.authorizationControl"),
+				authorizationPanel), BorderLayout.CENTER);
+		northAccessPanel.add(clonePushPanel, BorderLayout.SOUTH);
+
 		JPanel accessPanel = new JPanel(new BorderLayout(5, 5));
-		accessPanel.add(
-				newFieldPanel(Translation.get("gb.accessRestriction"),
-						accessRestriction), BorderLayout.NORTH);
-		accessPanel.add(
-				newFieldPanel(Translation.get("gb.permittedUsers"),
+		accessPanel.add(northAccessPanel, BorderLayout.NORTH);
+		accessPanel.add(newFieldPanel(Translation.get("gb.permittedUsers"),
 						usersPalette), BorderLayout.CENTER);
 
 		teamsPalette = new JPalette<String>();
@@ -389,6 +428,9 @@
 			error("Relative folder references (../) are prohibited.");
 			return false;
 		}
+		if (rname.endsWith("/")) {
+			rname = rname.substring(0, rname.length() - 1);
+		}
 
 		// confirm valid characters in repository name
 		Character c = StringUtils.findInvalidCharacter(rname);
@@ -444,7 +486,10 @@
 		repository.showReadme = showReadme.isSelected();
 		repository.skipSizeCalculation = skipSizeCalculation.isSelected();
 		repository.skipSummaryMetrics = skipSummaryMetrics.isSelected();
+		
 		repository.isFrozen = isFrozen.isSelected();
+		repository.allowForks = allowForks.isSelected();
+		repository.verifyCommitter = verifyCommitter.isSelected();
 
 		String ml = mailingListsField.getText();
 		if (!StringUtils.isEmpty(ml)) {
@@ -460,6 +505,8 @@
 
 		repository.accessRestriction = (AccessRestrictionType) accessRestriction
 				.getSelectedItem();
+		repository.authorizationControl = allowAuthenticated.isSelected() ? 
+				AuthorizationControl.AUTHENTICATED : AuthorizationControl.NAMED;
 		repository.federationStrategy = (FederationStrategy) federationStrategy
 				.getSelectedItem();
 
@@ -492,6 +539,12 @@
 		this.accessRestriction.setSelectedItem(restriction);
 	}
 
+	public void setAuthorizationControl(AuthorizationControl authorization) {
+		boolean authenticated = authorization != null && AuthorizationControl.AUTHENTICATED.equals(authorization);
+		this.allowAuthenticated.setSelected(authenticated);
+		this.allowNamed.setSelected(!authenticated);
+	}
+
 	public void setUsers(String owner, List<String> all, List<String> selected) {
 		ownerField.setModel(new DefaultComboBoxModel(all.toArray()));
 		if (!StringUtils.isEmpty(owner)) {

--
Gitblit v1.9.1