mirror of
https://github.com/floci-io/floci.git
synced 2026-12-04 18:48:00 -05:00
refactor(core): decode pagination tokens through Base64Url (#6468)
AppSync, Pricing, Service Quotas and AppSync's DynamoDB data source decoded their pagination tokens to bytes and then to a UTF-8 string. Base64Url.decode does both with the same JDK decoder, so behaviour is unchanged.
This commit is contained in:
1 parent
217929bd65
commit
162805c4b6
4 files changed
+4
-13
No files matched your search
@@ -25,7 +25,6 @@ import java.security.SecureRandom;
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
import java.util.*;
|
||||
import java.util.Base64;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -1380,8 +1379,7 @@ public class AppSyncService {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
byte[] decoded = Base64.getUrlDecoder().decode(token);
|
||||
return Integer.parseInt(new String(decoded, java.nio.charset.StandardCharsets.UTF_8));
|
||||
return Integer.parseInt(Base64Url.decode(token));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
+1
-4
@@ -13,9 +13,7 @@ import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -349,8 +347,7 @@ public class DynamoDbDataSourceInvoker implements AppSyncDataSourceInvoker {
|
||||
|
||||
private JsonNode decodeNextToken(String nextToken) {
|
||||
try {
|
||||
byte[] decoded = Base64.getUrlDecoder().decode(nextToken);
|
||||
return objectMapper.readTree(new String(decoded, StandardCharsets.UTF_8));
|
||||
return objectMapper.readTree(Base64Url.decode(nextToken));
|
||||
} catch (Exception e) {
|
||||
throw new AwsException("InternalFailureException",
|
||||
"The nextToken handed to the DynamoDB data source is not one Floci issued", 500);
|
||||
|
||||
@@ -19,7 +19,6 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -377,8 +376,7 @@ public class PricingService {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
byte[] decoded = Base64.getUrlDecoder().decode(token);
|
||||
return Integer.parseInt(new String(decoded, java.nio.charset.StandardCharsets.UTF_8));
|
||||
return Integer.parseInt(Base64Url.decode(token));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
+1
-3
@@ -17,7 +17,6 @@ import jakarta.inject.Inject;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -233,8 +232,7 @@ public class ServiceQuotasService {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
byte[] decoded = Base64.getUrlDecoder().decode(token);
|
||||
return Integer.parseInt(new String(decoded, StandardCharsets.UTF_8));
|
||||
return Integer.parseInt(Base64Url.decode(token));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user