Consolidate base64 encoding/decoding to use Guava's BaseEncoding
Replace usage of Java's, JGit's and Apache Commons' Base64 classes with BaseEncoding from Guava. No Gerrit code directly depends on Apache Commons Codec any more, so we can remove all the explicit dependencies from the build rules. However, it is still a transient dependency of the httpclient library, and is used by some plugins, so we can't completely remove it from the build. Change-Id: I9a934bda3e4519f359759b20efb298d544f1391b
This commit is contained in:
@@ -22,6 +22,7 @@ import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.io.BaseEncoding;
|
||||
import com.google.gerrit.entities.Account;
|
||||
import com.google.gerrit.extensions.auth.oauth.OAuthLoginProvider;
|
||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||
@@ -53,7 +54,6 @@ import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpServletResponseWrapper;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
|
||||
/**
|
||||
@@ -225,7 +225,7 @@ class ProjectOAuthFilter implements Filter {
|
||||
|
||||
private AuthInfo extractAuthInfo(String hdr, String encoding)
|
||||
throws UnsupportedEncodingException {
|
||||
byte[] decoded = Base64.decodeBase64(hdr.substring(BASIC.length()));
|
||||
byte[] decoded = BaseEncoding.base64().decode(hdr.substring(BASIC.length()));
|
||||
String usernamePassword = new String(decoded, encoding);
|
||||
int splitPos = usernamePassword.indexOf(':');
|
||||
if (splitPos < 1 || splitPos == usernamePassword.length() - 1) {
|
||||
|
Reference in New Issue
Block a user