Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final Refactoring - Syw UID2-4158 token gen code refactoring user identity #1123

Open
wants to merge 69 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
1693ea8
Renamed IdentityToken class and variables to Identity as it's a set o…
sunnywu Oct 10, 2024
14fd733
Renamed Identity.LogoutToken to InvalidIdentity and added some commen…
sunnywu Oct 10, 2024
7dd3a69
Renamed Identity.LogoutToken to InvalidIdentity and added some commen…
sunnywu Oct 10, 2024
f2e7a87
renamed getAdvertisingId to MappedIdentity
sunnywu Oct 11, 2024
c0cb6df
Split UserIdentity into 3 distinct classes - HashedDiiIdentity, First…
sunnywu Oct 11, 2024
0fccf8c
Added brief comment to Identity/MappedIdentity
sunnywu Oct 11, 2024
113e8ca
Renamed MappedIdentity to MappedIdentityResult
sunnywu Oct 11, 2024
ae03ff5
1. Rename AdvertisingToken class to AdvertisingTokenInput
sunnywu Oct 11, 2024
5595a15
Renamed ITokenEncoder.encode to ITokenEncoder.encodeIntoIdentityResponse
sunnywu Oct 11, 2024
c6bc08f
Renamed Identity.isEmptyToken method to Identity.isNotValid
sunnywu Oct 11, 2024
639b799
Renamed PublisherIdentity to SourcePublisher
sunnywu Oct 11, 2024
d9c730e
Refactored UserIdentity as a base class which is inherited by HashedD…
sunnywu Oct 11, 2024
42c5890
Renamed Identity to IdentityResponse
sunnywu Oct 11, 2024
b62aa54
Fixed using raw identity in testGenerateTokenForOptOutUser
sunnywu Oct 14, 2024
b272d40
Renamed RefreshResponse#getIdentity to RefreshResponse#getIdentityRes…
sunnywu Oct 14, 2024
7e5ad5d
1. Refactor EncryptedTokenEncoder#encodeIntoIdentityResponse
sunnywu Oct 14, 2024
131d203
Use EncryptedTokenEncoder directly inside UIDOperatorService class in…
sunnywu Oct 14, 2024
8dc0a41
Renamed MappedIdentity to RawUid2Result and UIDOperatorService.getAd…
sunnywu Oct 14, 2024
91ffa12
1. Fixed RawUid2Result to RawUidResult
sunnywu Oct 14, 2024
d9845b7
Merge branch 'syw-UID2-4159-token-gen-code-renaming' into syw-UID2-41…
sunnywu Oct 14, 2024
4bb4ccb
Renamed IdentityResponse.optOutIdentityResponse to OptOutIdentityResp…
sunnywu Oct 14, 2024
8ae5e08
Renamed IdentityResponse.optoutIdentityResponse to OptOutIdentityResp…
sunnywu Oct 14, 2024
5a0bb89
Merge branch 'syw-UID2-4159-token-gen-code-renaming' into syw-UID2-41…
sunnywu Oct 14, 2024
b507d8e
Fixed UserIdentity member variables as final and added constructor
sunnywu Oct 15, 2024
f5877b7
1. Addressed code review feedbacks
sunnywu Oct 15, 2024
ccc639f
Made UserIdentity abstract first
sunnywu Oct 15, 2024
dabff48
Fixed a few id variable to rawUid/firstLevelHash to make it clear. Fi…
sunnywu Oct 15, 2024
d8eda03
Fixed UserIdentity member variables as final and added constructor
sunnywu Oct 15, 2024
e74e8da
1. Addressed code review feedbacks
sunnywu Oct 15, 2024
7f4ebf5
Made UserIdentity abstract first
sunnywu Oct 15, 2024
72f7be4
Fixed a few id variable to rawUid/firstLevelHash to make it clear. Fi…
sunnywu Oct 15, 2024
44ed5d3
Merge remote-tracking branch 'origin/syw-UID2-4159-token-gen-code-ren…
sunnywu Oct 15, 2024
21f0c60
1. Refactored EncryptedTokenEncoder to rename encode/encodev2/encodev3
sunnywu Oct 16, 2024
6031d14
Merge remote-tracking branch 'origin/syw-UID2-4159-token-gen-code-ren…
sunnywu Oct 16, 2024
3b1718c
1. Removed the UserIdentity's refreshedAt field as that's redundant and
sunnywu Oct 16, 2024
0ab0a79
1. Removed privacyBits and establishedAt from UserIdentity/HashedDiiI…
sunnywu Oct 16, 2024
7538bfb
added comments
sunnywu Oct 16, 2024
249c25d
fixed variable name
sunnywu Oct 16, 2024
53f4de1
fixed variable name
sunnywu Oct 16, 2024
3624f15
Merge remote-tracking branch 'origin/syw-UID2-4159-token-gen-code-ren…
sunnywu Oct 16, 2024
a38af09
Merge remote-tracking branch 'origin/syw-UID2-4159-token-gen-code-ref…
sunnywu Oct 16, 2024
4c1de75
Moved privacyBits out of FirstLevelHashIdentity and treat it as a sep…
sunnywu Oct 21, 2024
062f908
Added a new IdentityRequest constructor to set default values for pri…
sunnywu Oct 21, 2024
76a1345
Update src/main/java/com/uid2/operator/model/IdentityRequest.java
sunnywu Oct 28, 2024
5db6e4f
Replace privacy bits type to PrivacyBits class instance
sunnywu Oct 28, 2024
741237d
Replace privacy bits type to PrivacyBits class instance
sunnywu Oct 28, 2024
3900017
Replace privacy bits type to PrivacyBits class instance
sunnywu Oct 28, 2024
e5b104d
missing a newline
sunnywu Oct 28, 2024
e25cd19
1. Added PrivacyBitsTest/IdentityResponseTest/RawUidResponseTest classes
sunnywu Oct 28, 2024
986cf2e
Created verifyFirstLevelHashIdentityAndEstablishedAt method for verif…
sunnywu Oct 28, 2024
f445180
Created verifyFirstLevelHashIdentityAndEstablishedAt method for verif…
sunnywu Oct 28, 2024
e4e7d2d
Merge remote-tracking branch 'origin/main' into syw-UID2-4159-token-g…
sunnywu Oct 28, 2024
fa1c0f1
Checking privacy bits in more tests in UIDOperatorVerticleTest
sunnywu Oct 28, 2024
20d695c
[CI Pipeline] Released Snapshot version: 5.41.1-alpha-116-SNAPSHOT
Oct 29, 2024
c950c6d
revered version in pom.xml
sunnywu Oct 30, 2024
a908e1f
added some comments and renamed refreshIdentity method param to input…
sunnywu Oct 30, 2024
04dfc14
fixed unit tests checking establishedAt between advertisingTokenInput…
sunnywu Oct 30, 2024
2edcb05
Refactored unit test codes to standardise the advertisingTokenInput/r…
sunnywu Oct 30, 2024
ca44945
Refactored unit test codes to standardise the advertisingTokenInput/r…
sunnywu Oct 30, 2024
da549b0
Code review feedback
sunnywu Nov 4, 2024
c6586a5
renamed IUIDOperatorService#mapIdentity to mapHashedDiiIdentity
sunnywu Nov 4, 2024
d76bceb
renamed to
sunnywu Nov 4, 2024
23a6f50
Code review feedback and renamed AdvertisingTOkenInput/RefreshTokenIn…
sunnywu Nov 4, 2024
a002ad1
Code review feedback,
sunnywu Dec 5, 2024
ea0b247
Renamed IdentityRequest/IdentityResponse to TokenGenerateRequest/Resp…
sunnywu Dec 9, 2024
4476ee1
- Renamed RawUidResponse to IdentityMapResponseItem, MapRequest to Id…
sunnywu Dec 9, 2024
6bb1fb9
1. Renamed FirstLevelHashIdentity/HashedDiiIdentity/RawUidIdentity to…
sunnywu Dec 9, 2024
a8f0915
1. Renamed IdentityType to DiiType
sunnywu Dec 9, 2024
7875d98
Merge remote-tracking branch 'origin/main' into syw-UID2-4159-token-g…
sunnywu Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/main/java/com/uid2/operator/IdentityConst.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
import com.uid2.operator.service.EncodingUtils;

