Skip to content

Commit 9a974ff

Browse files
committed
Address Matt's feedback
1 parent b8163ce commit 9a974ff

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

src/main/java/com/uid2/client/IdentityMapV3Helper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ public IdentityMapV3Response createIdentityMapResponse(String responseString, En
3131
return new IdentityMapV3Response(decryptedResponseString, identityMapInput);
3232
}
3333

34-
Uid2Helper uid2Helper;
34+
private final Uid2Helper uid2Helper;
3535
}

src/main/java/com/uid2/client/IdentityMapV3Input.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public static IdentityMapV3Input fromHashedPhones(List<String> hashedPhones) {
3737
return new IdentityMapV3Input().withHashedPhones(hashedPhones);
3838
}
3939

40-
private transient final Map<String, List<String>> diiMappings = new HashMap<>();
40+
// Transient as this should not be part of the serialized JSON payload we send to UID2 Operator
41+
private transient final Map<String, List<String>> hashedDiiToRawDii = new HashMap<>();
4142

4243
@SerializedName("email_hash")
4344
private final List<Identity> hashedEmails = new ArrayList<>();
@@ -139,14 +140,14 @@ public IdentityMapV3Input withPhone(String phone) {
139140
}
140141

141142
List<String> getInputDiis(String identityType, int i) {
142-
return diiMappings.get(getEncodedDii(identityType, i));
143+
return hashedDiiToRawDii.get(getHashedDii(identityType, i));
143144
}
144145

145146
private void addToDiiMappings(String hashedDii, String rawDii) {
146-
diiMappings.computeIfAbsent(hashedDii, k -> new ArrayList<>()).add(rawDii);
147+
hashedDiiToRawDii.computeIfAbsent(hashedDii, k -> new ArrayList<>()).add(rawDii);
147148
}
148149

149-
private String getEncodedDii(String identityType, int i) {
150+
private String getHashedDii(String identityType, int i) {
150151
switch (identityType) {
151152
case "email_hash": return hashedEmails.get(i).identity;
152153
case "phone_hash": return hashedPhones.get(i).identity;

src/main/java/com/uid2/client/IdentityMapV3Response.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,19 @@ private void populateIdentitiesForType(IdentityMapV3Input identityMapInput, Stri
4040
}
4141
}
4242

43-
private static IdentityMapV3Input getIdentityMapInput(IdentityMapV3Input identityMapInput) {
44-
return identityMapInput;
45-
}
46-
4743
public boolean isSuccess() {
4844
return "success".equals(status);
4945
}
5046

51-
static public class ApiResponse {
47+
public static class ApiResponse {
5248
@SerializedName("status")
5349
public String status;
5450

5551
@SerializedName("body")
5652
public Map<String, List<ApiIdentity>> body;
5753
}
5854

59-
static public class ApiIdentity {
55+
public static class ApiIdentity {
6056
@SerializedName("u")
6157
public String currentUid;
6258

@@ -70,7 +66,7 @@ static public class ApiIdentity {
7066
public String error;
7167
}
7268

73-
static public class MappedIdentity {
69+
public static class MappedIdentity {
7470
public MappedIdentity(String currentUid, String previousUid, Instant refreshFrom) {
7571
this.currentUid = currentUid;
7672
this.previousUid = previousUid;
@@ -98,7 +94,7 @@ public Instant getRefreshFrom() {
9894
}
9995
}
10096

101-
static public class UnmappedIdentity {
97+
public static class UnmappedIdentity {
10298
public UnmappedIdentity(String reason)
10399
{
104100
this.reason = UnmappedIdentityReason.fromString(reason);
@@ -119,11 +115,11 @@ public String getRawReason() {
119115
}
120116

121117
public HashMap<String, MappedIdentity> getMappedIdentities() {
122-
return mappedIdentities;
118+
return new HashMap<>(mappedIdentities);
123119
}
124120

125121
public HashMap<String, UnmappedIdentity> getUnmappedIdentities() {
126-
return unmappedIdentities;
122+
return new HashMap<>(unmappedIdentities);
127123
}
128124

129125
private final String status;

0 commit comments

Comments
 (0)