@@ -146,16 +146,20 @@ open class LoginActivity : AppCompatActivity(), OAuthWebviewHelperEvents {
146146 val salesforceSDKManager = SalesforceSDKManager .getInstance()
147147
148148 /*
149- * For Salesforce Identity API UI Bridge support, the overriding front door bridge URL to
150- * use in place of the default initial login URL plus the optional web server flow code
151- * verifier accompanying the front door bridge URL
149+ * For Salesforce Identity API UI Bridge support, the overriding
150+ * frontdoor bridge URL to use in place of the default initial login URL
151+ * plus the optional web server flow code verifier accompanying the
152+ * frontdoor bridge URL.
152153 */
153- val frontDoorBridgeUrl = salesforceSDKManager.frontDoorBridgeUrl
154- val frontDoorBridgeCodeVerifier = salesforceSDKManager.frontDoorBridgeCodeVerifier
155- val isUsingFrontDoorBridge = frontDoorBridgeUrl != null
156- // Reset the the Salesforce SDK manager's UI bridge support.
157- salesforceSDKManager.frontDoorBridgeUrl = null
158- salesforceSDKManager.frontDoorBridgeCodeVerifier = null
154+ val isUsingFrontDoorBridge = isFrontdoorBridgeUrlIntent(intent) || isQrCodeLoginUrlIntent(intent)
155+ val uiBridgeApiParameters = if (isQrCodeLoginUrlIntent(intent)) {
156+ uiBridgeApiParametersFromQrCodeLoginUrl(intent.data?.toString())
157+ } else intent.getStringExtra(EXTRA_KEY_FRONTDOOR_BRIDGE_URL )?.let { frontdoorBridgeUrl ->
158+ UiBridgeApiParameters (
159+ frontdoorBridgeUrl,
160+ intent.getStringExtra(EXTRA_KEY_PKCE_CODE_VERIFIER )
161+ )
162+ }
159163
160164 accountAuthenticatorResponse = intent.getParcelableExtra<AccountAuthenticatorResponse ?>(
161165 KEY_ACCOUNT_AUTHENTICATOR_RESPONSE
@@ -233,11 +237,10 @@ open class LoginActivity : AppCompatActivity(), OAuthWebviewHelperEvents {
233237 )
234238
235239 // Prompt user with the default login page or log in via other configurations such as using a Salesforce Identity API UI Bridge front door URL.
236- @Suppress(" KotlinConstantConditions" ) // Note: This is a cosmetic suppress until the Android Studio inspector can smart cast the front door bridge URL as the compiler does.
237240 when {
238- isUsingFrontDoorBridge && frontDoorBridgeUrl != null -> loginWithFrontdoorBridgeUrl(
239- frontDoorBridgeUrl ,
240- frontDoorBridgeCodeVerifier
241+ isUsingFrontDoorBridge && uiBridgeApiParameters?.frontdoorBridgeUrl != null -> loginWithFrontdoorBridgeUrl(
242+ uiBridgeApiParameters.frontdoorBridgeUrl ,
243+ uiBridgeApiParameters.pkceCodeVerifier
241244 )
242245
243246 else -> certAuthOrLogin()
@@ -723,7 +726,7 @@ open class LoginActivity : AppCompatActivity(), OAuthWebviewHelperEvents {
723726 * [LoginActivity.loginWithFrontdoorBridgeUrl].
724727 *
725728 * @param qrCodeLoginUrl The QR code login URL
726- * @return Boolean true if a log in attempt is possible using the provided QR code log in URL,
729+ * @return Boolean true if a log in attempt is possible using the provided QR code login URL,
727730 * false otherwise
728731 */
729732 fun loginWithFrontdoorBridgeUrlFromQrCode (
@@ -799,15 +802,26 @@ open class LoginActivity : AppCompatActivity(), OAuthWebviewHelperEvents {
799802 var qrCodeLoginUrlJsonPkceCodeVerifierKey = " pkce_code_verifier"
800803
801804 /* *
802- * When QR code log in is enabled, determines if the provided intent has QR code login
803- * parameters.
805+ * Determines if the provided intent has QR code login parameters.
804806 * @param intent The intent to determine QR code login enablement for
805- * @return Boolean true if the intent has QR code login parameters or false otherwise
807+ * @return Boolean true if the intent has QR code login parameters or
808+ * false otherwise
806809 */
807- fun isQrCodeLoginIntent (
810+ fun isQrCodeLoginUrlIntent (
808811 intent : Intent
809- ) = SalesforceSDKManager .getInstance().isQrCodeLoginEnabled
810- && intent.data?.path?.contains(qrCodeLoginUrlPath) == true
812+ ) = intent.data?.path?.contains(qrCodeLoginUrlPath) == true
813+
814+ /* *
815+ * Determines if the provided intent has front door bridge URL
816+ * parameters.
817+ * @param intent The intent to determine front door bridge URL
818+ * enablement for
819+ * @return Boolean true if the intent has front door bridge URL
820+ * parameters or false otherwise
821+ */
822+ private fun isFrontdoorBridgeUrlIntent (
823+ intent : Intent
824+ ) = intent.hasExtra(EXTRA_KEY_FRONTDOOR_BRIDGE_URL )
811825
812826 /* *
813827 * Parses Salesforce Identity API UI Bridge parameters from the provided login QR code login
@@ -839,6 +853,12 @@ open class LoginActivity : AppCompatActivity(), OAuthWebviewHelperEvents {
839853 // endregion
840854 // region QR Code Login Via Salesforce Identity API UI Bridge Private Implementation
841855
856+ /* * Extras key for the Salesforce Identity API UI Bridge front door URL */
857+ const val EXTRA_KEY_FRONTDOOR_BRIDGE_URL = " frontdoor_bridge_url"
858+
859+ /* * Extras key for the Salesforce Identity API UI PKCE code verifier */
860+ const val EXTRA_KEY_PKCE_CODE_VERIFIER = " pkce_code_verifier"
861+
842862 /* *
843863 * For QR code login URLs, a regular expression to extract the Salesforce Identity API UI
844864 * Bridge parameter JSON string.
0 commit comments