Skip to content

Commit 1ac9f7f

Browse files
authored
1 parent 47dbbc0 commit 1ac9f7f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

msal/src/main/java/com/microsoft/identity/client/PublicClientApplication.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import static com.microsoft.identity.common.java.authorities.AzureActiveDirectoryAudience.isHomeTenantAlias;
3535
import static com.microsoft.identity.common.java.eststelemetry.PublicApiId.PCA_GENERATE_SIGNED_HTTP_REQUEST;
3636
import static com.microsoft.identity.common.java.eststelemetry.PublicApiId.PCA_GENERATE_SIGNED_HTTP_REQUEST_ASYNC;
37+
import static com.microsoft.identity.common.java.exception.ClientException.NOT_VALID_BROKER_FOUND;
3738
import static com.microsoft.identity.common.java.exception.ClientException.TOKEN_CACHE_ITEM_NOT_FOUND;
3839
import static com.microsoft.identity.common.java.exception.ClientException.TOKEN_SHARING_DESERIALIZATION_ERROR;
3940
import static com.microsoft.identity.common.java.exception.ClientException.TOKEN_SHARING_MSA_PERSISTENCE_ERROR;
@@ -2234,6 +2235,7 @@ private static boolean isAccountHomeTenant(@Nullable final Map<String, ?> claims
22342235

22352236
/**
22362237
* Returns true if the provided package name is a valid broker app.
2238+
* NOTE: Expose to Company Portal for Shared Device Mode broker validation.
22372239
*
22382240
* @param context application context.
22392241
* @param packageName package name of the app to be verified.
@@ -2242,4 +2244,25 @@ public boolean isValidBrokerPackage(@NonNull final Context context,
22422244
@NonNull final String packageName){
22432245
return new BrokerValidator(context).isValidBrokerPackage(packageName);
22442246
}
2247+
2248+
/**
2249+
* Returns active name of the broker app.
2250+
* NOTE: Expose to Company Portal for telemetry purpose.
2251+
*
2252+
* @param context application context.
2253+
* @return active broker package name. Null if active broker isn't installed.
2254+
**/
2255+
@Nullable
2256+
public String getActiveBrokerPackageName(@NonNull final Context context)
2257+
throws MsalException {
2258+
try {
2259+
return new BrokerValidator(context).getCurrentActiveBrokerPackageName();
2260+
} catch (final ClientException e){
2261+
if (NOT_VALID_BROKER_FOUND.equalsIgnoreCase(e.getErrorCode())) {
2262+
return null;
2263+
}
2264+
2265+
throw MsalExceptionAdapter.msalExceptionFromBaseException(e);
2266+
}
2267+
}
22452268
}

0 commit comments

Comments
 (0)