Skip to content

Commit

Permalink
fix conversion from PseudonymizedIdentity --> Pseudonym
Browse files Browse the repository at this point in the history
  • Loading branch information
eschultink committed Jul 28, 2023
1 parent 8772762 commit 57cddd6
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.*;

import java.util.Base64;

/**
* pseudonymized form of an account identifier
*
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()));
}
}
9 changes: 9 additions & 0 deletions java/gateway-core/gateway-core.iml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/target/generated-test-sources/test-annotations" isTestSource="true" generated="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
Expand Down
9 changes: 9 additions & 0 deletions java/impl/aws/psoxy-aws.iml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/target/generated-test-sources/test-annotations" isTestSource="true" generated="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
Expand Down
9 changes: 9 additions & 0 deletions java/impl/gcp/psoxy-gcp.iml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/target/generated-test-sources/test-annotations" isTestSource="true" generated="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
Expand Down
3 changes: 3 additions & 0 deletions java/impl/impl.iml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" generated="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
Expand Down
3 changes: 3 additions & 0 deletions java/java.iml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" generated="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
Expand Down

0 comments on commit 57cddd6

Please sign in to comment.