Просмотр исходного кода

Decode cookie once in AbstractRememberMeServices

Issue gh-9192
zhuang 4 лет назад
Родитель
Сommit
ff58ac836e

+ 2 - 2
web/src/main/java/org/springframework/security/web/authentication/rememberme/AbstractRememberMeServices.java

@@ -208,13 +208,13 @@ public abstract class AbstractRememberMeServices
 		for (int j = 0; j < cookieValue.length() % 4; j++) {
 			cookieValue = cookieValue + "=";
 		}
+		String cookieAsPlainText;
 		try {
-			Base64.getDecoder().decode(cookieValue.getBytes());
+			cookieAsPlainText = new String(Base64.getDecoder().decode(cookieValue.getBytes()));
 		}
 		catch (IllegalArgumentException ex) {
 			throw new InvalidCookieException("Cookie token was not Base64 encoded; value was '" + cookieValue + "'");
 		}
-		String cookieAsPlainText = new String(Base64.getDecoder().decode(cookieValue.getBytes()));
 		String[] tokens = StringUtils.delimitedListToStringArray(cookieAsPlainText, DELIMITER);
 		for (int i = 0; i < tokens.length; i++) {
 			try {