public class IdentityConst {

// DIIs for generating optout tokens for legacy participants - to be deprecated
public static final String OptOutTokenIdentityForEmail = "[email protected]";
public static final String OptOutTokenIdentityForPhone = "+00000000001";

// DIIs for testing with token/validate endpoint, see https://unifiedid.com/docs/endpoints/post-token-validate
public static final String ValidateIdentityForEmail = "[email protected]";
public static final String ValidateIdentityForPhone = "+12345678901";
public static final byte[] ValidateIdentityForEmailHash = EncodingUtils.getSha256Bytes(IdentityConst.ValidateIdentityForEmail);
public static final byte[] ValidateIdentityForPhoneHash = EncodingUtils.getSha256Bytes(IdentityConst.ValidateIdentityForPhone);

// DIIs to use when you want to generate a optout response in token generation or identity map
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: should be an optout

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

public static final String OptOutIdentityForEmail = "[email protected]";
public static final String OptOutIdentityForPhone = "+00000000000";

// DIIs to use when you want to generate a UID token but when doing refresh token, you want to always get an optout response
// to test the optout handling workflow
public static final String RefreshOptOutIdentityForEmail = "[email protected]";
public static final String RefreshOptOutIdentityForPhone = "+00000000002";



}
19 changes: 0 additions & 19 deletions src/main/java/com/uid2/operator/model/AdvertisingToken.java

