android: Show different error message depending on IMC state
authorTobias Brunner <tobias@strongswan.org>
Thu, 16 May 2013 11:32:50 +0000 (13:32 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 8 Jul 2013 16:49:28 +0000 (18:49 +0200)
src/frontends/android/res/values-de/strings.xml
src/frontends/android/res/values-pl/strings.xml
src/frontends/android/res/values-ru/strings.xml
src/frontends/android/res/values-ua/strings.xml
src/frontends/android/res/values/strings.xml
src/frontends/android/src/org/strongswan/android/ui/VpnStateFragment.java

index 3181e0a..77bbbe7 100644 (file)
@@ -94,6 +94,7 @@
     <string name="error_unreachable">Gateway ist nicht erreichbar.</string>
     <string name="error_peer_auth_failed">Authentifizierung des Gateway ist fehlgeschlagen.</string>
     <string name="error_auth_failed">Benutzerauthentifizierung ist fehlgeschlagen.</string>
+    <string name="error_assessment_failed">Sicherheitsassessment ist fehlgeschlagen.</string>
     <string name="error_generic">Unbekannter Fehler während des Verbindens.</string>
     <string name="connecting_title">Verbinden: %1$s</string>
     <string name="connecting_message">Verbinde mit \""%1$s\".</string>
index 3ba5e16..9a54715 100644 (file)
@@ -96,6 +96,7 @@
     <string name="error_unreachable">Bramka jest nieosiągalna</string>
     <string name="error_peer_auth_failed">Błąd przy weryfikacji bramki</string>
     <string name="error_auth_failed">Błąd przy autoryzacji użytkownika</string>
+    <string name="error_assessment_failed">Security assessment failed.</string>
     <string name="error_generic">Nieznany błąd w czasie połączenia</string>
     <string name="connecting_title">Łączenie: %1$s</string>
     <string name="connecting_message">Tworzenie tunelu VPN z \""%1$s\".</string>
index afa2136..9ff1eff 100644 (file)
@@ -91,6 +91,7 @@
     <string name="error_unreachable">Шлюз недоступен.</string>
     <string name="error_peer_auth_failed">Ошибка авторизаци при подключении к шлюзу.</string>
     <string name="error_auth_failed">Ошибка авторизации пользователя.</string>
+    <string name="error_assessment_failed">Security assessment failed.</string>
     <string name="error_generic">Неизвестная ошибка.</string>
     <string name="connecting_title">Подключение: %1$s</string>
     <string name="connecting_message">Подключение к VPN с \""%1$s\".</string>
index 953ba0a..e420a35 100644 (file)
@@ -92,6 +92,7 @@
     <string name="error_unreachable">Немає зв\'язку зі шлюзом.</string>
     <string name="error_peer_auth_failed">Помилка перевірки данних аутентифікації шлюза.</string>
     <string name="error_auth_failed">Помилка аутентифікації користувача.</string>
+    <string name="error_assessment_failed">Security assessment failed.</string>
     <string name="error_generic">Невідома помилка під час підключення.</string>
     <string name="connecting_title">Підключення: %1$s</string>
     <string name="connecting_message">Підключення VPN з \""%1$s\".</string>
index c91bce4..e7b7fb6 100644 (file)
@@ -94,6 +94,7 @@
     <string name="error_unreachable">Gateway is unreachable.</string>
     <string name="error_peer_auth_failed">Verifying gateway authentication failed.</string>
     <string name="error_auth_failed">User authentication failed.</string>
+    <string name="error_assessment_failed">Security assessment failed.</string>
     <string name="error_generic">Unspecified failure while connecting.</string>
     <string name="connecting_title">Connecting: %1$s</string>
     <string name="connecting_message">Establishing VPN with \""%1$s\".</string>
index 6aec7e7..d745d83 100644 (file)
@@ -23,6 +23,7 @@ import org.strongswan.android.logic.VpnStateService;
 import org.strongswan.android.logic.VpnStateService.ErrorState;
 import org.strongswan.android.logic.VpnStateService.State;
 import org.strongswan.android.logic.VpnStateService.VpnStateListener;
+import org.strongswan.android.logic.imc.ImcState;
 
 import android.app.AlertDialog;
 import android.app.Fragment;
@@ -45,6 +46,7 @@ import android.widget.TextView;
 public class VpnStateFragment extends Fragment implements VpnStateListener
 {
        private static final String KEY_ERROR = "error";
+       private static final String KEY_IMC_STATE = "imc_state";
        private static final String KEY_NAME = "name";
 
        private TextView mProfileNameView;
@@ -56,6 +58,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
        private State mState;
        private AlertDialog mErrorDialog;
        private ErrorState mError;
+       private ImcState mImcState;
        private String mErrorProfileName;
        private VpnStateService mService;
        private final ServiceConnection mServiceConnection = new ServiceConnection() {
@@ -85,9 +88,11 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
                                                        mServiceConnection, Service.BIND_AUTO_CREATE);
 
                mError = ErrorState.NO_ERROR;
+               mImcState = ImcState.UNKNOWN;
                if (savedInstanceState != null && savedInstanceState.containsKey(KEY_ERROR))
                {
                        mError = (ErrorState)savedInstanceState.getSerializable(KEY_ERROR);
+                       mImcState = (ImcState)savedInstanceState.getSerializable(KEY_IMC_STATE);
                        mErrorProfileName = savedInstanceState.getString(KEY_NAME);
                }
        }
@@ -98,6 +103,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
                super.onSaveInstanceState(outState);
 
                outState.putSerializable(KEY_ERROR, mError);
+               outState.putSerializable(KEY_IMC_STATE, mImcState);
                outState.putString(KEY_NAME, mErrorProfileName);
        }
 
@@ -167,6 +173,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
        {
                State state = mService.getState();
                ErrorState error = ErrorState.NO_ERROR;
+               ImcState imcState = ImcState.UNKNOWN;
                String name = "", gateway = "";
 
                if (state != State.DISABLED)
@@ -178,9 +185,10 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
                                gateway = profile.getGateway();
                        }
                        error = mService.getErrorState();
+                       imcState = mService.getImcState();
                }
 
-               if (reportError(name, state, error))
+               if (reportError(name, state, error, imcState))
                {
                        return;
                }
@@ -223,16 +231,18 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
                }
        }
 
-       private boolean reportError(String name, State state, ErrorState error)
+       private boolean reportError(String name, State state, ErrorState error, ImcState imcState)
        {
                if (mError != ErrorState.NO_ERROR)
                {       /* we are currently reporting an error which was not yet dismissed */
                        error = mError;
+                       imcState = mImcState;
                        name = mErrorProfileName;
                }
                else if (error != ErrorState.NO_ERROR && (state == State.CONNECTING || state == State.CONNECTED))
                {       /* while initiating we report errors */
                        mError = error;
+                       mImcState = imcState;
                        mErrorProfileName = name;
                }
                else
@@ -257,7 +267,14 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
                switch (error)
                {
                        case AUTH_FAILED:
-                               showErrorDialog(R.string.error_auth_failed);
+                               if (imcState == ImcState.BLOCK)
+                               {
+                                       showErrorDialog(R.string.error_assessment_failed);
+                               }
+                               else
+                               {
+                                       showErrorDialog(R.string.error_auth_failed);
+                               }
                                break;
                        case PEER_AUTH_FAILED:
                                showErrorDialog(R.string.error_peer_auth_failed);
@@ -308,6 +325,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
        private void clearError()
        {
                mError = ErrorState.NO_ERROR;
+               mImcState = ImcState.UNKNOWN;
                updateView();
        }