Merge branch 'stable-2.11'

* stable-2.11:
  Fix non-ascii password authentication failure under tomcat (LDAP)
  Allow InternalUsers to see drafts

Change-Id: Ic81a825c8063b8e1e272f6d25d4a2730b3ee9058
This commit is contained in:
David Pursehouse 2015-10-09 22:06:33 +09:00
commit 5bc2e1c115
4 changed files with 16 additions and 1 deletions

View File

@ -14,6 +14,8 @@
package com.google.gerrit.httpd.auth.ldap; package com.google.gerrit.httpd.auth.ldap;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
@ -106,6 +108,7 @@ class LdapLoginServlet extends HttpServlet {
@Override @Override
protected void doPost(HttpServletRequest req, HttpServletResponse res) protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException { throws ServletException, IOException {
req.setCharacterEncoding(UTF_8.name());
String username = Strings.nullToEmpty(req.getParameter("username")).trim(); String username = Strings.nullToEmpty(req.getParameter("username")).trim();
String password = Strings.nullToEmpty(req.getParameter("password")); String password = Strings.nullToEmpty(req.getParameter("password"));
String remember = Strings.nullToEmpty(req.getParameter("rememberme")); String remember = Strings.nullToEmpty(req.getParameter("rememberme"));

View File

@ -100,4 +100,9 @@ public abstract class CurrentUser {
public boolean isIdentifiedUser() { public boolean isIdentifiedUser() {
return false; return false;
} }
/** Check if the CurrentUser is an InternalUser. */
public boolean isInternalUser() {
return false;
}
} }

View File

@ -61,6 +61,11 @@ public class InternalUser extends CurrentUser {
return Collections.emptySet(); return Collections.emptySet();
} }
@Override
public boolean isInternalUser() {
return true;
}
@Override @Override
public String toString() { public String toString() {
return "InternalUser"; return "InternalUser";

View File

@ -28,6 +28,7 @@ import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.InternalUser;
import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeData;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
@ -352,6 +353,7 @@ public class ChangeControl {
public boolean isDraftVisible(ReviewDb db, ChangeData cd) public boolean isDraftVisible(ReviewDb db, ChangeData cd)
throws OrmException { throws OrmException {
return isOwner() || isReviewer(db, cd) || getRefControl().canViewDrafts(); return isOwner() || isReviewer(db, cd) || getRefControl().canViewDrafts()
|| getCurrentUser().isInternalUser();
} }
} }