Skip to content

Commit e8a10e3

Browse files
authored
Enable Broker Discovery by default in MSAL/Broker API, Fixes AB#3430520 (#2818)
[AB#3430520](https://identitydivision.visualstudio.com/fac9d424-53d2-45c0-91b5-ef6ba7a6bf26/_workitems/edit/3430520)
1 parent b412e0d commit e8a10e3

File tree

2 files changed

+6
-42
lines changed

2 files changed

+6
-42
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
vNext
22
----------
3+
- [MINOR] Enable Broker Discovery by default in MSAL/Broker API (#2818)
34
- [MINOR] Share SharedPreferencesInMemoryCache across instances of BrokerOAuth2TokenCache
45
- [MINOR] Use SharedPreferencesInMemoryCache implementation in Broker (#2802)
56

common/src/main/java/com/microsoft/identity/common/internal/activebrokerdiscovery/BrokerDiscoveryClientFactory.kt

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,7 @@ import kotlinx.coroutines.sync.withLock
3838
class BrokerDiscoveryClientFactory {
3939

4040
companion object {
41-
42-
private val TAG = BrokerDiscoveryClientFactory::class.simpleName
43-
44-
@Volatile
45-
private var IS_NEW_DISCOVERY_ENABLED = false
46-
41+
4742
@Volatile
4843
private var clientSdkInstance: IBrokerDiscoveryClient? = null
4944

@@ -56,25 +51,11 @@ class BrokerDiscoveryClientFactory {
5651
private val lock = Mutex()
5752

5853
/**
59-
* If set to true, the new Broker discovery mechanism will be enabled.
60-
* This is currently turned off by default - until we're ready to ship the feature.
54+
* Do nothing, since this is always enabled now.
55+
* Keep it for now to prevent breaking OneAuth.
6156
**/
6257
@JvmStatic
6358
fun setNewBrokerDiscoveryEnabled(isEnabled: Boolean){
64-
// If the flag changes, wipe the existing singleton.
65-
if (isEnabled != IS_NEW_DISCOVERY_ENABLED) {
66-
clientSdkInstance = null
67-
brokerSdkInstance = null
68-
IS_NEW_DISCOVERY_ENABLED = isEnabled
69-
}
70-
}
71-
72-
/**
73-
* Returns true if the new Broker discovery mechanism is enabled.
74-
**/
75-
@JvmStatic
76-
fun isNewBrokerDiscoveryEnabled(): Boolean {
77-
return BuildConfig.newBrokerDiscoveryEnabledFlag || IS_NEW_DISCOVERY_ENABLED;
7859
}
7960

8061
/**
@@ -87,7 +68,7 @@ class BrokerDiscoveryClientFactory {
8768
runBlocking {
8869
lock.withLock {
8970
if (clientSdkInstance == null) {
90-
clientSdkInstance = getInstance(context,
71+
clientSdkInstance = BrokerDiscoveryClient(context,
9172
platformComponents,
9273
ClientActiveBrokerCache.getClientSdkCache(platformComponents.storageSupplier))
9374
}
@@ -108,7 +89,7 @@ class BrokerDiscoveryClientFactory {
10889
runBlocking {
10990
lock.withLock {
11091
if (brokerSdkInstance == null) {
111-
brokerSdkInstance = getInstance(context,
92+
brokerSdkInstance = BrokerDiscoveryClient(context,
11293
platformComponents,
11394
ClientActiveBrokerCache.getBrokerSdkCache(platformComponents.storageSupplier))
11495
}
@@ -117,23 +98,5 @@ class BrokerDiscoveryClientFactory {
11798
}
11899
return brokerSdkInstance!!
119100
}
120-
121-
/**
122-
* Initializes a new [IBrokerDiscoveryClient] object.
123-
* to be used by OneAuth/MSAL.
124-
**/
125-
@JvmStatic
126-
private fun getInstance(context: Context,
127-
platformComponents: IPlatformComponents,
128-
cache: IClientActiveBrokerCache) : IBrokerDiscoveryClient{
129-
val methodTag = "$TAG:getInstance"
130-
return if (isNewBrokerDiscoveryEnabled()) {
131-
Logger.info(methodTag, "Broker Discovery is enabled. Use the new logic on the SDK side")
132-
BrokerDiscoveryClient(context, platformComponents, cache)
133-
} else {
134-
Logger.info(methodTag, "Broker Discovery is disabled. Use AccountManager on the SDK side.")
135-
LegacyBrokerDiscoveryClient(context)
136-
}
137-
}
138101
}
139102
}

0 commit comments

Comments
 (0)