Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
vNext
----------
- [MINOR] Add telemetry for the switch browser protocol (#2612)
- [MINOR] Enable the new Broker discovery on MSAL by default (#2618)

Version 21.0.0
----------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ class BrokerDiscoveryClientFactory {

companion object {

private val TAG = BrokerDiscoveryClientFactory::class.simpleName

@Volatile
private var IS_NEW_DISCOVERY_ENABLED = false

@Volatile
private var clientSdkInstance: IBrokerDiscoveryClient? = null

Expand All @@ -56,15 +61,20 @@ class BrokerDiscoveryClientFactory {
**/
@JvmStatic
fun setNewBrokerDiscoveryEnabled(isEnabled: Boolean){
// noop
// If the flag changes, wipe the existing singleton.
if (isEnabled != IS_NEW_DISCOVERY_ENABLED) {
clientSdkInstance = null
brokerSdkInstance = null
IS_NEW_DISCOVERY_ENABLED = isEnabled
}
}

/**
* Returns true if the new Broker discovery mechanism is enabled.
**/
@JvmStatic
fun isNewBrokerDiscoveryEnabled(): Boolean {
return true;
return BuildConfig.newBrokerDiscoveryEnabledFlag || IS_NEW_DISCOVERY_ENABLED;
}

/**
Expand Down Expand Up @@ -116,7 +126,14 @@ class BrokerDiscoveryClientFactory {
private fun getInstance(context: Context,
platformComponents: IPlatformComponents,
cache: IClientActiveBrokerCache) : IBrokerDiscoveryClient{
return BrokerDiscoveryClient(context, platformComponents, cache)
val methodTag = "$TAG:getInstance"
return if (isNewBrokerDiscoveryEnabled()) {
Logger.info(methodTag, "Broker Discovery is enabled. Use the new logic on the SDK side")
BrokerDiscoveryClient(context, platformComponents, cache)
} else {
Logger.info(methodTag, "Broker Discovery is disabled. Use AccountManager on the SDK side.")
LegacyBrokerDiscoveryClient(context)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) Microsoft Corporation.
// All rights reserved.
//
// This code is licensed under the MIT License.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files(the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions :
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.microsoft.identity.common.internal.activebrokerdiscovery

import android.content.Context
import com.microsoft.identity.common.internal.broker.BrokerData

/**
* An [IBrokerDiscoveryClient] which is based on AccountManager.
**/
class LegacyBrokerDiscoveryClient(val context: Context): IBrokerDiscoveryClient {

override fun getActiveBroker(shouldSkipCache: Boolean): BrokerData? {
return AccountManagerBrokerDiscoveryUtil(context)
.getActiveBrokerFromAccountManager()
}
}
Loading