From 8a8bc3dc1bc810cef952a12071b6ec7dd8ff9750 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Mon, 20 Oct 2014 09:33:07 -0400
Subject: [PATCH] Prepare v1.6.1 documentation updates
---
src/main/java/com/gitblit/auth/RedmineAuthProvider.java | 21 ++++++++-------------
1 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/gitblit/auth/RedmineAuthProvider.java b/src/main/java/com/gitblit/auth/RedmineAuthProvider.java
index 176c576..ae4f28e 100644
--- a/src/main/java/com/gitblit/auth/RedmineAuthProvider.java
+++ b/src/main/java/com/gitblit/auth/RedmineAuthProvider.java
@@ -19,14 +19,13 @@
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
-import org.apache.wicket.util.io.IOUtils;
+import org.apache.commons.io.IOUtils;
import com.gitblit.Constants;
import com.gitblit.Constants.AccountType;
import com.gitblit.Keys;
import com.gitblit.auth.AuthenticationProvider.UsernamePasswordAuthenticationProvider;
import com.gitblit.models.UserModel;
-import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.ConnectionUtils;
import com.gitblit.utils.StringUtils;
import com.google.gson.Gson;
@@ -122,24 +121,19 @@
}
UserModel user = userManager.getUserModel(username);
- if (user == null) // create user object for new authenticated user
+ if (user == null) {
+ // create user object for new authenticated user
user = new UserModel(username.toLowerCase());
+ }
// create a user cookie
- if (StringUtils.isEmpty(user.cookie) && !ArrayUtils.isEmpty(password)) {
- user.cookie = StringUtils.getSHA1(user.username + new String(password));
- }
+ setCookie(user, password);
// update user attributes from Redmine
user.accountType = getAccountType();
user.displayName = current.user.firstname + " " + current.user.lastname;
user.emailAddress = current.user.mail;
user.password = Constants.EXTERNAL_ACCOUNT;
- if (!StringUtils.isEmpty(current.user.login)) {
- // only admin users can get login name
- // evidently this is an undocumented behavior of Redmine
- user.canAdmin = true;
- }
// TODO consider Redmine group mapping for team membership
// http://www.redmine.org/projects/redmine/wiki/Rest_Users
@@ -159,15 +153,16 @@
if (!url.endsWith("/")) {
url = url.concat("/");
}
+ String apiUrl = url + "users/current.json";
+
HttpURLConnection http;
if (username == null) {
// apikey authentication
String apiKey = String.valueOf(password);
- String apiUrl = url + "users/current.json?key=" + apiKey;
http = (HttpURLConnection) ConnectionUtils.openConnection(apiUrl, null, null);
+ http.addRequestProperty("X-Redmine-API-Key", apiKey);
} else {
// username/password BASIC authentication
- String apiUrl = url + "users/current.json";
http = (HttpURLConnection) ConnectionUtils.openConnection(apiUrl, username, password);
}
http.setRequestMethod("GET");
--
Gitblit v1.9.1