use of com.salesforce.androidsdk.rest.ClientManager in project SalesforceMobileSDK-Android by forcedotcom.
the class SalesforceSDKManager method logout.
/**
* Destroys the stored authentication credentials (removes the account)
* and, if requested, restarts the app.
*
* @param frontActivity Front activity.
* @param showLoginPage If true, displays the login page after removing the account.
*/
public void logout(Activity frontActivity, final boolean showLoginPage) {
final ClientManager clientMgr = new ClientManager(context, getAccountType(), null, shouldLogoutWhenTokenRevoked());
final Account account = clientMgr.getAccount();
logout(account, frontActivity, showLoginPage);
}
use of com.salesforce.androidsdk.rest.ClientManager in project SalesforceMobileSDK-Android by forcedotcom.
the class SalesforceActivityDelegate method onResume.
/**
* Brings up ScreenLock if needed
* Build RestClient if requested and then calls activity.onResume(restClient)
* Otherwise calls activity.onResume(null)
*
* @param buildRestClient
*/
public void onResume(boolean buildRestClient) {
// Brings up the ScreenLock if needed.
if (buildRestClient) {
// Gets login options.
final String accountType = SalesforceSDKManager.getInstance().getAccountType();
final ClientManager.LoginOptions loginOptions = SalesforceSDKManager.getInstance().getLoginOptions();
// Gets a rest client.
new ClientManager(SalesforceSDKManager.getInstance().getAppContext(), accountType, loginOptions, SalesforceSDKManager.getInstance().shouldLogoutWhenTokenRevoked()).getRestClient(activity, new ClientManager.RestClientCallback() {
@Override
public void authenticatedRestClient(RestClient client) {
if (client == null) {
SalesforceSDKManager.getInstance().logout(activity);
return;
}
((SalesforceActivityInterface) activity).onResume(client);
// Lets observers know that rendition is complete.
EventsObservable.get().notifyEvent(EventsObservable.EventType.RenditionComplete);
}
});
} else {
((SalesforceActivityInterface) activity).onResume(null);
}
}
use of com.salesforce.androidsdk.rest.ClientManager in project SalesforceMobileSDK-Android by forcedotcom.
the class IDPRequestHandler method buildRestClient.
private void buildRestClient() {
final Context context = SalesforceSDKManager.getInstance().getAppContext();
final BootConfig bootConfig = BootConfig.getBootConfig(context);
final String idpCallbackUrl = bootConfig.getOauthRedirectURI();
final String idpClientId = bootConfig.getRemoteAccessConsumerKey();
final String[] idpScopes = bootConfig.getOauthScopes();
final ClientManager.LoginOptions loginOptions = new ClientManager.LoginOptions(loginUrl, idpCallbackUrl, idpClientId, idpScopes);
final String idpAccountType = SalesforceSDKManager.getInstance().getAccountType();
final ClientManager clientManager = new ClientManager(context, idpAccountType, loginOptions, false);
restClient = clientManager.peekRestClient(userAccount);
}
use of com.salesforce.androidsdk.rest.ClientManager in project SalesforceMobileSDK-Android by forcedotcom.
the class ManagerTestCase method setUp.
public void setUp() throws Exception {
targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
apiVersion = ApiVersionStrings.getVersionNumber(targetContext);
final Application app = Instrumentation.newApplication(TestForceApp.class, targetContext);
InstrumentationRegistry.getInstrumentation().callApplicationOnCreate(app);
TestCredentials.init(InstrumentationRegistry.getInstrumentation().getContext());
eq = new EventsListenerQueue();
if (MobileSyncSDKManager.getInstance() == null) {
eq.waitForEvent(EventType.AppCreateComplete, 5000);
}
final LoginOptions loginOptions = new LoginOptions(TestCredentials.LOGIN_URL, TEST_CALLBACK_URL, TestCredentials.CLIENT_ID, TEST_SCOPES);
final ClientManager clientManager = new ClientManager(targetContext, TestCredentials.ACCOUNT_TYPE, loginOptions, true);
clientManager.createNewAccount(TestCredentials.ACCOUNT_NAME, TestCredentials.USERNAME, TestCredentials.REFRESH_TOKEN, TEST_AUTH_TOKEN, TestCredentials.INSTANCE_URL, TestCredentials.LOGIN_URL, TestCredentials.IDENTITY_URL, TestCredentials.CLIENT_ID, TestCredentials.ORG_ID, TestCredentials.USER_ID, null, null, null, null, null, null, TestCredentials.PHOTO_URL, null, null, null, null, null, null, null, null, null);
SyncManager.reset();
sdkManager = MobileSyncSDKManager.getInstance();
smartStore = sdkManager.getSmartStore();
globalSmartStore = sdkManager.getGlobalSmartStore();
syncManager = SyncManager.getInstance();
globalSyncManager = SyncManager.getInstance(null, null, globalSmartStore);
restClient = initRestClient();
syncManager.setRestClient(restClient);
MobileSyncLogger.setLogLevel(SalesforceLogger.Level.DEBUG);
}
Aggregations