Skip to content

Commit 02ca194

Browse files
committed
Make getManagedIdentitySource static
1 parent 46cc756 commit 02ca194

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/ManagedIdentityApplication.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import lombok.AccessLevel;
77
import lombok.Getter;
8-
import lombok.Setter;
98
import org.slf4j.LoggerFactory;
109

1110
import java.util.concurrent.CompletableFuture;
@@ -24,7 +23,8 @@ public class ManagedIdentityApplication extends AbstractApplicationBase implemen
2423
@Getter
2524
static TokenCache sharedTokenCache = new TokenCache();
2625

27-
@Getter(value = AccessLevel.PUBLIC)
26+
//Deprecated the field in favor of the static getManagedIdentitySource method
27+
@Deprecated
2828
ManagedIdentitySourceType managedIdentitySource = ManagedIdentityClient.getManagedIdentitySource();
2929

3030
@Getter(value = AccessLevel.PACKAGE)
@@ -105,4 +105,13 @@ protected Builder self() {
105105
return this;
106106
}
107107
}
108+
109+
/**
110+
* Returns a {@link ManagedIdentitySourceType} value, which is based primarily on environment variables set on the system.
111+
*
112+
* @return ManagedIdentitySourceType enum for source type
113+
*/
114+
public static ManagedIdentitySourceType getManagedIdentitySource() {
115+
return ManagedIdentityClient.getManagedIdentitySource();
116+
}
108117
}

msal4j-sdk/src/test/java/com/microsoft/aad/msal4j/ManagedIdentityTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void managedIdentity_GetManagedIdentitySource(ManagedIdentitySourceType source,
161161
.build();
162162

163163
ManagedIdentitySourceType miClientSourceType = ManagedIdentityClient.getManagedIdentitySource();
164-
ManagedIdentitySourceType miAppSourceType = miApp.managedIdentitySource;
164+
ManagedIdentitySourceType miAppSourceType = ManagedIdentityApplication.getManagedIdentitySource();
165165
assertEquals(expectedSource, miClientSourceType);
166166
assertEquals(expectedSource, miAppSourceType);
167167
}

0 commit comments

Comments
 (0)