mirror of
https://github.com/etesync/android
synced 2025-02-03 03:11:48 +00:00
Setup: always show 401 Unauthorized errors
* also increase version code and version to 0.6.3
This commit is contained in:
parent
5e5da95e23
commit
ebe13cef5e
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="at.bitfire.davdroid"
|
package="at.bitfire.davdroid"
|
||||||
android:versionCode="40"
|
android:versionCode="41"
|
||||||
android:versionName="0.6.2" android:installLocation="internalOnly">
|
android:versionName="0.6.3" android:installLocation="internalOnly">
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="14"
|
android:minSdkVersion="14"
|
||||||
|
@ -15,6 +15,7 @@ import at.bitfire.davdroid.R;
|
|||||||
import at.bitfire.davdroid.webdav.DavException;
|
import at.bitfire.davdroid.webdav.DavException;
|
||||||
import at.bitfire.davdroid.webdav.DavHttpClient;
|
import at.bitfire.davdroid.webdav.DavHttpClient;
|
||||||
import at.bitfire.davdroid.webdav.DavIncapableException;
|
import at.bitfire.davdroid.webdav.DavIncapableException;
|
||||||
|
import at.bitfire.davdroid.webdav.NotAuthorizedException;
|
||||||
import at.bitfire.davdroid.webdav.WebDavResource;
|
import at.bitfire.davdroid.webdav.WebDavResource;
|
||||||
import at.bitfire.davdroid.webdav.HttpPropfind.Mode;
|
import at.bitfire.davdroid.webdav.HttpPropfind.Mode;
|
||||||
|
|
||||||
@ -127,15 +128,18 @@ public class DavResourceFinder {
|
|||||||
* @param serviceName Well-known service name ("carddav", "caldav")
|
* @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
|
* @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)
|
// look for well-known service (RFC 5785)
|
||||||
try {
|
try {
|
||||||
WebDavResource wellKnown = new WebDavResource(resource, "/.well-known/" + serviceName);
|
WebDavResource wellKnown = new WebDavResource(resource, "/.well-known/" + serviceName);
|
||||||
wellKnown.propfind(Mode.CURRENT_USER_PRINCIPAL);
|
wellKnown.propfind(Mode.CURRENT_USER_PRINCIPAL);
|
||||||
if (wellKnown.getCurrentUserPrincipal() != null)
|
if (wellKnown.getCurrentUserPrincipal() != null)
|
||||||
return new WebDavResource(wellKnown, wellKnown.getCurrentUserPrincipal());
|
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) {
|
} 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) {
|
} catch (DavException e) {
|
||||||
Log.d(TAG, "Well-known " + serviceName + " service detection failed at DAV level", 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);
|
resource.propfind(Mode.CURRENT_USER_PRINCIPAL);
|
||||||
if (resource.getCurrentUserPrincipal() != null)
|
if (resource.getCurrentUserPrincipal() != null)
|
||||||
return new WebDavResource(resource, resource.getCurrentUserPrincipal());
|
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) {
|
} catch (HttpException e) {
|
||||||
Log.d(TAG, "HTTP error when querying principal for " + serviceName + " service", e);
|
Log.d(TAG, "HTTP error when querying principal for " + serviceName + " service", e);
|
||||||
} catch (DavException e) {
|
} catch (DavException e) {
|
||||||
|
12
src/at/bitfire/davdroid/webdav/NotAuthorizedException.java
Normal file
12
src/at/bitfire/davdroid/webdav/NotAuthorizedException.java
Normal file
@ -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();
|
String reason = code + " " + statusLine.getReasonPhrase();
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
case HttpStatus.SC_UNAUTHORIZED:
|
||||||
|
throw new NotAuthorizedException(reason);
|
||||||
case HttpStatus.SC_NOT_FOUND:
|
case HttpStatus.SC_NOT_FOUND:
|
||||||
throw new NotFoundException(reason);
|
throw new NotFoundException(reason);
|
||||||
case HttpStatus.SC_PRECONDITION_FAILED:
|
case HttpStatus.SC_PRECONDITION_FAILED:
|
||||||
|
Loading…
Reference in New Issue
Block a user