diff --git a/app/src/main/java/at/bitfire/davdroid/journalmanager/JournalAuthenticator.java b/app/src/main/java/at/bitfire/davdroid/journalmanager/JournalAuthenticator.java index baafd298..cf31f970 100644 --- a/app/src/main/java/at/bitfire/davdroid/journalmanager/JournalAuthenticator.java +++ b/app/src/main/java/at/bitfire/davdroid/journalmanager/JournalAuthenticator.java @@ -31,7 +31,7 @@ public class JournalAuthenticator { } } - public String getAuthToken(String username, String password) throws Exceptions.HttpException { + public String getAuthToken(String username, String password) throws Exceptions.HttpException, IOException { FormBody.Builder formBuilder = new FormBody.Builder() .add("username", username) .add("password", password); @@ -41,19 +41,13 @@ public class JournalAuthenticator { .url(remote) .build(); - try { - Response response = client.newCall(request).execute(); - if (response.isSuccessful()) { - return GsonHelper.gson.fromJson(response.body().charStream(), AuthResponse.class).token; - } else if (response.code() == HttpURLConnection.HTTP_BAD_REQUEST) { - throw new Exceptions.UnauthorizedException("Username or password incorrect"); - } else { - throw new Exceptions.HttpException(response); - } - } catch (IOException e) { - App.log.log(Level.SEVERE, "Couldn't download external resource", e); + Response response = client.newCall(request).execute(); + if (response.isSuccessful()) { + return GsonHelper.gson.fromJson(response.body().charStream(), AuthResponse.class).token; + } else if (response.code() == HttpURLConnection.HTTP_BAD_REQUEST) { + throw new Exceptions.UnauthorizedException("Username or password incorrect"); + } else { + throw new Exceptions.HttpException(response); } - - return null; } } diff --git a/app/src/main/java/at/bitfire/davdroid/ui/setup/BaseConfigurationFinder.java b/app/src/main/java/at/bitfire/davdroid/ui/setup/BaseConfigurationFinder.java index 4e1806a9..738f6f1f 100644 --- a/app/src/main/java/at/bitfire/davdroid/ui/setup/BaseConfigurationFinder.java +++ b/app/src/main/java/at/bitfire/davdroid/ui/setup/BaseConfigurationFinder.java @@ -10,6 +10,7 @@ package at.bitfire.davdroid.ui.setup; import android.content.Context; import android.support.annotation.NonNull; +import java.io.IOException; import java.io.Serializable; import java.net.URI; import java.util.HashMap; @@ -59,7 +60,7 @@ public class BaseConfigurationFinder { String authtoken = null; try { authtoken = authenticator.getAuthToken(credentials.userName, credentials.password); - } catch (Exceptions.HttpException e) { + } catch (Exceptions.HttpException|IOException e) { log.warning(e.getMessage()); failed = true;