From 69abbcc1f808be103df3d017b604461003ae7646 Mon Sep 17 00:00:00 2001 From: Avery-Dunn Date: Mon, 24 Jun 2024 13:06:28 -0700 Subject: [PATCH] Expose refreshon parameter in auth result metadata --- .../microsoft/aad/msal4j/AuthenticationResult.java | 2 +- .../aad/msal4j/AuthenticationResultMetadata.java | 13 +++---------- .../microsoft/aad/msal4j/TokenRequestExecutor.java | 5 ++++- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AuthenticationResult.java b/msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AuthenticationResult.java index ad6ceabd..9d3562b1 100644 --- a/msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AuthenticationResult.java +++ b/msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AuthenticationResult.java @@ -92,7 +92,7 @@ private ITenantProfile getTenantProfile() { private final String scopes; @Builder.Default - private final AuthenticationResultMetadata metadata = new AuthenticationResultMetadata(); + private final AuthenticationResultMetadata metadata = AuthenticationResultMetadata.builder().build(); @Getter(value = AccessLevel.PACKAGE) private final Boolean isPopAuthorization; diff --git a/msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AuthenticationResultMetadata.java b/msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AuthenticationResultMetadata.java index 4a4a1a49..b618dfd3 100644 --- a/msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AuthenticationResultMetadata.java +++ b/msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AuthenticationResultMetadata.java @@ -4,6 +4,7 @@ package com.microsoft.aad.msal4j; import lombok.AccessLevel; +import lombok.Builder; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @@ -16,17 +17,9 @@ @Accessors(fluent = true) @Getter @Setter(AccessLevel.PACKAGE) +@Builder public class AuthenticationResultMetadata implements Serializable { private TokenSource tokenSource; - - /** - * Sets default metadata values. Used when creating an {@link IAuthenticationResult} before the values are known. - */ - AuthenticationResultMetadata() { - } - - AuthenticationResultMetadata(TokenSource tokenSource) { - this.tokenSource = tokenSource; - } + private Long refreshOn; } \ No newline at end of file diff --git a/msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/TokenRequestExecutor.java b/msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/TokenRequestExecutor.java index 7e66ea2f..815ebfcc 100644 --- a/msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/TokenRequestExecutor.java +++ b/msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/TokenRequestExecutor.java @@ -155,7 +155,10 @@ private AuthenticationResult createAuthenticationResultFromOauthHttpResponse( refreshOn(response.getRefreshIn() > 0 ? currTimestampSec + response.getRefreshIn() : 0). accountCacheEntity(accountCacheEntity). scopes(response.getScope()). - metadata(new AuthenticationResultMetadata(TokenSource.IDENTITY_PROVIDER)). + metadata(AuthenticationResultMetadata.builder() + .tokenSource(TokenSource.IDENTITY_PROVIDER) + .refreshOn(response.getRefreshIn() > 0 ? currTimestampSec + response.getRefreshIn() : 0) + .build()). build(); } else {