From 57cddd6d1d4fae6f8cd38c913f0a383e69ae50e1 Mon Sep 17 00:00:00 2001 From: Erik Schultink Date: Fri, 28 Jul 2023 14:00:53 -0700 Subject: [PATCH] fix conversion from PseudonymizedIdentity --> Pseudonym --- .../java/co/worklytics/psoxy/PseudonymizedIdentity.java | 8 ++++++-- .../psoxy/storage/impl/BulkDataSanitizerImplTest.java | 6 ++++++ java/gateway-core/gateway-core.iml | 9 +++++++++ java/impl/aws/psoxy-aws.iml | 9 +++++++++ java/impl/gcp/psoxy-gcp.iml | 9 +++++++++ java/impl/impl.iml | 3 +++ java/java.iml | 3 +++ 7 files changed, 45 insertions(+), 2 deletions(-) diff --git a/java/core/src/main/java/co/worklytics/psoxy/PseudonymizedIdentity.java b/java/core/src/main/java/co/worklytics/psoxy/PseudonymizedIdentity.java index 742713d55..847f760fb 100644 --- a/java/core/src/main/java/co/worklytics/psoxy/PseudonymizedIdentity.java +++ b/java/core/src/main/java/co/worklytics/psoxy/PseudonymizedIdentity.java @@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonInclude; import lombok.*; +import java.util.Base64; + /** * pseudonymized form of an account identifier * @@ -72,10 +74,12 @@ public Pseudonym asPseudonym() { //q: what to do w original, if anything? + Base64.Decoder decoder = Base64.getUrlDecoder(); + return Pseudonym.builder() - .hash(hash == null ? null : hash.getBytes()) + .hash(hash == null ? null : decoder.decode(hash.getBytes())) .domain(domain) - .reversible(reversible == null ? null : reversible.getBytes()) + .reversible(reversible == null ? null : decoder.decode(reversible.getBytes())) .build(); } } diff --git a/java/core/src/test/java/co/worklytics/psoxy/storage/impl/BulkDataSanitizerImplTest.java b/java/core/src/test/java/co/worklytics/psoxy/storage/impl/BulkDataSanitizerImplTest.java index 3d487ac1b..19217f92c 100644 --- a/java/core/src/test/java/co/worklytics/psoxy/storage/impl/BulkDataSanitizerImplTest.java +++ b/java/core/src/test/java/co/worklytics/psoxy/storage/impl/BulkDataSanitizerImplTest.java @@ -11,6 +11,7 @@ import com.avaulta.gateway.pseudonyms.PseudonymEncoder; import com.avaulta.gateway.pseudonyms.PseudonymImplementation; import com.avaulta.gateway.pseudonyms.impl.Base64Sha256HashPseudonymEncoder; +import com.avaulta.gateway.pseudonyms.impl.UrlSafeTokenPseudonymEncoder; import com.avaulta.gateway.tokens.DeterministicTokenizationStrategy; import com.avaulta.gateway.tokens.impl.Sha256DeterministicTokenizationStrategy; import com.google.common.collect.ImmutableMap; @@ -367,5 +368,10 @@ void pre_v0_4_30_bulk_pseudonym_URL_SAFE_TOKEN_ENCODING(String identifier) { byte[] token = deterministicTokenizationStrategy.getToken(identifier, Function.identity()); assertEquals(legacyEncoded, encoder.encode(Pseudonym.builder().hash(token).build())); + + // check that the none legacy encoding is just the legacy encoding with a "t~" prefix + UrlSafeTokenPseudonymEncoder urlSafeTokenPseudonymEncoder = new UrlSafeTokenPseudonymEncoder(); + assertEquals("t~" + legacyEncoded + (pseudonymizedIdentity.getDomain() == null ? "" : ("@" + pseudonymizedIdentity.getDomain())), + urlSafeTokenPseudonymEncoder.encode(pseudonymizedIdentity.asPseudonym())); } } diff --git a/java/gateway-core/gateway-core.iml b/java/gateway-core/gateway-core.iml index a0121bb0c..c897218d0 100644 --- a/java/gateway-core/gateway-core.iml +++ b/java/gateway-core/gateway-core.iml @@ -3,6 +3,15 @@ + + + + + + + + + diff --git a/java/impl/aws/psoxy-aws.iml b/java/impl/aws/psoxy-aws.iml index f0908b99d..f37ae59d2 100644 --- a/java/impl/aws/psoxy-aws.iml +++ b/java/impl/aws/psoxy-aws.iml @@ -3,6 +3,15 @@ + + + + + + + + + diff --git a/java/impl/gcp/psoxy-gcp.iml b/java/impl/gcp/psoxy-gcp.iml index 20a110725..21d8e453e 100644 --- a/java/impl/gcp/psoxy-gcp.iml +++ b/java/impl/gcp/psoxy-gcp.iml @@ -3,6 +3,15 @@ + + + + + + + + + diff --git a/java/impl/impl.iml b/java/impl/impl.iml index dba755a77..11d3ac64d 100644 --- a/java/impl/impl.iml +++ b/java/impl/impl.iml @@ -3,6 +3,9 @@ + + + diff --git a/java/java.iml b/java/java.iml index dba755a77..11d3ac64d 100644 --- a/java/java.iml +++ b/java/java.iml @@ -3,6 +3,9 @@ + + +