Skip to content

Commit d08a45c

Browse files
committed
Make LoginOptions internal.
1 parent e31a35e commit d08a45c

12 files changed

Lines changed: 37 additions & 455 deletions

File tree

libs/SalesforceSDK/src/com/salesforce/androidsdk/accounts/UserAccountManager.java

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,7 @@ public void switchToUser(UserAccount user, int userSwitchType, Bundle extras) {
325325
if (user.equals(curUser)) {
326326
return;
327327
}
328-
final ClientManager cm = new ClientManager(context, accountType,
329-
SalesforceSDKManager.getInstance().getLoginOptions(), true);
328+
final ClientManager cm = new ClientManager(context, accountType, true);
330329
final Account account = cm.getAccountByName(user.getAccountName());
331330
storeCurrentUserInfo(user.getUserId(), user.getOrgId());
332331
cm.peekRestClient(account);
@@ -350,23 +349,17 @@ public void switchToUser(UserAccount user, int userSwitchType, Bundle extras) {
350349
* in ClientManager will return a RestClient instance for the new user.
351350
*/
352351
public void switchToNewUser() {
353-
final Bundle options = SalesforceSDKManager.getInstance().getLoginOptions().asBundle();
354-
switchToNewUserWithOptions(options);
352+
final Bundle options = new Bundle();
353+
final Bundle reply = new Bundle();
354+
final Intent i = new Intent(context, SalesforceSDKManager.getInstance().getLoginActivityClass());
355+
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
356+
options.putBoolean(BiometricAuthenticationManager.SHOW_BIOMETRIC, false);
357+
options.putBoolean(LoginActivity.NEW_USER, true);
358+
i.putExtras(options);
359+
reply.putParcelable(AccountManager.KEY_INTENT, i);
360+
context.startActivity(i);
355361
}
356362

357-
/**
358-
* Kicks off the login flow to switch to a new user with jwt. Once the login
359-
* flow is complete, the context will automatically become the
360-
* new user's context and a call to peekRestClient() or getRestClient()
361-
* in ClientManager will return a RestClient instance for the new user.
362-
*
363-
* @param jwt JWT.
364-
* @param url Instance/My domain URL.
365-
*/
366-
public void switchToNewUser(String jwt, String url) {
367-
final Bundle options = SalesforceSDKManager.getInstance().getLoginOptions(jwt, url).asBundle();
368-
switchToNewUserWithOptions(options);
369-
}
370363

371364
/**
372365
* Logs the current user out.
@@ -697,17 +690,6 @@ public synchronized void refreshToken(UserAccount userAccount) {
697690
}
698691
}
699692

700-
private void switchToNewUserWithOptions(Bundle options) {
701-
final Bundle reply = new Bundle();
702-
final Intent i = new Intent(context, SalesforceSDKManager.getInstance().getLoginActivityClass());
703-
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
704-
options.putBoolean(BiometricAuthenticationManager.SHOW_BIOMETRIC, false);
705-
options.putBoolean(LoginActivity.NEW_USER, true);
706-
i.putExtras(options);
707-
reply.putParcelable(AccountManager.KEY_INTENT, i);
708-
context.startActivity(i);
709-
}
710-
711693
/**
712694
* Create bundle for authenticator service
713695
* - it uses keys understood by authenticator service

libs/SalesforceSDK/src/com/salesforce/androidsdk/app/SalesforceSDKManager.kt

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ import com.salesforce.androidsdk.push.PushService
119119
import com.salesforce.androidsdk.push.PushService.Companion.pushNotificationsRegistrationType
120120
import com.salesforce.androidsdk.push.PushService.PushNotificationReRegistrationType.ReRegistrationOnAppForeground
121121
import com.salesforce.androidsdk.rest.ClientManager
122-
import com.salesforce.androidsdk.rest.ClientManager.LoginOptions
123122
import com.salesforce.androidsdk.rest.RestClient
124123
import com.salesforce.androidsdk.security.BiometricAuthenticationManager
125124
import com.salesforce.androidsdk.security.SalesforceKeyGenerator.getEncryptionKey
@@ -188,9 +187,6 @@ open class SalesforceSDKManager protected constructor(
188187
/** The Android context */
189188
val appContext: Context = context
190189

191-
/** Login options associated with the app */
192-
private var loginOptionsInternal: LoginOptions? = null
193-
194190
/**
195191
* Returns the class for the main activity.
196192
*
@@ -550,42 +546,6 @@ open class SalesforceSDKManager protected constructor(
550546
}
551547
}
552548

553-
/** Login options associated with the app */
554-
open val loginOptions: LoginOptions get() = getLoginOptions(null, null)
555-
556-
/**
557-
* Sets the login options associated with the app.
558-
*
559-
* @param jwt The `jwt`
560-
* @param url The URL
561-
*/
562-
open fun getLoginOptions(
563-
jwt: String?,
564-
url: String?
565-
) = loginOptionsInternal?.apply {
566-
this.jwt = jwt
567-
setUrl(url)
568-
} ?: getBootConfig(
569-
appContext
570-
).let { config ->
571-
when {
572-
isEmpty(jwt) -> LoginOptions(
573-
url,
574-
config.oauthRedirectURI,
575-
config.remoteAccessConsumerKey,
576-
config.oauthScopes
577-
)
578-
579-
else -> LoginOptions(
580-
url,
581-
config.oauthRedirectURI,
582-
config.remoteAccessConsumerKey,
583-
config.oauthScopes,
584-
jwt
585-
)
586-
}.also { loginOptionsInternal = it }
587-
}
588-
589549
/**
590550
* Indicates if the Salesforce Mobile SDK should automatically log out when
591551
* the access token is revoked. When overriding this method to return false,
@@ -995,7 +955,6 @@ open class SalesforceSDKManager protected constructor(
995955
val clientMgr = ClientManager(
996956
appContext,
997957
accountType,
998-
null,
999958
shouldLogoutWhenTokenRevoked()
1000959
)
1001960

@@ -1202,7 +1161,6 @@ open class SalesforceSDKManager protected constructor(
12021161
ClientManager(
12031162
appContext,
12041163
accountType,
1205-
loginOptions,
12061164
true
12071165
)
12081166
}
@@ -1218,7 +1176,6 @@ open class SalesforceSDKManager protected constructor(
12181176
): ClientManager = ClientManager(
12191177
appContext,
12201178
accountType,
1221-
getLoginOptions(jwt, url),
12221179
true
12231180
)
12241181

libs/SalesforceSDK/src/com/salesforce/androidsdk/auth/AuthenticatorService.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@ public IBinder onBind(Intent intent) {
105105
}
106106

107107
private static class Authenticator extends AbstractAccountAuthenticator {
108-
109-
private static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
110-
private static final String ANDROID_PACKAGE_NAME = "androidPackageName";
111-
112108
private final Context context;
113109

114110
Authenticator(Context ctx) {
@@ -122,24 +118,16 @@ public Bundle addAccount(AccountAuthenticatorResponse response,
122118
String authTokenType,
123119
String[] requiredFeatures,
124120
Bundle options) {
125-
if (isAddFromSettings(options)) {
126-
options.putAll(SalesforceSDKManager.getInstance().getLoginOptions().asBundle());
127-
}
128121
return makeAuthIntentBundle(response, options);
129122
}
130123

131-
private boolean isAddFromSettings(Bundle options) {
132-
return options.containsKey(ANDROID_PACKAGE_NAME)
133-
&& SETTINGS_PACKAGE_NAME.equals(options.getString(ANDROID_PACKAGE_NAME));
134-
}
135-
136124
@Override
137125
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account,
138126
String authTokenType, Bundle options) throws NetworkErrorException {
139-
140127
UserAccount originalUserAccount = UserAccountManager.getInstance().buildUserAccount(account);
141-
final Map<String,String> addlParamsMap = SalesforceSDKManager.getInstance().getLoginOptions().getAdditionalParameters();
128+
142129
try {
130+
final Map<String,String> addlParamsMap = originalUserAccount.getAdditionalOauthValues();
143131
final OAuth2.TokenEndpointResponse tr = OAuth2.refreshAuthToken(HttpAccess.DEFAULT,
144132
new URI(originalUserAccount.getLoginServer()), originalUserAccount.getClientId(), originalUserAccount.getRefreshToken(), addlParamsMap);
145133

@@ -172,10 +160,6 @@ public Bundle getAuthToken(AccountAuthenticatorResponse response, Account accoun
172160
}
173161
}
174162

175-
private String decryptUserData(AccountManager mgr, Account account, String key, String encryptionKey) {
176-
return SalesforceSDKManager.decrypt(mgr.getUserData(account, key), encryptionKey);
177-
}
178-
179163
private Bundle makeAuthIntentBundle(AccountAuthenticatorResponse response, Bundle options) {
180164
final Bundle reply = new Bundle();
181165
final Intent i = new Intent(context, SalesforceSDKManager.getInstance().getLoginActivityClass());

libs/SalesforceSDK/src/com/salesforce/androidsdk/auth/NativeLoginManager.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import android.util.Base64.NO_WRAP
3636
import android.util.Base64.URL_SAFE
3737
import android.util.Base64.encodeToString
3838
import android.util.Patterns.EMAIL_ADDRESS
39+
import androidx.core.os.bundleOf
3940
import com.salesforce.androidsdk.accounts.UserAccount
4041
import com.salesforce.androidsdk.app.SalesforceSDKManager
4142
import com.salesforce.androidsdk.auth.NativeLoginManager.StartRegistrationRequestBody.UserData
@@ -67,7 +68,7 @@ import com.salesforce.androidsdk.auth.interfaces.NativeLoginResult.Success
6768
import com.salesforce.androidsdk.auth.interfaces.NativeLoginResult.UnknownError
6869
import com.salesforce.androidsdk.auth.interfaces.OtpRequestResult
6970
import com.salesforce.androidsdk.auth.interfaces.OtpVerificationMethod
70-
import com.salesforce.androidsdk.rest.ClientManager.LoginOptions
71+
import com.salesforce.androidsdk.rest.LoginOptions
7172
import com.salesforce.androidsdk.rest.RestClient.AsyncRequestCallback
7273
import com.salesforce.androidsdk.rest.RestRequest
7374
import com.salesforce.androidsdk.rest.RestRequest.RestEndpoint.LOGIN
@@ -170,9 +171,7 @@ internal class NativeLoginManager(
170171
val context = SalesforceSDKManager.getInstance().appContext
171172
val intent = Intent(context, SalesforceSDKManager.getInstance().webViewLoginActivityClass)
172173
intent.setFlags(FLAG_ACTIVITY_SINGLE_TOP)
173-
val options = SalesforceSDKManager.getInstance().loginOptions.asBundle()
174-
options.putBoolean(SHOW_BIOMETRIC, bioAuthLocked)
175-
intent.putExtras(options)
174+
intent.putExtras(bundleOf(SHOW_BIOMETRIC to bioAuthLocked))
176175
Bundle().putParcelable(KEY_INTENT, intent)
177176

178177
return intent
@@ -198,7 +197,7 @@ internal class NativeLoginManager(
198197

199198
private suspend fun suspendFinishAuthFlow(tokenResponse: RestResponse): NativeLoginResult {
200199
val appContext = SalesforceSDKManager.getInstance().appContext
201-
val loginOptions = LoginOptions(loginUrl, redirectUri, clientId, emptyArray<String>())
200+
val loginOptions = LoginOptions(loginUrl, clientId, emptyArray<String>())
202201
val tokenEndpointResponse = TokenEndpointResponse(tokenResponse.rawResponse)
203202
tokenResponse.consumeQuietly()
204203

libs/SalesforceSDK/src/com/salesforce/androidsdk/auth/idp/IDPAuthCodeHelper.kt

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import com.salesforce.androidsdk.R
3434
import com.salesforce.androidsdk.accounts.UserAccount
3535
import com.salesforce.androidsdk.app.SalesforceSDKManager
3636
import com.salesforce.androidsdk.auth.OAuth2.getAuthorizationUrl
37-
import com.salesforce.androidsdk.config.BootConfig
3837
import com.salesforce.androidsdk.rest.ClientManager
3938
import com.salesforce.androidsdk.rest.RestClient
4039
import com.salesforce.androidsdk.rest.RestRequest
@@ -94,18 +93,8 @@ internal class IDPAuthCodeHelper private constructor(
9493
private fun buildRestClient(): RestClient? {
9594
SalesforceSDKLogger.d(TAG, "Building rest client")
9695
val context = SalesforceSDKManager.getInstance().appContext
97-
val bootConfig = BootConfig.getBootConfig(context)
98-
val idpCallbackUrl = bootConfig.oauthRedirectURI
99-
val idpClientId = bootConfig.remoteAccessConsumerKey
100-
val idpScopes = bootConfig.oauthScopes
101-
val loginOptions = ClientManager.LoginOptions(
102-
userAccount.loginServer, idpCallbackUrl, idpClientId, idpScopes
103-
)
10496
val idpAccountType = SalesforceSDKManager.getInstance().accountType
105-
val clientManager = ClientManager(
106-
context, idpAccountType,
107-
loginOptions, false
108-
)
97+
val clientManager = ClientManager(context, idpAccountType, false)
10998
return clientManager.peekRestClient(userAccount)
11099
}
111100

libs/SalesforceSDK/src/com/salesforce/androidsdk/auth/idp/SPAuthCodeHelper.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import com.salesforce.androidsdk.accounts.UserAccount
3232
import com.salesforce.androidsdk.auth.HttpAccess
3333
import com.salesforce.androidsdk.auth.OAuth2
3434
import com.salesforce.androidsdk.auth.OAuth2.TokenEndpointResponse
35-
import com.salesforce.androidsdk.rest.ClientManager
35+
import com.salesforce.androidsdk.rest.LoginOptions
3636
import com.salesforce.androidsdk.ui.OAuthWebviewHelper
3737
import com.salesforce.androidsdk.ui.OAuthWebviewHelper.OAuthWebviewHelperEvents
3838
import com.salesforce.androidsdk.util.LogUtil
@@ -88,13 +88,10 @@ internal class SPAuthCodeHelper private constructor (
8888
}
8989

9090
private fun completeLogin(tokenResponse: TokenEndpointResponse) {
91-
val loginOptions = ClientManager.LoginOptions(
91+
val loginOptions = LoginOptions(
9292
loginUrl,
93-
spConfig.oauthCallbackUrl,
9493
spConfig.oauthClientId,
9594
spConfig.oauthScopes,
96-
null,
97-
null
9895
)
9996

10097
val oauthHelper = OAuthWebviewHelper(context, this, loginOptions)

0 commit comments

Comments
 (0)