This file was deleted.

28 changes: 28 additions & 0 deletions src/main/java/com/uid2/operator/model/AdvertisingTokenRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.uid2.operator.model;

import java.time.Instant;

import com.uid2.operator.model.userIdentity.RawUidIdentity;
import com.uid2.operator.util.PrivacyBits;
import com.uid2.shared.model.TokenVersion;

// class containing enough data to create a new uid or advertising token
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean "new uid token" and "new advertising token"? If so, what is the difference between the two?

Or does it mean "new uid" and "new advertising token"? If so, why is the advertising token request used to create a new uid? What is a uid in this case anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should re-phrase better to
class containing enough information to create a new uid token (aka advertising token)

I use the term uid because this is about UID2/EUID. I think we have an understanding previously that from now on we should try to call things UID if it's used for both UID2 & EUID.

public class AdvertisingTokenRequest extends VersionedToken {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this class inherit from VersionedToken? Should the base classed be renamed to something like VersionedTokenRequest for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VersionedToken is a generic store for both AdvertisingTokenRequest and RefreshTokenRequest. So yeh i can rename to VersionedTokenRequest to be consistent.

Fixed

public final OperatorIdentity operatorIdentity;
public final SourcePublisher sourcePublisher;
public final RawUidIdentity rawUidIdentity;
public final PrivacyBits privacyBits;
public final Instant establishedAt;

public AdvertisingTokenRequest(TokenVersion version, Instant createdAt, Instant expiresAt, OperatorIdentity operatorIdentity,
SourcePublisher sourcePublisher, RawUidIdentity rawUidIdentity, PrivacyBits privacyBits,
Instant establishedAt) {
super(version, createdAt, expiresAt);
this.operatorIdentity = operatorIdentity;
this.sourcePublisher = sourcePublisher;
this.rawUidIdentity = rawUidIdentity;
this.privacyBits = privacyBits;
this.establishedAt = establishedAt;
}
}

35 changes: 27 additions & 8 deletions src/main/java/com/uid2/operator/model/IdentityRequest.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
package com.uid2.operator.model;

import com.uid2.operator.model.userIdentity.HashedDiiIdentity;
import com.uid2.operator.util.PrivacyBits;

import java.time.Instant;

