Skip to content

Commit 40f4346

Browse files
authored
fix correct usage (#3404)
base64 is part of JVM , no need to use it from another libraries
1 parent 3449e86 commit 40f4346

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

server/src/test/java/org/cloudfoundry/identity/uaa/oauth/jwt/JwtHeaderHelperTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.fasterxml.jackson.databind.ObjectMapper;
44
import com.fasterxml.jackson.databind.node.ObjectNode;
5-
import org.apache.directory.api.util.Base64;
65
import org.cloudfoundry.identity.uaa.test.RandomParametersJunitExtension;
76
import org.cloudfoundry.identity.uaa.test.RandomParametersJunitExtension.RandomValue;
87
import org.junit.jupiter.api.BeforeEach;
@@ -14,6 +13,7 @@
1413
import org.junit.jupiter.params.ParameterizedTest;
1514
import org.junit.jupiter.params.provider.ValueSource;
1615

16+
import java.util.Base64;
1717
import java.util.List;
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
@@ -194,6 +194,6 @@ private void validateJwtHeaders(JwtHeader header) {
194194
}
195195

196196
private String asBase64(String jwt) {
197-
return new String(Base64.encode(jwt.getBytes()));
197+
return new String(Base64.getEncoder().encode(jwt.getBytes()));
198198
}
199199
}

uaa/src/test/java/org/cloudfoundry/identity/uaa/mock/token/RefreshTokenMockMvcTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import com.fasterxml.jackson.core.type.TypeReference;
1717
import com.google.common.collect.Lists;
18-
import org.apache.directory.api.util.Base64;
1918
import org.apache.http.HttpStatus;
2019
import org.cloudfoundry.identity.uaa.client.UaaClientDetails;
2120
import org.cloudfoundry.identity.uaa.constants.OriginKeys;
@@ -46,6 +45,7 @@
4645
import org.springframework.mock.web.MockHttpServletResponse;
4746

4847
import java.time.Instant;
48+
import java.util.Base64;
4949
import java.util.Collections;
5050
import java.util.HashMap;
5151
import java.util.Map;
@@ -207,7 +207,7 @@ void refreshTokenGrant_rejectsAccessTokens_PasswordGrantType() throws Exception
207207
String body = mockMvc.perform(post("/oauth/token")
208208
.accept(MediaType.APPLICATION_JSON_VALUE)
209209
.header("Host", getZoneHostUrl(zone))
210-
.header("Authorization", "Basic " + new String(Base64.encode((client.getClientId() + ":" + SECRET).getBytes())))
210+
.header("Authorization", "Basic " + new String(Base64.getEncoder().encode((client.getClientId() + ":" + SECRET).getBytes())))
211211
.param("grant_type", GRANT_TYPE_PASSWORD)
212212
.param("client_id", client.getClientId())
213213
.param("client_secret", SECRET)
@@ -238,7 +238,7 @@ void refreshTokenGrant_rejectsIdTokens() throws Exception {
238238
String body = mockMvc.perform(post("/oauth/token")
239239
.accept(MediaType.APPLICATION_JSON_VALUE)
240240
.header("Host", getZoneHostUrl(zone))
241-
.header("Authorization", "Basic " + new String(Base64.encode((client.getClientId() + ":" + SECRET).getBytes())))
241+
.header("Authorization", "Basic " + new String(Base64.getEncoder().encode((client.getClientId() + ":" + SECRET).getBytes())))
242242
.param("grant_type", GRANT_TYPE_PASSWORD)
243243
.param("client_id", client.getClientId())
244244
.param("client_secret", SECRET)

0 commit comments

Comments
 (0)