From 579cdd4a691adbbe89f85ce679502cf5d1f045d0 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 28 Nov 2012 17:09:45 -0500
Subject: [PATCH] Fixed missing format call for certificate authentication logging

---
 src/com/gitblit/wicket/pages/BasePage.java |   68 ++++++++++++++++++++++++++++++---
 1 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/src/com/gitblit/wicket/pages/BasePage.java b/src/com/gitblit/wicket/pages/BasePage.java
index 4d37611..05640ad 100644
--- a/src/com/gitblit/wicket/pages/BasePage.java
+++ b/src/com/gitblit/wicket/pages/BasePage.java
@@ -15,6 +15,7 @@
  */
 package com.gitblit.wicket.pages;
 
+import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Collections;
@@ -52,7 +53,9 @@
 import org.slf4j.LoggerFactory;
 
 import com.gitblit.Constants;
+import com.gitblit.Constants.AccessPermission;
 import com.gitblit.Constants.AccessRestrictionType;
+import com.gitblit.Constants.AuthorizationControl;
 import com.gitblit.Constants.FederationStrategy;
 import com.gitblit.GitBlit;
 import com.gitblit.Keys;
@@ -128,13 +131,16 @@
 	}	
 
 	private void login() {
-		Cookie[] cookies = ((WebRequest) getRequestCycle().getRequest()).getCookies();
-		UserModel user = null;
-		if (GitBlit.self().allowCookieAuthentication() && cookies != null && cookies.length > 0) {
-			// Grab cookie from Browser Session
-			user = GitBlit.self().authenticate(cookies);
-		} else {
-			user = GitBlit.self().authenticate(((WebRequest) getRequestCycle().getRequest()).getHttpServletRequest());
+		// try to authenticate by servlet request
+		UserModel user = GitBlit.self().authenticate(((WebRequest) getRequestCycle().getRequest()).getHttpServletRequest());
+
+		if (user == null) {
+			// try to authenticate by cookie
+			Cookie[] cookies = ((WebRequest) getRequestCycle().getRequest()).getCookies();
+			if (GitBlit.self().allowCookieAuthentication() && cookies != null && cookies.length > 0) {
+				// Grab cookie from Browser Session
+				user = GitBlit.self().authenticate(cookies);
+			}
 		}
 
 		// Login the user
@@ -203,6 +209,39 @@
 		return map;
 	}
 	
+	protected Map<AccessPermission, String> getAccessPermissions() {
+		Map<AccessPermission, String> map = new LinkedHashMap<AccessPermission, String>();
+		for (AccessPermission type : AccessPermission.values()) {
+			switch (type) {
+			case NONE:
+				map.put(type, MessageFormat.format(getString("gb.noPermission"), type.code));
+				break;
+			case EXCLUDE:
+				map.put(type, MessageFormat.format(getString("gb.excludePermission"), type.code));
+				break;
+			case VIEW:
+				map.put(type, MessageFormat.format(getString("gb.viewPermission"), type.code));
+				break;
+			case CLONE:
+				map.put(type, MessageFormat.format(getString("gb.clonePermission"), type.code));
+				break;
+			case PUSH:
+				map.put(type, MessageFormat.format(getString("gb.pushPermission"), type.code));
+				break;
+			case CREATE:
+				map.put(type, MessageFormat.format(getString("gb.createPermission"), type.code));
+				break;
+			case DELETE:
+				map.put(type, MessageFormat.format(getString("gb.deletePermission"), type.code));
+				break;
+			case REWIND:
+				map.put(type, MessageFormat.format(getString("gb.rewindPermission"), type.code));
+				break;
+			}
+		}
+		return map;
+	}
+	
 	protected Map<FederationStrategy, String> getFederationTypes() {
 		Map<FederationStrategy, String> map = new LinkedHashMap<FederationStrategy, String>();
 		for (FederationStrategy type : FederationStrategy.values()) {
@@ -220,6 +259,21 @@
 		}
 		return map;
 	}
+	
+	protected Map<AuthorizationControl, String> getAuthorizationControls() {
+		Map<AuthorizationControl, String> map = new LinkedHashMap<AuthorizationControl, String>();
+		for (AuthorizationControl type : AuthorizationControl.values()) {
+			switch (type) {
+			case AUTHENTICATED:
+				map.put(type, getString("gb.allowAuthenticatedDescription"));
+				break;
+			case NAMED:
+				map.put(type, getString("gb.allowNamedDescription"));
+				break;
+			}
+		}
+		return map;
+	}
 
 	protected TimeZone getTimeZone() {
 		return GitBlit.getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get()

--
Gitblit v1.9.1