From 8427e93f25fb79bc39dbd31ce13fab637e7cfdff Mon Sep 17 00:00:00 2001
From: Jeroen Baten <jeroen@jeroenbaten.nl>
Date: Fri, 04 Jan 2013 11:34:24 -0500
Subject: [PATCH] Completed Dutch translation
---
src/com/gitblit/RedmineUserService.java | 30 ++++++++++++++++--------------
1 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/src/com/gitblit/RedmineUserService.java b/src/com/gitblit/RedmineUserService.java
index 93d1af8..b890f21 100644
--- a/src/com/gitblit/RedmineUserService.java
+++ b/src/com/gitblit/RedmineUserService.java
@@ -4,13 +4,14 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
-import java.net.URL;
import org.apache.wicket.util.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.gitblit.models.UserModel;
+import com.gitblit.utils.ConnectionUtils;
+import com.gitblit.utils.StringUtils;
import com.google.gson.Gson;
/**
@@ -72,11 +73,6 @@
}
@Override
- public boolean supportsCookies() {
- return false;
- }
-
- @Override
public UserModel authenticate(String username, char[] password) {
String urlText = this.settings.getString(Keys.realm.redmine.url, "");
if (!urlText.endsWith("/")) {
@@ -90,14 +86,20 @@
RedmineCurrent current = new Gson().fromJson(jsonString, RedmineCurrent.class);
String login = current.user.login;
- if (username.equalsIgnoreCase(login)) {
- UserModel userModel = new UserModel(login);
- userModel.displayName = current.user.firstname + " " + current.user.lastname;
- userModel.emailAddress = current.user.mail;
- userModel.canAdmin = true;
- return userModel;
+ boolean canAdmin = true;
+ // non admin user can not get login name
+ if (StringUtils.isEmpty(login)) {
+ canAdmin = false;
+ login = current.user.mail;
}
+ UserModel userModel = new UserModel(login);
+ userModel.canAdmin = canAdmin;
+ userModel.displayName = current.user.firstname + " " + current.user.lastname;
+ userModel.emailAddress = current.user.mail;
+ userModel.cookie = StringUtils.getSHA1(userModel.username + new String(password));
+
+ return userModel;
} catch (IOException e) {
logger.error("authenticate", e);
}
@@ -109,8 +111,8 @@
return testingJson;
}
- URL apiUrl = new URL(url + "users/current.json?key=" + apiKey);
- HttpURLConnection http = (HttpURLConnection) apiUrl.openConnection();
+ String apiUrl = url + "users/current.json?key=" + apiKey;
+ HttpURLConnection http = (HttpURLConnection) ConnectionUtils.openConnection(apiUrl, null, null);
http.setRequestMethod("GET");
http.connect();
InputStreamReader reader = new InputStreamReader(http.getInputStream());
--
Gitblit v1.9.1