Skip to content

Commit b10cd2e

Browse files
authored
refactor: use Base64 instead of Base64Utils (#3858)
SpringBoot 3.4 will remove Base64Utils
1 parent e3c46fd commit b10cd2e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

spring-boot-admin-server/src/main/java/de/codecentric/boot/admin/server/web/client/BasicAuthHttpHeaderProvider.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
package de.codecentric.boot.admin.server.web.client;
1818

1919
import java.nio.charset.StandardCharsets;
20+
import java.util.Base64;
2021
import java.util.Collections;
2122
import java.util.Map;
2223

2324
import org.springframework.http.HttpHeaders;
2425
import org.springframework.lang.Nullable;
25-
import org.springframework.util.Base64Utils;
2626
import org.springframework.util.StringUtils;
2727

2828
import de.codecentric.boot.admin.server.domain.entities.Instance;
@@ -86,7 +86,7 @@ public HttpHeaders getHeaders(Instance instance) {
8686
}
8787

8888
protected String encode(String username, String password) {
89-
String token = Base64Utils.encodeToString((username + ":" + password).getBytes(StandardCharsets.UTF_8));
89+
String token = base64Encode((username + ":" + password).getBytes(StandardCharsets.UTF_8));
9090
return "Basic " + token;
9191
}
9292

@@ -101,6 +101,14 @@ protected String encode(String username, String password) {
101101
return null;
102102
}
103103

104+
private static String base64Encode(byte[] src) {
105+
if (src.length == 0) {
106+
return "";
107+
}
108+
byte[] dest = Base64.getEncoder().encode(src);
109+
return new String(dest, StandardCharsets.UTF_8);
110+
}
111+
104112
@lombok.Data
105113
@lombok.NoArgsConstructor
106114
@lombok.AllArgsConstructor

0 commit comments

Comments
 (0)