]> source.dussan.org Git - gitblit.git/commitdiff
Added cookie suport
authormallowlabs <mallowlabs@gmail.com>
Sat, 8 Sep 2012 14:50:47 +0000 (23:50 +0900)
committermallowlabs <mallowlabs@gmail.com>
Sat, 8 Sep 2012 14:50:51 +0000 (23:50 +0900)
src/com/gitblit/RedmineUserService.java
tests/com/gitblit/tests/RedmineUserServiceTest.java

index 6ff61c7310bae577b7fbd6e1dbae6b9935bdaddd..47bb80a55dc676aa65eeaa10fb7d953510d9839c 100644 (file)
@@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory;
 \r
 import com.gitblit.models.UserModel;\r
 import com.gitblit.utils.ConnectionUtils;\r
+import com.gitblit.utils.StringUtils;\r
 import com.google.gson.Gson;\r
 \r
 /**\r
@@ -71,11 +72,6 @@ public class RedmineUserService extends GitblitUserService {
         return false;\r
     }\r
 \r
-    @Override\r
-    public boolean supportsCookies() {\r
-        return false;\r
-    }\r
-\r
     @Override\r
     public UserModel authenticate(String username, char[] password) {\r
         String urlText = this.settings.getString(Keys.realm.redmine.url, "");\r
@@ -95,6 +91,7 @@ public class RedmineUserService extends GitblitUserService {
                 userModel.displayName = current.user.firstname + " " + current.user.lastname;\r
                 userModel.emailAddress = current.user.mail;\r
                 userModel.canAdmin = true;\r
+                userModel.cookie = StringUtils.getSHA1(userModel.username + new String(password));\r
                 return userModel;\r
             }\r
 \r
index a6a8a5ebe414e17373d29b99aa9b084d80b47df0..0ba58ec59e64465f1c210bebc9cd8b75eb02d37f 100644 (file)
@@ -1,6 +1,7 @@
 package com.gitblit.tests;\r
 \r
 import static org.hamcrest.CoreMatchers.is;\r
+import static org.junit.Assert.assertNotNull;\r
 import static org.junit.Assert.assertNull;\r
 import static org.junit.Assert.assertThat;\r
 \r
@@ -27,6 +28,7 @@ public class RedmineUserServiceTest {
         assertThat(userModel.getName(), is("RedmineUserId"));\r
         assertThat(userModel.getDisplayName(), is("baz foo"));\r
         assertThat(userModel.emailAddress, is("baz@example.com"));\r
+        assertNotNull(userModel.cookie);\r
     }\r
 \r
     @Test\r