Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ import com.salesforce.androidsdk.auth.OAuth2.revokeRefreshToken
import com.salesforce.androidsdk.auth.RemoteAccessConsumerKeyProvider
import com.salesforce.androidsdk.auth.dpop.DPoPKeyManager
import com.salesforce.androidsdk.auth.dpop.DPoPNonceCache
import com.salesforce.androidsdk.auth.idp.SPConfig
import com.salesforce.androidsdk.auth.idp.interfaces.IDPManager
import com.salesforce.androidsdk.auth.idp.interfaces.SPManager
import com.salesforce.androidsdk.config.AdminPermsManager
import com.salesforce.androidsdk.config.AdminSettingsManager
import com.salesforce.androidsdk.config.BootConfig.getBootConfig
Expand Down Expand Up @@ -680,23 +677,49 @@ open class SalesforceSDKManager protected constructor(
}.getOrDefault("")


// Backing field for [idpManager]. The SDK reads this directly so its own internal use of the
// manager doesn't trigger the deprecation warning on the public property.
@Volatile
@Suppress("DEPRECATION") // References the deprecated IDPManager type until it is removed in 15.0.
private var _idpManager: com.salesforce.androidsdk.auth.idp.interfaces.IDPManager? = null

// Backing field for [spManager]. The SDK reads this directly so its own internal use of the
// manager doesn't trigger the deprecation warning on the public property.
@Volatile
@Suppress("DEPRECATION") // References the deprecated SPManager type until it is removed in 15.0.
private var _spManager: com.salesforce.androidsdk.auth.idp.interfaces.SPManager? = null

/**
* The Salesforce SDK manager's admin settings manager. Only
* defined if setAllowedSPApps() was called first
*/
var idpManager: IDPManager? = null
private set
@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
@Suppress("DEPRECATION") // References the deprecated IDPManager type until it is removed in 15.0.
Comment thread
sfdctaka marked this conversation as resolved.
Outdated
var idpManager: com.salesforce.androidsdk.auth.idp.interfaces.IDPManager?
get() = _idpManager
private set(value) {
_idpManager = value
}

/**
* The Salesforce SDK manager's SP manager. Only defined if
* setIdpAppPackageName() was called first
*/
var spManager: SPManager? = null
private set
@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
@Suppress("DEPRECATION") // References the deprecated SPManager type until it is removed in 15.0.
var spManager: com.salesforce.androidsdk.auth.idp.interfaces.SPManager?
get() = _spManager
private set(value) {
_spManager = value
}

/** Indicates if IDP login flow is enabled */
@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
val isIDPLoginFlowEnabled
get() = spManager != null
get() = _spManager != null

/**
* The available Mobile SDK style themes.
Expand Down Expand Up @@ -897,27 +920,31 @@ open class SalesforceSDKManager protected constructor(

/** Indicates if this app is configured as an identity provider */
private val isIdentityProvider
get() = idpManager != null
get() = _idpManager != null

/**
* Sets the IDP package name for this app.
* As a result, this app gets an SP Manager and can be used as an SP
* @param idpAppPackageName The IDP app package name
*/
@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
fun setIDPAppPackageName(idpAppPackageName: String?) {
registerUsedAppFeature(FEATURE_APP_IS_SP)
spManager = idpAppPackageName?.let { DefaultSPManager(it) }
_spManager = idpAppPackageName?.let { DefaultSPManager(it) }
}

