summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-07-01 07:18:36 +0200
committerVincent Petry <pvince81@owncloud.com>2015-07-01 07:18:36 +0200
commitb921748e61a05b65e9d58221bb2c44b02befb64d (patch)
treede822e6a7a5af2683c2bb0b8c62288f26f366716 /lib/private
parentf76773bd4c7816ffedf3e7b09029367ad82e3093 (diff)
parent134dc136e66f7ead2e4ffc7d74711e1d9a8dc58d (diff)
downloadnextcloud-server-b921748e61a05b65e9d58221bb2c44b02befb64d.tar.gz
nextcloud-server-b921748e61a05b65e9d58221bb2c44b02befb64d.zip
Merge pull request #17224 from owncloud/webdav-handle-ServerNotAvailableException
Adding exception handling for ServerNotAvailableException
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/connector/sabre/auth.php44
1 files changed, 29 insertions, 15 deletions
diff --git a/lib/private/connector/sabre/auth.php b/lib/private/connector/sabre/auth.php
index 5a32a9112ba..8a6eaab5bf8 100644
--- a/lib/private/connector/sabre/auth.php
+++ b/lib/private/connector/sabre/auth.php
@@ -30,7 +30,12 @@
*/
namespace OC\Connector\Sabre;
-class Auth extends \Sabre\DAV\Auth\Backend\AbstractBasic {
+use Exception;
+use Sabre\DAV\Auth\Backend\AbstractBasic;
+use Sabre\DAV\Exception\NotAuthenticated;
+use Sabre\DAV\Exception\ServiceUnavailable;
+
+class Auth extends AbstractBasic {
const DAV_AUTHENTICATED = 'AUTHENTICATED_TO_DAV_BACKEND';
/**
@@ -69,7 +74,7 @@ class Auth extends \Sabre\DAV\Auth\Backend\AbstractBasic {
} else {
\OC_Util::setUpFS(); //login hooks may need early access to the filesystem
if(\OC_User::login($username, $password)) {
- // make sure we use owncloud's internal username here
+ // make sure we use ownCloud's internal username here
// and not the HTTP auth supplied one, see issue #14048
$ocUser = \OC_User::getUser();
\OC_Util::setUpFS($ocUser);
@@ -99,21 +104,30 @@ class Auth extends \Sabre\DAV\Auth\Backend\AbstractBasic {
}
/**
- * Override function here. We want to cache authentication cookies
- * in the syncing client to avoid HTTP-401 roundtrips.
- * If the sync client supplies the cookies, then OC_User::isLoggedIn()
- * will return true and we can see this WebDAV request as already authenticated,
- * even if there are no HTTP Basic Auth headers.
- * In other case, just fallback to the parent implementation.
- *
- * @param \Sabre\DAV\Server $server
- * @param $realm
- * @return bool
- */
+ * Override function here. We want to cache authentication cookies
+ * in the syncing client to avoid HTTP-401 roundtrips.
+ * If the sync client supplies the cookies, then OC_User::isLoggedIn()
+ * will return true and we can see this WebDAV request as already authenticated,
+ * even if there are no HTTP Basic Auth headers.
+ * In other case, just fallback to the parent implementation.
+ *
+ * @param \Sabre\DAV\Server $server
+ * @param string $realm
+ * @return bool
+ * @throws ServiceUnavailable
+ */
public function authenticate(\Sabre\DAV\Server $server, $realm) {
- $result = $this->auth($server, $realm);
- return $result;
+ try {
+ $result = $this->auth($server, $realm);
+ return $result;
+ } catch (NotAuthenticated $e) {
+ throw $e;
+ } catch (Exception $e) {
+ $class = get_class($e);
+ $msg = $e->getMessage();
+ throw new ServiceUnavailable("$class: $msg");
+ }
}
/**