public final class IdentityRequest {
public final PublisherIdentity publisherIdentity;
public final UserIdentity userIdentity;
public final SourcePublisher sourcePublisher;
public final HashedDiiIdentity hashedDiiIdentity;
public final OptoutCheckPolicy optoutCheckPolicy;

public final PrivacyBits privacyBits;
public final Instant establishedAt;

public IdentityRequest(
PublisherIdentity publisherIdentity,
UserIdentity userIdentity,
OptoutCheckPolicy tokenGeneratePolicy)
{
this.publisherIdentity = publisherIdentity;
this.userIdentity = userIdentity;
SourcePublisher sourcePublisher,
HashedDiiIdentity hashedDiiIdentity,
OptoutCheckPolicy tokenGeneratePolicy,
PrivacyBits privacyBits,
Instant establishedAt) {
this.sourcePublisher = sourcePublisher;
this.hashedDiiIdentity = hashedDiiIdentity;
this.optoutCheckPolicy = tokenGeneratePolicy;
this.privacyBits = privacyBits;
this.establishedAt = establishedAt;
}

public IdentityRequest(
SourcePublisher sourcePublisher,
HashedDiiIdentity hashedDiiIdentity,
OptoutCheckPolicy tokenGeneratePolicy) {
this(sourcePublisher, hashedDiiIdentity, tokenGeneratePolicy, PrivacyBits.DEFAULT, Instant.now());

}

public boolean shouldCheckOptOut() {
Expand Down
81 changes: 81 additions & 0 deletions src/main/java/com/uid2/operator/model/IdentityResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.uid2.operator.model;

import com.uid2.shared.model.TokenVersion;
import io.vertx.core.json.JsonObject;

import java.time.Instant;

// this defines all the fields for the response of the /token/generate and /client/generate endpoints before they are
// jsonified
// todo: can be converted to record later
public class IdentityResponse {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was IdentityTokens

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this is used for token generation / refresh responses and that we have identity map API, it can be confusing what this refers to. Should this be something like TokenGenerateResponse instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to TokenGenerateResponse

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sidenote: we can start using record for POJOs and reduce boilerplate code since we are on Java 21 now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noted. probably won't change it but leaving a note as future improvement

public static IdentityResponse OptOutIdentityResponse = new IdentityResponse("", null, "", Instant.EPOCH, Instant.EPOCH, Instant.EPOCH);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OptOutResponse? The Identity already shows up with the class name in typical usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok renamed to OptOutResponse

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


//aka UID token
private final String advertisingToken;
private final TokenVersion advertisingTokenVersion;
private final String refreshToken;
// when the advertising token/uid token expires
private final Instant identityExpires;
private final Instant refreshExpires;
private final Instant refreshFrom;

public IdentityResponse(String advertisingToken, TokenVersion advertisingTokenVersion, String refreshToken,
Instant identityExpires, Instant refreshExpires, Instant refreshFrom) {
this.advertisingToken = advertisingToken;
this.advertisingTokenVersion = advertisingTokenVersion;
this.refreshToken = refreshToken;
this.identityExpires = identityExpires;
this.refreshExpires = refreshExpires;
this.refreshFrom = refreshFrom;
}

public String getAdvertisingToken() {
return advertisingToken;
}

public TokenVersion getAdvertisingTokenVersion() {
return advertisingTokenVersion;
}

public String getRefreshToken() {
return refreshToken;
}

public Instant getIdentityExpires() {
return identityExpires;
}

public Instant getRefreshExpires() {
return refreshExpires;
}

public Instant getRefreshFrom() {
return refreshFrom;
}

public boolean isOptedOut() {
return advertisingToken == null || advertisingToken.isEmpty();
}

// for v1/v2 token/generate and token/refresh and client/generate (CSTG) endpoints
public JsonObject toJsonV1() {
final JsonObject json = new JsonObject();
json.put("advertising_token", getAdvertisingToken());
json.put("refresh_token", getRefreshToken());
json.put("identity_expires", getIdentityExpires().toEpochMilli());
json.put("refresh_expires", getRefreshExpires().toEpochMilli());
json.put("refresh_from", getRefreshFrom().toEpochMilli());
return json;
}

// for the original/legacy token/generate and token/refresh endpoint
public JsonObject toJsonV0() {
final JsonObject json = new JsonObject();
json.put("advertisement_token", getAdvertisingToken());
json.put("advertising_token", getAdvertisingToken());
json.put("refresh_token", getRefreshToken());

return json;
}
}
53 changes: 0 additions & 53 deletions src/main/java/com/uid2/operator/model/IdentityTokens.java

This file was deleted.

11 changes: 6 additions & 5 deletions src/main/java/com/uid2/operator/model/MapRequest.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package com.uid2.operator.model;

import com.uid2.operator.model.userIdentity.HashedDiiIdentity;

import java.time.Instant;

public final class MapRequest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IdentityMapRequest? Actually given identity map is a batch request, maybe IdentityMapRequestItem or IdentityMapRequest.Item would be more appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to IdentityMapRequestItem

public final UserIdentity userIdentity;
public final HashedDiiIdentity hashedDiiIdentity;
public final OptoutCheckPolicy optoutCheckPolicy;
public final Instant asOf;

public MapRequest(
UserIdentity userIdentity,
HashedDiiIdentity hashedDiiIdentity,
OptoutCheckPolicy optoutCheckPolicy,
Instant asOf)
{
this.userIdentity = userIdentity;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is an existing styling issue here - { should be on previous line. Just a minor suggestion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Instant asOf) {
this.hashedDiiIdentity = hashedDiiIdentity;
this.optoutCheckPolicy = optoutCheckPolicy;
this.asOf = asOf;
}
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/com/uid2/operator/model/MappedIdentity.java

This file was deleted.

13 changes: 0 additions & 13 deletions src/main/java/com/uid2/operator/model/PublisherIdentity.java

This file was deleted.

19 changes: 19 additions & 0 deletions src/main/java/com/uid2/operator/model/RawUidResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.uid2.operator.model;

// Contains the computed raw UID and its bucket ID from identity/map request
public class RawUidResponse {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed from MappedIdentity

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking again - I think MapRequest is the request object for identity/map right? We don't want to have the same name here? like IdentityRequest/IdentityResponse or RefreshTokenInput/RefreshResponse

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this applies too to the other TokenInput classes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm the identity/map function has a hashed dii input and returns a raw Uid (and bucket id). I can call RawUidResponse to MapResponse but i think RawUidResponse is clearer so changing to MapResponse for the sake matching up is not necessary making it clearer and therefore i would hesitate to make this change.

For AdvertisingTokenInput/RefreshTokenInput, i have renamed to AdvertisingTokenRequest/RefreshTokenRequest

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about IdentityMapResponse for the encompassing response (list of mappings) and nested class IdentityMapResponse.Item or non-nested class IdentityMapResponseItem for a single record?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to IdentityMapResponseItem and also MapRequest to IdentityMapRequestItem
I renamed IUIDOperatorService.mapHashedDiiIdentity to mapHashedDii as well

public static final RawUidResponse OptoutIdentity = new RawUidResponse(new byte[33], "");
// The raw UID is also known as Advertising Id (historically)
public final byte[] rawUid;
public final String bucketId;

public RawUidResponse(byte[] rawUid, String bucketId) {
this.rawUid = rawUid;
this.bucketId = bucketId;
}

// historically Optout is known as Logout
public boolean isOptedOut() {
return this.equals(OptoutIdentity) || this.bucketId == null || this.bucketId.isEmpty();
}
}
29 changes: 15 additions & 14 deletions src/main/java/com/uid2/operator/model/RefreshResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,38 @@

public class RefreshResponse {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be RefreshTokenResponse, especially given there is now RefreshTokenRequest?
Although for consistency perhaps these should be TokenRefreshRequest and TokenRefreshResponse.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to TokenRefreshRequest and TokenRefreshResponse


public static RefreshResponse Invalid = new RefreshResponse(Status.Invalid, IdentityTokens.LogoutToken);
public static RefreshResponse Optout = new RefreshResponse(Status.Optout, IdentityTokens.LogoutToken);
public static RefreshResponse Expired = new RefreshResponse(Status.Expired, IdentityTokens.LogoutToken);
public static RefreshResponse Deprecated = new RefreshResponse(Status.Deprecated, IdentityTokens.LogoutToken);
public static RefreshResponse NoActiveKey = new RefreshResponse(Status.NoActiveKey, IdentityTokens.LogoutToken);
public static final RefreshResponse Invalid = new RefreshResponse(Status.Invalid,
IdentityResponse.OptOutIdentityResponse);
public static final RefreshResponse Optout = new RefreshResponse(Status.Optout, IdentityResponse.OptOutIdentityResponse);
public static final RefreshResponse Expired = new RefreshResponse(Status.Expired, IdentityResponse.OptOutIdentityResponse);
public static final RefreshResponse Deprecated = new RefreshResponse(Status.Deprecated, IdentityResponse.OptOutIdentityResponse);
public static final RefreshResponse NoActiveKey = new RefreshResponse(Status.NoActiveKey, IdentityResponse.OptOutIdentityResponse);
private final Status status;
private final IdentityTokens tokens;
private final IdentityResponse identityResponse;
private final Duration durationSinceLastRefresh;
private final boolean isCstg;

private RefreshResponse(Status status, IdentityTokens tokens, Duration durationSinceLastRefresh, boolean isCstg) {
private RefreshResponse(Status status, IdentityResponse identityResponse, Duration durationSinceLastRefresh, boolean isCstg) {
this.status = status;
this.tokens = tokens;
this.identityResponse = identityResponse;
this.durationSinceLastRefresh = durationSinceLastRefresh;
this.isCstg = isCstg;
}

private RefreshResponse(Status status, IdentityTokens tokens) {
this(status, tokens, null, false);
private RefreshResponse(Status status, IdentityResponse identityResponse) {
this(status, identityResponse, null, false);
}

public static RefreshResponse createRefreshedResponse(IdentityTokens tokens, Duration durationSinceLastRefresh, boolean isCstg) {
return new RefreshResponse(Status.Refreshed, tokens, durationSinceLastRefresh, isCstg);
public static RefreshResponse createRefreshedResponse(IdentityResponse identityResponse, Duration durationSinceLastRefresh, boolean isCstg) {
return new RefreshResponse(Status.Refreshed, identityResponse, durationSinceLastRefresh, isCstg);
}

public Status getStatus() {
return status;
}

public IdentityTokens getTokens() {
return tokens;
public IdentityResponse getIdentityResponse() {
return identityResponse;
}

public Duration getDurationSinceLastRefresh() {
Expand Down
Loading