/**
* Sets the allowed SP apps for this app.
* As a result this app gets an IDP manager and can be used as an IDP
* @param allowedSPApps The list of allows SP app
*/
@Suppress("unused")
fun setAllowedSPApps(allowedSPApps: List<SPConfig>) {
@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
@Suppress("unused", "DEPRECATION") // References the deprecated SPConfig parameter type until it is removed in 15.0.
fun setAllowedSPApps(allowedSPApps: List<com.salesforce.androidsdk.auth.idp.SPConfig>) {
registerUsedAppFeature(FEATURE_APP_IS_IDP)
idpManager = DefaultIDPManager(allowedSPApps)
_idpManager = DefaultIDPManager(allowedSPApps)
}


Expand Down Expand Up @@ -1776,6 +1803,7 @@ open class SalesforceSDKManager protected constructor(

/** Information to display in the developer support dialog */
open val devSupportInfo: DevSupportInfo
@Suppress("DEPRECATION") // Reads the deprecated isIDPLoginFlowEnabled flag until it is removed in 15.0.
get() {
val userList = userAccountManager.authenticatedUsers?.joinToString(separator = ",\n") {
"${it.displayName} (${it.username})"
Expand Down Expand Up @@ -2123,6 +2151,7 @@ open class SalesforceSDKManager protected constructor(
* @param context The Android context
*/
@JvmStatic
@Suppress("DEPRECATION") // Auto-wires the deprecated IDP login flow from MDM config until it is removed in 15.0.
fun initInternal(context: Context) {

// Upgrades to the latest version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ import androidx.compose.ui.viewinterop.AndroidView
import com.salesforce.androidsdk.app.SalesforceSDKManager
import com.salesforce.androidsdk.util.LogUtil
import com.salesforce.androidsdk.util.SalesforceSDKLogger
import com.salesforce.androidsdk.auth.idp.interfaces.IDPAuthCodeActivity as IDPAuthCodeActivityInterface

class IDPAuthCodeActivity : ComponentActivity(), IDPAuthCodeActivityInterface {
@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
@Suppress("DEPRECATION") // Implements the deprecated IDPAuthCodeActivity interface and reads the deprecated idpManager flag until they are removed in 15.0.
class IDPAuthCodeActivity : ComponentActivity(), com.salesforce.androidsdk.auth.idp.interfaces.IDPAuthCodeActivity {

companion object {
private val TAG: String = IDPAuthCodeActivity::class.java.simpleName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import java.net.URI
/**
* Helper class used in IDP app to get auth code from server
*/
@Suppress("DEPRECATION") // Uses the deprecated SPConfig type until it is removed in 15.0.
internal class IDPAuthCodeHelper @VisibleForTesting internal constructor(
val webView: WebView,
val userAccount: UserAccount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
@file:Suppress("DEPRECATION") // Imports and uses the deprecated IDPManager/IDPAuthCodeActivity/Status types throughout until they are removed in 15.0.
package com.salesforce.androidsdk.auth.idp

import android.content.Context
Expand All @@ -47,6 +48,7 @@ import com.salesforce.androidsdk.util.SalesforceSDKLogger
* e.g. the context (activity) that started it
* the web view to get the auth code in
*/
@Suppress("DEPRECATION") // Uses the deprecated SPConfig/Status types until they are removed in 15.0.
internal class IDPLoginFlow(context:Context, val user:UserAccount, val spConfig: SPConfig, val onStatusUpdate:(Status) -> Unit) : ActiveFlow(context) {

var authCodeActivity: IDPAuthCodeActivity? = null
Expand All @@ -70,6 +72,7 @@ internal class IDPLoginFlow(context:Context, val user:UserAccount, val spConfig:
/**
* Class handling IDP operations within an IDP app
*/
@Suppress("DEPRECATION") // Implements the deprecated IDPManager interface and uses SPConfig/Status until they are removed in 15.0.
internal class IDPManager(
val allowedSPApps: List<SPConfig>,
// the following allows us to decouple IDPManager from other part of the SDK and make it easier to test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ import com.salesforce.androidsdk.util.SalesforceSDKLogger
/**
* Receiver running in IDP app handling calls from SP app
*/
@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
class IDPReceiver : BroadcastReceiver() {
@Suppress("DEPRECATION") // Reads the deprecated idpManager flag until it is removed in 15.0.
override fun onReceive(context: Context, intent: Intent) {
SalesforceSDKManager.getInstance().idpManager?.onReceive(context, intent) ?: run {
SalesforceSDKLogger.d(this::class.java.simpleName, "onReceive no idp manager to handle ${LogUtil.intentToString(intent)}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import java.net.URI
/**
* Helper class used in SP app to get auth tokens and create user given auth code
*/
@Suppress("DEPRECATION") // Uses the deprecated SPConfig type until it is removed in 15.0.
internal class SPAuthCodeHelper private constructor (
val context: Context,
val loginUrl: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ import com.salesforce.androidsdk.config.BootConfig
/**
* SP app configuration
*/
@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
@Suppress("DEPRECATION") // References itself internally in equals()/hashCode()/forCurrentApp() until it is removed in 15.0.
data class SPConfig (
val appPackageName: String,
val componentName: String,
Expand All @@ -41,6 +44,8 @@ data class SPConfig (
) {
companion object {
@JvmStatic
@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
fun forCurrentApp(): SPConfig {
val sdkMgr = SalesforceSDKManager.getInstance()
return with(BootConfig.getBootConfig(sdkMgr.appContext)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
@file:Suppress("DEPRECATION") // Imports and uses the deprecated SPManager/Status types throughout until they are removed in 15.0.
package com.salesforce.androidsdk.auth.idp

import android.app.Activity
Expand All @@ -49,6 +50,7 @@ import com.salesforce.androidsdk.util.SalesforceSDKLogger
* - or the receiver context in the case it was started in response to a IDP login request
* the code verifier
*/
@Suppress("DEPRECATION") // Uses the deprecated Status type until it is removed in 15.0.
internal class SPLoginFlow private constructor(context:Context, val onStatusUpdate: (Status) -> Unit)
: ActiveFlow(context) {

Expand Down Expand Up @@ -81,6 +83,7 @@ internal class SPLoginFlow private constructor(context:Context, val onStatusUpda
/**
* Class handling SP operations within a SP app
*/
@Suppress("DEPRECATION") // Implements the deprecated SPManager interface and uses the Status type until they are removed in 15.0.
internal class SPManager(
private val idpAppPackageName: String,
// the following allows us to decouple IDPManager from other part of the SDK and make it easier to test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ import com.salesforce.androidsdk.util.SalesforceSDKLogger
/**
* Receiver running in SP app handling calls from IDP app
*/
@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
class SPReceiver : BroadcastReceiver() {
@Suppress("DEPRECATION") // Reads the deprecated spManager flag until it is removed in 15.0.
override fun onReceive(context: Context, intent: Intent) {
SalesforceSDKManager.getInstance().spManager?.onReceive(context, intent) ?: run {
SalesforceSDKLogger.d(this::class.java.simpleName, "onReceive no sp manager to handle ${LogUtil.intentToString(intent)}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ package com.salesforce.androidsdk.auth.idp.interfaces

import android.webkit.WebView

@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
interface IDPAuthCodeActivity {

val webView: WebView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ import android.content.Context
import android.content.Intent
import com.salesforce.androidsdk.R

@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
@Suppress("DEPRECATION") // Members below reference the deprecated Status/StatusUpdateCallback types until they are removed in 15.0.
interface IDPManager {

@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
enum class Status(val resIdForDescription: Int) {
LOGIN_REQUEST_SENT_TO_SP(R.string.sf__login_request_sent_to_sp),
GETTING_AUTH_CODE_FROM_SERVER(R.string.sf__getting_auth_code_from_server),
Expand All @@ -41,6 +46,8 @@ interface IDPManager {
SP_LOGIN_COMPLETE(R.string.sf__sp_login_complete)
}

@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
interface StatusUpdateCallback {
fun onStatusUpdate(status: Status)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ import android.content.Context
import android.content.Intent
import com.salesforce.androidsdk.R

@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
@Suppress("DEPRECATION") // Members below reference the deprecated Status/StatusUpdateCallback types until they are removed in 15.0.
interface SPManager {

@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
enum class Status(val resIdForDescription:Int) {
FAILED_TO_SEND_REQUEST_TO_IDP(R.string.sf__failed_to_send_request_to_idp),
LOGIN_REQUEST_SENT_TO_IDP(R.string.sf__login_request_sent_to_idp),
Expand All @@ -40,6 +45,8 @@ interface SPManager {
FAILED_TO_EXCHANGE_AUTHORIZATION_CODE(R.string.sf__failed_to_exchange_authorization_code),
LOGIN_COMPLETE(R.string.sf__login_complete)
}
@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
interface StatusUpdateCallback {
fun onStatusUpdate(status: Status)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public enum ConfigKey {
RequireCertAuth,
ManagedAppCertAlias,
OnlyShowAuthorizedHosts,

/**
* @deprecated The IDP (Identity Provider) login flow is deprecated and will be removed
* in Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.
*/
@Deprecated
IDPAppPackageName
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ import com.salesforce.androidsdk.app.SalesforceSDKManager.Theme.DARK
import com.salesforce.androidsdk.auth.OAuth2.OAuthFailedException
import com.salesforce.androidsdk.auth.OAuth2.TokenEndpointResponse
import com.salesforce.androidsdk.auth.OAuthErrorCode
import com.salesforce.androidsdk.auth.idp.interfaces.SPManager.Status
import com.salesforce.androidsdk.auth.idp.interfaces.SPManager.StatusUpdateCallback
import com.salesforce.androidsdk.config.LoginServerManager
import com.salesforce.androidsdk.config.RuntimeConfig.ConfigKey.ManagedAppCertAlias
import com.salesforce.androidsdk.config.RuntimeConfig.ConfigKey.RequireCertAuth
Expand Down Expand Up @@ -901,8 +899,9 @@ open class LoginActivity : FragmentActivity() {
}
}

internal inner class SPStatusCallback : StatusUpdateCallback {
override fun onStatusUpdate(status: Status) {
@Suppress("DEPRECATION") // Implements the deprecated StatusUpdateCallback/Status types until they are removed in 15.0.
internal inner class SPStatusCallback : com.salesforce.androidsdk.auth.idp.interfaces.SPManager.StatusUpdateCallback {
override fun onStatusUpdate(status: com.salesforce.androidsdk.auth.idp.interfaces.SPManager.Status) {
runOnUiThread {
makeText(
applicationContext,
Expand Down Expand Up @@ -1079,6 +1078,9 @@ open class LoginActivity : FragmentActivity() {
/**
* Called when the IDP login button is clicked.
*/
@Deprecated("The IDP (Identity Provider) login flow is deprecated and will be removed in " +
"Salesforce Mobile SDK 15.0. Apps should use advanced (browser-based) authentication.")
@Suppress("DEPRECATION") // Reads the deprecated spManager flag until it is removed in 15.0.
open fun onIDPLoginClick() {
SalesforceSDKManager.getInstance().spManager?.kickOffSPInitiatedLoginFlow(
this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ open class LoginViewModel(
internal var previousPendingServer: String? = null

internal val authFinished = mutableStateOf(false)
@Suppress("DEPRECATION") // Reads the deprecated isIDPLoginFlowEnabled flag until it is removed in 15.0.
internal val isIDPLoginFlowEnabled = derivedStateOf {
SalesforceSDKManager.getInstance().isIDPLoginFlowEnabled
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ fun LoginView() {
viewModel.biometricAuthenticationButtonAction.value?.invoke() ?: activity.onBioAuthClick()
}
} else null
@Suppress("DEPRECATION") // Calls the deprecated onIDPLoginClick until it is removed in 15.0.
val idpButton =
if (viewModel.isIDPLoginFlowEnabled.value) {
LoginViewModel.BottomBarButton(stringResource(sf__launch_idp)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ import org.junit.runner.RunWith
internal class PublicOverridesTest {
private val context = InstrumentationRegistry.getInstrumentation().context

// onIDPLoginClick() is deprecated (IDP flow, 14.0 → removal targeted for 15.0); overriding it
// here only verifies the override point still exists, so suppress the deprecation warning.
@Suppress("DEPRECATION")
@Test
fun overrideLoginActivity() {
class OverrideLoginActivity : LoginActivity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
// This suite exercises the IDP/SP login flow, which is deprecated (14.0, removal targeted for 15.0).
// The flow still ships and must keep working, so the tests intentionally use the deprecated APIs.
@file:Suppress("DEPRECATION")

package com.salesforce.androidsdk.auth.idp

import android.accounts.Account
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
// This suite exercises the IDP/SP login flow, which is deprecated (14.0, removal targeted for 15.0).
// The flow still ships and must keep working, so the tests intentionally use the deprecated APIs.
@file:Suppress("DEPRECATION")

package com.salesforce.androidsdk.auth.idp

import android.content.Context
Expand Down
Loading
Loading