Setup: always show 401 Unauthorized errors

* also increase version code and version to 0.6.3
pull/2/head
rfc2822 10 years ago
parent 5e5da95e23
commit ebe13cef5e

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="at.bitfire.davdroid"
android:versionCode="40"
android:versionName="0.6.2" android:installLocation="internalOnly">
android:versionCode="41"
android:versionName="0.6.3" android:installLocation="internalOnly">
<uses-sdk
android:minSdkVersion="14"

@ -15,6 +15,7 @@ import at.bitfire.davdroid.R;
import at.bitfire.davdroid.webdav.DavException;
import at.bitfire.davdroid.webdav.DavHttpClient;
import at.bitfire.davdroid.webdav.DavIncapableException;
import at.bitfire.davdroid.webdav.NotAuthorizedException;
import at.bitfire.davdroid.webdav.WebDavResource;
import at.bitfire.davdroid.webdav.HttpPropfind.Mode;
@ -127,15 +128,18 @@ public class DavResourceFinder {
* @param serviceName Well-known service name ("carddav", "caldav")
* @return WebDavResource of current-user-principal for the given service, or null if it can't be found
*/
private static WebDavResource getCurrentUserPrincipal(WebDavResource resource, String serviceName) throws IOException, HttpException, DavException {
private static WebDavResource getCurrentUserPrincipal(WebDavResource resource, String serviceName) throws IOException, NotAuthorizedException {
// look for well-known service (RFC 5785)
try {
WebDavResource wellKnown = new WebDavResource(resource, "/.well-known/" + serviceName);
wellKnown.propfind(Mode.CURRENT_USER_PRINCIPAL);
if (wellKnown.getCurrentUserPrincipal() != null)
return new WebDavResource(wellKnown, wellKnown.getCurrentUserPrincipal());
} catch (NotAuthorizedException e) {
Log.d(TAG, "Well-known " + serviceName + " service detection not authorized", e);
throw e;
} catch (HttpException e) {
Log.d(TAG, "well-known " + serviceName + " service detection failed with HTTP error", e);
Log.d(TAG, "Well-known " + serviceName + " service detection failed with HTTP error", e);
} catch (DavException e) {
Log.d(TAG, "Well-known " + serviceName + " service detection failed at DAV level", e);
}
@ -145,6 +149,9 @@ public class DavResourceFinder {
resource.propfind(Mode.CURRENT_USER_PRINCIPAL);
if (resource.getCurrentUserPrincipal() != null)
return new WebDavResource(resource, resource.getCurrentUserPrincipal());
} catch (NotAuthorizedException e) {
Log.d(TAG, "Not authorized for querying principal for " + serviceName + " service", e);
throw e;
} catch (HttpException e) {
Log.d(TAG, "HTTP error when querying principal for " + serviceName + " service", e);
} catch (DavException e) {

@ -0,0 +1,12 @@
package at.bitfire.davdroid.webdav;
import org.apache.http.HttpStatus;
public class NotAuthorizedException extends HttpException {
private static final long serialVersionUID = 2490525047224413586L;
public NotAuthorizedException(String reason) {
super(HttpStatus.SC_UNAUTHORIZED, reason);
}
}

@ -416,6 +416,8 @@ public class WebDavResource {
String reason = code + " " + statusLine.getReasonPhrase();
switch (code) {
case HttpStatus.SC_UNAUTHORIZED:
throw new NotAuthorizedException(reason);
case HttpStatus.SC_NOT_FOUND:
throw new NotFoundException(reason);
case HttpStatus.SC_PRECONDITION_FAILED:

Loading…
Cancel
Save