Skip to content

Commit 99f44b1

Browse files
committed
refactor: extract shouldReAttachPrtForEstsHost() method
Move the 3-part condition (flight check + eSTS host check + PRT header check) into a single method for readability in the handleUrl() chain.
1 parent 03bade7 commit 99f44b1

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

common/src/main/java/com/microsoft/identity/common/internal/ui/webview/AzureActiveDirectoryWebViewClient.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,7 @@ else if (isRedirectUrl(formattedURL)) {
366366
} else if (CommonFlightsManager.INSTANCE.getFlightsProvider().isFlightEnabled(CommonFlight.ENABLE_ATTACH_PRT_HEADER_WHEN_CROSS_CLOUD) && isCrossCloudRedirect(formattedURL)) {
367367
Logger.info(methodTag,"Navigation contains cross cloud redirect.");
368368
processCrossCloudRedirect(view, url);
369-
} else if (CommonFlightsManager.INSTANCE.getFlightsProvider().isFlightEnabled(CommonFlight.ENABLE_PRT_HEADER_FOR_ESTS_HOST_REDIRECT)
370-
&& isEstsCloudHost(url)
371-
&& hasPrtHeaderAttached()) {
369+
} else if (shouldReAttachPrtForEstsHost(url)) {
372370
Logger.info(methodTag, "Navigation redirects to eSTS cloud host, re-attaching PRT header.");
373371
processEstsHostRedirect(view, url);
374372
} else if (mInWebCpFlow && isWebCpEnrollmentUrl(url)) {
@@ -1175,6 +1173,18 @@ private boolean hasPrtHeaderAttached() {
11751173
&& mRequestHeaders.containsKey(AuthenticationConstants.Broker.PRT_RESPONSE_HEADER);
11761174
}
11771175

1176+
/**
1177+
* Returns true if PRT headers should be re-attached for an eSTS cloud host navigation.
1178+
* Checks that the flight is enabled, the URL is a known eSTS host, and PRT headers
1179+
* were present in the original request.
1180+
*/
1181+
private boolean shouldReAttachPrtForEstsHost(@NonNull final String url) {
1182+
return CommonFlightsManager.INSTANCE.getFlightsProvider()
1183+
.isFlightEnabled(CommonFlight.ENABLE_PRT_HEADER_FOR_ESTS_HOST_REDIRECT)
1184+
&& isEstsCloudHost(url)
1185+
&& hasPrtHeaderAttached();
1186+
}
1187+
11781188
/**
11791189
* Processes an eSTS host redirect by generating a fresh PRT credential JWT and attaching it.
11801190
*/

0 commit comments

Comments
 (0)