Search in sources :

Example 6 with AuthenticationManager

use of org.eyeseetea.malariacare.data.authentication.AuthenticationManager in project pictureapp by EyeSeeTea.

the class DashboardActivity method executeLogout.

public void executeLogout() {
    IAuthenticationManager iAuthenticationManager = new AuthenticationManager(this);
    LogoutUseCase logoutUseCase = new LogoutUseCase(iAuthenticationManager);
    AlarmPushReceiver.cancelPushAlarm(this);
    logoutUseCase.execute(new LogoutUseCase.Callback() {

        @Override
        public void onLogoutSuccess() {
            DashboardActivityStrategy.onLogoutSuccess();
        }

        @Override
        public void onLogoutError(String message) {
            Log.e("." + this.getClass().getSimpleName(), message);
        }
    });
}
Also used : IAuthenticationManager(org.eyeseetea.malariacare.domain.boundary.IAuthenticationManager) AuthenticationManager(org.eyeseetea.malariacare.data.authentication.AuthenticationManager) IAuthenticationManager(org.eyeseetea.malariacare.domain.boundary.IAuthenticationManager) LogoutUseCase(org.eyeseetea.malariacare.domain.usecase.LogoutUseCase)

Example 7 with AuthenticationManager

use of org.eyeseetea.malariacare.data.authentication.AuthenticationManager in project pictureapp by EyeSeeTea.

the class LoginActivityStrategy method checkCredentials.

@Override
public void checkCredentials(Credentials credentials, final Callback callback) {
    ICredentialsRepository credentialsLocalDataSource = new CredentialsLocalDataSource();
    Credentials savedCredentials = credentialsLocalDataSource.getOrganisationCredentials();
    if (savedCredentials == null || savedCredentials.isEmpty() || savedCredentials.getUsername().equals(credentials.getUsername()) && (!savedCredentials.getPassword().equals(credentials.getPassword()) || !savedCredentials.getServerURL().equals(credentials.getServerURL()))) {
        callback.onSuccessDoLogin();
    } else if (savedCredentials.getUsername().equals(credentials.getUsername()) && savedCredentials.getPassword().equals(credentials.getPassword()) && savedCredentials.getServerURL().equals(credentials.getServerURL())) {
        callback.onSuccess();
    } else {
        IAuthenticationManager iAuthenticationManager = new AuthenticationManager(loginActivity);
        LogoutUseCase logoutUseCase = new LogoutUseCase(iAuthenticationManager);
        AlarmPushReceiver.cancelPushAlarm(loginActivity);
        logoutUseCase.execute(new LogoutUseCase.Callback() {

            @Override
            public void onLogoutSuccess() {
                callback.onSuccessDoLogin();
            }

            @Override
            public void onLogoutError(String message) {
                callback.onError();
            }
        });
    }
}
Also used : IAuthenticationManager(org.eyeseetea.malariacare.domain.boundary.IAuthenticationManager) AuthenticationManager(org.eyeseetea.malariacare.data.authentication.AuthenticationManager) IAuthenticationManager(org.eyeseetea.malariacare.domain.boundary.IAuthenticationManager) LogoutUseCase(org.eyeseetea.malariacare.domain.usecase.LogoutUseCase) CredentialsLocalDataSource(org.eyeseetea.malariacare.data.database.CredentialsLocalDataSource) Credentials(org.eyeseetea.malariacare.domain.entity.Credentials) ICredentialsRepository(org.eyeseetea.malariacare.domain.boundary.repositories.ICredentialsRepository)

Example 8 with AuthenticationManager

use of org.eyeseetea.malariacare.data.authentication.AuthenticationManager in project pictureapp by EyeSeeTea.

the class BaseActivityStrategy method onCreate.

@Override
public void onCreate() {
    mAuthenticationManager = new AuthenticationManager(mBaseActivity);
    mLogoutUseCase = new LogoutUseCase(mAuthenticationManager);
}
Also used : IAuthenticationManager(org.eyeseetea.malariacare.domain.boundary.IAuthenticationManager) AuthenticationManager(org.eyeseetea.malariacare.data.authentication.AuthenticationManager) LogoutUseCase(org.eyeseetea.malariacare.domain.usecase.LogoutUseCase)

Aggregations

AuthenticationManager (org.eyeseetea.malariacare.data.authentication.AuthenticationManager)8 LogoutUseCase (org.eyeseetea.malariacare.domain.usecase.LogoutUseCase)7 IAuthenticationManager (org.eyeseetea.malariacare.domain.boundary.IAuthenticationManager)6 Intent (android.content.Intent)2 LoginActivity (org.eyeseetea.malariacare.LoginActivity)2 CredentialsLocalDataSource (org.eyeseetea.malariacare.data.database.CredentialsLocalDataSource)2 IAsyncExecutor (org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor)2 IMainExecutor (org.eyeseetea.malariacare.domain.boundary.executors.IMainExecutor)2 ICredentialsRepository (org.eyeseetea.malariacare.domain.boundary.repositories.ICredentialsRepository)2 Credentials (org.eyeseetea.malariacare.domain.entity.Credentials)2 AsyncExecutor (org.eyeseetea.malariacare.presentation.executors.AsyncExecutor)2 UIThreadExecutor (org.eyeseetea.malariacare.presentation.executors.UIThreadExecutor)2 IntentFilter (android.content.IntentFilter)1 InvalidLoginAttemptsRepositoryLocalDataSource (org.eyeseetea.malariacare.data.database.InvalidLoginAttemptsRepositoryLocalDataSource)1 OrganisationUnitRepository (org.eyeseetea.malariacare.data.repositories.OrganisationUnitRepository)1 PullController (org.eyeseetea.malariacare.data.sync.importer.PullController)1 IPullController (org.eyeseetea.malariacare.domain.boundary.IPullController)1 IInvalidLoginAttemptsRepository (org.eyeseetea.malariacare.domain.boundary.repositories.IInvalidLoginAttemptsRepository)1 IOrganisationUnitRepository (org.eyeseetea.malariacare.domain.boundary.repositories.IOrganisationUnitRepository)1 ALoginUseCase (org.eyeseetea.malariacare.domain.usecase.ALoginUseCase)1