Skip to content

Commit dd8c51a

Browse files
committed
Clean up comments
1 parent f09f806 commit dd8c51a

5 files changed

Lines changed: 20 additions & 26 deletions

File tree

msal4j-sdk/src/integrationtest/java/com/microsoft/aad/msal4j/AgenticIT.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020

2121
/**
2222
* Integration tests for agentic (agent identity) scenarios using MSAL Java APIs.
23-
* Corresponds to .NET's Agentic.cs — tests the MSAL-level APIs for the agent identity flow
23+
* Tests the MSAL-level APIs for the agent identity flow
2424
* (specifically the FMI portions that are available on this branch).
2525
*
2626
* <p>These tests use MSAL token acquisition APIs (unlike AgenticRawHttpIT which uses raw HTTP).
2727
*
28-
* <p>Test configuration (same as .NET Agentic.cs):
28+
* <p>Test configuration:
2929
* <ul>
3030
* <li>Blueprint app: {@link #BLUEPRINT_CLIENT_ID}</li>
3131
* <li>Agent app: {@link #AGENT_APP_ID}</li>
@@ -42,7 +42,7 @@
4242
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
4343
class AgenticIT {
4444

45-
// Same config as .NET Agentic.cs
45+
// Lab test configuration
4646
private static final String BLUEPRINT_CLIENT_ID = "aab5089d-e764-47e3-9f28-cc11c2513821";
4747
private static final String TENANT_ID = "10c419d4-4a50-45b2-aa4e-919fb84df24f";
4848
private static final String AGENT_APP_ID = "ab18ca07-d139-4840-8b3b-4be9610c6ed5";
@@ -74,8 +74,6 @@ void init() throws KeyStoreException, NoSuchProviderException,
7474
* This tests Leg 2 of the agent identity flow:
7575
* 1. Blueprint CCA acquires FMI credential (fmi_path = agentAppId)
7676
* 2. Agent CCA uses that credential as client_assertion to get Graph token
77-
*
78-
* Corresponds to .NET's AgentGetsAppTokenForGraphTest.
7977
*/
8078
@Test
8179
void agentGetsAppToken_UsingFmiAssertion() throws Exception {

msal4j-sdk/src/integrationtest/java/com/microsoft/aad/msal4j/FmiIT.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121

2222
/**
2323
* Integration tests for FMI (Federated Managed Identity) support.
24-
* Corresponds to .NET's FmiIntegrationTests.cs — validates real Entra ID interactions
25-
* for the FMI token acquisition flows described in the FMI protocol spec v1.0 Section 3.2.
24+
* Validates real Entra ID interactions for the FMI token acquisition flows.
2625
*
2726
* <p>Test apps are in MSID Lab 4:
2827
* <ul>
@@ -41,7 +40,7 @@
4140
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
4241
class FmiIT {
4342

44-
// Same configuration as .NET's FmiIntegrationTests.cs
43+
// Lab test configuration
4544
private static final String TENANT_ID = "10c419d4-4a50-45b2-aa4e-919fb84df24f";
4645
private static final String RMA_CLIENT_ID = "3bf56293-fbb5-42bd-a407-248ba7431a8c";
4746
private static final String WEB_API_SCOPE = "api://aa464f73-2868-4f67-b0e7-fc2f749e757f/.default";

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ static boolean isNullOrBlank(final String str) {
8383

8484
/**
8585
* Computes an extended cache key hash from a sorted map of key-value components.
86-
* Uses the same algorithm as MSAL .NET, Go, and Python: concatenate sorted key+value pairs,
87-
* SHA-256 hash, then Base64URL encode without padding.
86+
* Concatenates sorted key+value pairs, SHA-256 hashes, then Base64URL encodes without padding.
87+
* This algorithm is cross-SDK compatible (same output for the same inputs in all MSAL SDKs).
8888
*
8989
* @param cacheKeyComponents a sorted map of component names to values
9090
* @return Base64URL-encoded SHA-256 hash, or empty string if the map is null/empty

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ private static AccessTokenCacheEntity createAccessTokenCacheEntity(TokenRequestE
340340
/**
341341
* Computes the extended cache key hash for a request, if applicable.
342342
* Currently, this is used for client credential requests with an fmi_path parameter.
343-
* The algorithm matches MSAL .NET/Go/Python: sorted key-value concatenation → SHA-256 → Base64URL.
343+
* The algorithm uses sorted key-value concatenation → SHA-256 → Base64URL (cross-SDK compatible).
344344
*/
345345
private static String computeExtCacheKeyHashForRequest(MsalRequest msalRequest) {
346346
if (msalRequest instanceof ClientCredentialRequest) {

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,12 @@
2020
* Tests for FMI (Federated Managed Identity) support in client credential flows.
2121
* Covers fmi_path body parameter injection, cache key isolation via ext_cache_key,
2222
* and assertion context (AssertionRequestOptions) propagation.
23-
*
24-
* These tests correspond to MSAL .NET's FmiIntegrationTests (§1-§3) and
25-
* UserFederatedIdentityCredentialTests (§4-§5) in the AgentIDs_ComponentsReference.
2623
*/
2724
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
2825
class FmiTest {
2926

3027
// ========================================================================
31-
// §2: fmi_path body parameter
28+
// fmi_path body parameter
3229
// ========================================================================
3330

3431
@Test
@@ -99,7 +96,7 @@ void fmiPath_NotIncludedWhenNull() throws Exception {
9996
}
10097

10198
// ========================================================================
102-
// §3: Cache key isolation (ext_cache_key)
99+
// Cache key isolation (ext_cache_key)
103100
// ========================================================================
104101

105102
@Test
@@ -226,7 +223,7 @@ void fmiPath_CacheDoesNotCollideWithNonFmiTokens() throws Exception {
226223
}
227224

228225
// ========================================================================
229-
// §3: ext_cache_key hash computation
226+
// ext_cache_key hash computation
230227
// ========================================================================
231228

232229
@Test
@@ -236,7 +233,7 @@ void computeExtCacheKeyHash_EmptyMapReturnsEmpty() {
236233
}
237234

238235
// ========================================================================
239-
// §5: Assertion context — AssertionRequestOptions
236+
// Assertion context — AssertionRequestOptions
240237
// ========================================================================
241238

242239
@Test
@@ -374,16 +371,16 @@ void fmiPath_WhitespaceOnlyThrowsIllegalArgumentException() {
374371
}
375372

376373
// ========================================================================
377-
// §3: Exact cache key string validation (cross-SDK compatibility)
374+
// Exact cache key string validation (cross-SDK compatibility)
378375
// ========================================================================
379376

380377
@Test
381-
void fmiPath_CacheKeyFormat_MatchesDotNetFormat() throws Exception {
378+
void fmiPath_CacheKeyFormat_MatchesCrossSDKFormat() throws Exception {
382379
// This test verifies that the internal cache key produced by Java uses the correct
383380
// format: "-{env}-atext-{clientId}-{tenantId}-{scopes}-{hash}"
384-
// Using the same fmi_path as .NET's Flow1 test: "SomeFmiPath/FmiCredentialPath"
381+
// Using the same fmi_path as other SDKs' integration tests: "SomeFmiPath/FmiCredentialPath"
385382
// Expected hash (case-sensitive): zm2n0E62zwTsnNsozptLsoOoB_C7i-GfpxHYQQINJUw
386-
// The full cache key is lowercased (both .NET and Java do this).
383+
// The full cache key is lowercased.
387384
// Java resolves login.microsoftonline.com → login.windows.net (preferred alias).
388385
DefaultHttpClient httpClientMock = mock(DefaultHttpClient.class);
389386

@@ -430,21 +427,21 @@ void fmiPath_CacheKeyFormat_MatchesDotNetFormat() throws Exception {
430427

431428
@Test
432429
void fmiPath_HashValueMatchesCrossSDK() {
433-
// Verify that the Java hash computation matches .NET for known inputs
430+
// Verify that the Java hash computation matches other MSAL SDKs for known inputs
434431
TreeMap<String, String> components = new TreeMap<>();
435432
components.put("fmi_path", "SomeFmiPath/FmiCredentialPath");
436433

437434
String hash = StringHelper.computeExtCacheKeyHash(components);
438435
assertEquals("zm2n0E62zwTsnNsozptLsoOoB_C7i-GfpxHYQQINJUw", hash,
439-
"Hash for 'SomeFmiPath/FmiCredentialPath' should match .NET/Go/Python");
436+
"Hash for 'SomeFmiPath/FmiCredentialPath' should match cross-SDK value");
440437

441-
// Second known value from .NET tests
438+
// Second known value
442439
TreeMap<String, String> components2 = new TreeMap<>();
443440
components2.put("fmi_path", "SomeFmiPath/Path");
444441

445442
String hash2 = StringHelper.computeExtCacheKeyHash(components2);
446443
assertEquals("7CX57Q63os7benQ6ER0sxgJPtNQSv7TGb5zexcidFoI", hash2,
447-
"Hash for 'SomeFmiPath/Path' should match .NET");
444+
"Hash for 'SomeFmiPath/Path' should match cross-SDK value");
448445
}
449446

450447
@Test

0 commit comments

Comments
 (0)