This commit is contained in:
WonChul Heo
2024-05-21 06:53:25 +09:00
committed by GitHub
parent 450599fbcf
commit 1bdca37b7f
2 changed files with 4 additions and 4 deletions

View File

@@ -19,6 +19,7 @@ package org.springframework.cloud.config.client;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.Arrays;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@@ -43,7 +44,6 @@ import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.Base64Utils;
import org.springframework.web.client.RestTemplate;
import static org.springframework.cloud.config.client.ConfigClientProperties.AUTHORIZATION;
@@ -137,7 +137,7 @@ public class ConfigClientRequestTemplateFactory {
}
if (password != null) {
byte[] token = Base64Utils.encode((username + ":" + password).getBytes());
byte[] token = Base64.getEncoder().encode((username + ":" + password).getBytes());
httpHeaders.add("Authorization", "Basic " + new String(token));
}
else if (authorization != null) {

View File

@@ -18,6 +18,7 @@ package org.springframework.cloud.config.server.encryption;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Base64;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -33,7 +34,6 @@ import org.springframework.security.crypto.codec.Hex;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.security.rsa.crypto.RsaKeyHolder;
import org.springframework.security.rsa.crypto.RsaSecretEncryptor;
import org.springframework.util.Base64Utils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -194,7 +194,7 @@ public class EncryptionController {
}
catch (IllegalArgumentException e) {
try {
Base64Utils.decode(candidate.getBytes());
Base64.getDecoder().decode(candidate.getBytes());
return candidate;
}
catch (IllegalArgumentException ex) {