use of org.eyeseetea.malariacare.domain.entity.Credentials in project pictureapp by EyeSeeTea.
the class AuthenticationManager method getServerCredentials.
public Credentials getServerCredentials(String serverUrl) {
String username = PreferencesState.getInstance().getContext().getString(R.string.user_push);
String password = PreferencesState.getInstance().getContext().getString(R.string.pass_push);
Credentials credentials = new Credentials(serverUrl, username, password);
return credentials;
}
use of org.eyeseetea.malariacare.domain.entity.Credentials in project pictureapp by EyeSeeTea.
the class LoadUserAndCredentialsUseCase method loadCredentials.
private void loadCredentials() {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
String serverURL = sharedPreferences.getString(mContext.getString(R.string.dhis_url), "");
String username = sharedPreferences.getString(mContext.getString(R.string.dhis_user), "");
String password = sharedPreferences.getString(mContext.getString(R.string.dhis_password), "");
Credentials credentials = new Credentials(serverURL, username, password);
Session.setCredentials(credentials);
}
use of org.eyeseetea.malariacare.domain.entity.Credentials in project pictureapp by EyeSeeTea.
the class LoginActivity method login.
public void login(String serverUrl, String username, String password) {
final Credentials credentials = new Credentials(serverUrl, username, password);
onStartLoading();
mLoginActivityStrategy.checkCredentials(credentials, new ALoginActivityStrategy.Callback() {
@Override
public void onSuccess() {
mLoginActivityStrategy.onLoginSuccess(credentials);
}
@Override
public void onSuccessDoLogin() {
executeLoginUseCase(credentials);
}
@Override
public void onError() {
hideProgressBar();
showError(getString(R.string.login_unexpected_error));
}
});
}
use of org.eyeseetea.malariacare.domain.entity.Credentials in project pictureapp by EyeSeeTea.
the class PreferencesState method getCredentialsFromPreferences.
/**
* Get credentials from sharedPreferences.
*/
public static Credentials getCredentialsFromPreferences() {
Context context = PreferencesState.getInstance().getContext();
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
String url = sharedPreferences.getString(context.getString(R.string.dhis_url), "");
String username = sharedPreferences.getString(context.getString(R.string.dhis_user), "");
String password = sharedPreferences.getString(context.getString(R.string.dhis_password), "");
Credentials credentials = new Credentials(url, username, password);
return credentials;
}
use of org.eyeseetea.malariacare.domain.entity.Credentials in project pictureapp by EyeSeeTea.
the class PushServiceStrategy method push.
@Override
public void push() {
IAuthenticationManager authenticationManager = new AuthenticationManager(PreferencesState.getInstance().getContext());
IMainExecutor mainExecutor = new UIThreadExecutor();
IAsyncExecutor asyncExecutor = new AsyncExecutor();
ICredentialsRepository credentialsLocalDataSoruce = new CredentialsLocalDataSource();
IOrganisationUnitRepository organisationDataSource = new OrganisationUnitRepository();
IInvalidLoginAttemptsRepository iInvalidLoginAttemptsRepository = new InvalidLoginAttemptsRepositoryLocalDataSource();
LoginUseCase loginUseCase = new LoginUseCase(authenticationManager, mainExecutor, asyncExecutor, organisationDataSource, credentialsLocalDataSoruce, iInvalidLoginAttemptsRepository);
final Credentials oldCredentials = credentialsLocalDataSoruce.getOrganisationCredentials();
loginUseCase.execute(oldCredentials, new ALoginUseCase.Callback() {
@Override
public void onLoginSuccess() {
PushServiceStrategy.this.onCorrectCredentials();
}
@Override
public void onServerURLNotValid() {
Log.e(TAG, "Error getting user credentials: URL not valid ");
}
@Override
public void onInvalidCredentials() {
logout();
}
@Override
public void onNetworkError() {
Log.e(TAG, "Error getting user credentials: NetworkError");
}
@Override
public void onConfigJsonInvalid() {
Log.e(TAG, "Error getting user credentials: JsonInvalid");
}
@Override
public void onUnexpectedError() {
Log.e(TAG, "Error getting user credentials: unexpectedError ");
}
@Override
public void onMaxLoginAttemptsReachedError() {
}
});
}
Aggregations