diff --git a/core/src/ocs.php b/core/src/ocs.php
index 448835ba89..2a9b18e0a4 100644
--- a/core/src/ocs.php
+++ b/core/src/ocs.php
@@ -32,7 +32,7 @@
require_once($confStorageDriver->getUserClassFileName());
/**
- * @var Pydio\OCS\Router $coreLoader
+ * @var Pydio\OCS\OCSPlugin $coreLoader
*/
$coreLoader = $pServ->getPluginById("core.ocs");
$configs = $coreLoader->getConfigs();
diff --git a/core/src/plugins/core.ocs/Router.php b/core/src/plugins/core.ocs/OCSPlugin.php
similarity index 99%
rename from core/src/plugins/core.ocs/Router.php
rename to core/src/plugins/core.ocs/OCSPlugin.php
index e979c434c8..d483b9b820 100644
--- a/core/src/plugins/core.ocs/Router.php
+++ b/core/src/plugins/core.ocs/OCSPlugin.php
@@ -24,7 +24,7 @@
require_once("vendor/autoload.php");
-class Router extends \AJXP_Plugin{
+class OCSPlugin extends \AJXP_Plugin{
public function federatedEnabled(){
return $this->getConfigs()["ENABLE_FEDERATED_SHARING"] === true;
@@ -69,9 +69,10 @@ public function route($endpoint, $uriParts, $parameters){
}
-
}
+
+
public function buildResponse($status = "ok", $code = 200, $message = null, $data = null){
$ocs = array(
diff --git a/core/src/plugins/core.ocs/service/class.OCS_DavBasicAuthNoPass.php b/core/src/plugins/core.ocs/service/class.OCS_DavBasicAuthNoPass.php
deleted file mode 100644
index a8f6965bb5..0000000000
--- a/core/src/plugins/core.ocs/service/class.OCS_DavBasicAuthNoPass.php
+++ /dev/null
@@ -1,74 +0,0 @@
-
- * This file is part of Pydio.
- *
- * Pydio is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Pydio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with Pydio. If not, see .
- *
- * The latest code can be found at .
- */
-
-defined('AJXP_EXEC') or die('Access not allowed');
-
-use Sabre\HTTP;
-
-class OCS_DavBasicAuthNoPass extends HTTP\BasicAuth
-{
- /**
- * Returns the supplied username and password.
- *
- * The returned array has two values:
- * * 0 - username
- * * 1 - password
- *
- * If nothing was supplied, 'false' will be returned
- *
- * @return mixed
- */
- public function getUserPass() {
-
- return self::parseUserPass($this->httpRequest);
-
- }
-
- public static function parseUserPass(Sabre\HTTP\Request $httpRequest){
-
- // Apache and mod_php
- if (($user = $httpRequest->getRawServerValue('PHP_AUTH_USER'))) {
- $pass = "";
- if(($passw = $httpRequest->getRawServerValue('PHP_AUTH_PW'))){
- $pass = $passw;
- }
- return array($user,$pass);
- }
-
- // Most other webservers
- $auth = $httpRequest->getHeader('Authorization');
-
- // Apache could prefix environment variables with REDIRECT_ when urls
- // are passed through mod_rewrite
- if (!$auth) {
- $auth = $httpRequest->getRawServerValue('REDIRECT_HTTP_AUTHORIZATION');
- }
-
- if (!$auth) return false;
-
- if (strpos(strtolower($auth),'basic')!==0) return false;
-
- return explode(':', base64_decode(substr($auth, 6)),2);
-
-
- }
-
-}
\ No newline at end of file
diff --git a/core/src/plugins/core.ocs/service/class.OCS_DavServer.php b/core/src/plugins/core.ocs/service/class.OCS_DavServer.php
deleted file mode 100644
index 452293e45b..0000000000
--- a/core/src/plugins/core.ocs/service/class.OCS_DavServer.php
+++ /dev/null
@@ -1,74 +0,0 @@
-
- * This file is part of Pydio.
- *
- * Pydio is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Pydio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with Pydio. If not, see .
- *
- * The latest code can be found at .
- */
-
-defined('AJXP_EXEC') or die('Access not allowed');
-
-/**
- * @param string $className
- * @return void
- */
-function AJXP_Sabre_autoload($className)
-{
- if (strpos($className,'AJXP_Sabre_')===0) {
- include AJXP_BIN_FOLDER. '/sabredav/ajaxplorer/class.' . $className . '.php';
- }
-}
-spl_autoload_register('AJXP_Sabre_autoload');
-include AJXP_INSTALL_PATH.'/core/classes/sabredav/lib/Sabre/autoload.php';
-require_once("class.OCS_DavAuthSharingBackend.php");
-
-class OCS_DavServer
-{
- public function start($baseUri = "/"){
-
- $rootCollection = new AJXP_Sabre_Collection("/", null, null);
- $server = new Sabre\DAV\Server($rootCollection);
- $server->setBaseUri($baseUri);
-
- $authBackend = new OCS_DavAuthSharingBackend($rootCollection);
- $authPlugin = new Sabre\DAV\Auth\Plugin($authBackend, ConfService::getCoreConf("WEBDAV_DIGESTREALM"));
- $server->addPlugin($authPlugin);
-
- if (!is_dir(AJXP_DATA_PATH."/plugins/server.sabredav")) {
- mkdir(AJXP_DATA_PATH."/plugins/server.sabredav", 0755);
- $fp = fopen(AJXP_DATA_PATH."/plugins/server.sabredav/locks", "w");
- fwrite($fp, "");
- fclose($fp);
- }
-
- $lockBackend = new Sabre\DAV\Locks\Backend\File(AJXP_DATA_PATH."/plugins/server.sabredav/locks");
- $lockPlugin = new Sabre\DAV\Locks\Plugin($lockBackend);
- $server->addPlugin($lockPlugin);
-
- if (ConfService::getCoreConf("WEBDAV_BROWSER_LISTING")) {
- $browerPlugin = new AJXP_Sabre_BrowserPlugin((isSet($repository)?$repository->getDisplay():null));
- $extPlugin = new Sabre\DAV\Browser\GuessContentType();
- $server->addPlugin($browerPlugin);
- $server->addPlugin($extPlugin);
- }
- try {
- $server->exec();
- } catch ( Exception $e ) {
- AJXP_Logger::error(__CLASS__,"Exception",$e->getMessage());
- }
- }
-
-}
\ No newline at end of file
diff --git a/core/src/plugins/core.ocs/src/Model/IStore.php b/core/src/plugins/core.ocs/src/Model/IStore.php
new file mode 100644
index 0000000000..db5b177a8d
--- /dev/null
+++ b/core/src/plugins/core.ocs/src/Model/IStore.php
@@ -0,0 +1,84 @@
+
+ * This file is part of Pydio.
+ *
+ * Pydio is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pydio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Pydio. If not, see .
+ *
+ * The latest code can be found at .
+ */
+
+namespace Pydio\OCS\Model;
+
+defined('AJXP_EXEC') or die('Access not allowed');
+
+interface IStore
+{
+ /**
+ * Persists an invitation to store
+ * @param ShareInvitation $invitation
+ * @return ShareInvitation|false The invitation with its new ID.
+ */
+ public function storeInvitation(ShareInvitation $invitation);
+
+ /**
+ * Find all invitatins for a given token
+ * @param string $linkToken
+ * @return ShareInvitation[]
+ */
+ public function invitationsForLink($linkToken);
+
+ /**
+ * Find an invitation by ID
+ * @param $invitationId
+ * @return ShareInvitation|null
+ */
+ public function invitationById(string $invitationId);
+
+ /**
+ * Delete an invitation
+ * @param ShareInvitation $invitation
+ * @return bool
+ */
+ public function deleteInvitation(ShareInvitation $invitation);
+
+ /**
+ * Persists a remote share to the store
+ * @param RemoteShare $remoteShare
+ * @return RemoteShare|false The share with eventually its new ID.
+ */
+ public function storeRemoteShare(RemoteShare $remoteShare);
+
+ /**
+ * Find all remote shares for a given user
+ * @param string $userName
+ * @return RemoteShare[]
+ */
+ public function remoteSharesForUser($userName);
+
+ /**
+ * Find a remote share by its id
+ * @param string $remoteShareId
+ * @return RemoteShare
+ */
+ public function remoteShareById($remoteShareId);
+
+ /**
+ * Delete an existing remote share
+ * @param RemoteShare $remoteShare
+ * @return bool
+ */
+ public function deleteRemoteShare(RemoteShare $remoteShare);
+
+}
\ No newline at end of file
diff --git a/core/src/plugins/core.ocs/src/Model/RemoteShare.php b/core/src/plugins/core.ocs/src/Model/RemoteShare.php
new file mode 100644
index 0000000000..0ec46a6d7d
--- /dev/null
+++ b/core/src/plugins/core.ocs/src/Model/RemoteShare.php
@@ -0,0 +1,204 @@
+
+ * This file is part of Pydio.
+ *
+ * Pydio is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pydio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Pydio. If not, see .
+ *
+ * The latest code can be found at .
+ */
+namespace Pydio\OCS\Model;
+
+defined('AJXP_EXEC') or die('Access not allowed');
+
+
+class RemoteShare
+{
+ /**
+ * @var integer
+ */
+ var $id;
+ /**
+ * @var string
+ */
+ var $status;
+ /**
+ * @var string
+ */
+ var $ocsToken;
+ /**
+ * @var integer
+ */
+ var $ocsRemoteId;
+ /**
+ * @var string
+ */
+ var $user;
+ /**
+ * @var string
+ */
+ var $sender;
+
+ /**
+ * @var string
+ */
+ var $ocsServiceUrl;
+ /**
+ * @var string
+ */
+ var $ocsDavUrl;
+
+ /**
+ * @var bool
+ */
+ var $hasPassword;
+ /**
+ * @var string|null
+ */
+ var $password;
+ /**
+ * @var integer
+ */
+ var $receptionDate;
+ /**
+ * @var integer
+ */
+ var $answerDate;
+ /**
+ * @var string
+ */
+ var $message;
+ /**
+ * @var string
+ */
+ var $documentName;
+
+ /**
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ public function setId($id){
+ $this->id = $id;
+ }
+
+ /**
+ * @return string
+ */
+ public function getStatus()
+ {
+ return $this->status;
+ }
+
+ /**
+ * @return string
+ */
+ public function getOcsToken()
+ {
+ return $this->ocsToken;
+ }
+
+ /**
+ * @return int
+ */
+ public function getOcsRemoteId()
+ {
+ return $this->ocsRemoteId;
+ }
+
+ /**
+ * @return string
+ */
+ public function getUser()
+ {
+ return $this->user;
+ }
+
+ /**
+ * @return string
+ */
+ public function getSender()
+ {
+ return $this->sender;
+ }
+
+ /**
+ * @return string
+ */
+ public function getOcsServiceUrl()
+ {
+ return $this->ocsServiceUrl;
+ }
+
+ /**
+ * @return string
+ */
+ public function getOcsDavUrl()
+ {
+ return $this->ocsDavUrl;
+ }
+
+ /**
+ * @return boolean
+ */
+ public function isHasPassword()
+ {
+ return $this->hasPassword;
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getPassword()
+ {
+ return $this->password;
+ }
+
+ /**
+ * @return int
+ */
+ public function getReceptionDate()
+ {
+ return $this->receptionDate;
+ }
+
+ /**
+ * @return int
+ */
+ public function getAnswerDate()
+ {
+ return $this->answerDate;
+ }
+
+ /**
+ * @return string
+ */
+ public function getMessage()
+ {
+ return $this->message;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDocumentName()
+ {
+ return $this->documentName;
+ }
+
+
+}
\ No newline at end of file
diff --git a/core/src/plugins/core.ocs/src/Model/SQLStore.php b/core/src/plugins/core.ocs/src/Model/SQLStore.php
new file mode 100644
index 0000000000..6f61a6833c
--- /dev/null
+++ b/core/src/plugins/core.ocs/src/Model/SQLStore.php
@@ -0,0 +1,157 @@
+
+ * This file is part of Pydio.
+ *
+ * Pydio is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pydio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Pydio. If not, see .
+ *
+ * The latest code can be found at .
+ */
+namespace Pydio\OCS\Model;
+
+defined('AJXP_EXEC') or die('Access not allowed');
+
+define('OCS_SQLSTORE_FORMAT', 'serial');
+define('OCS_SQLSTORE_NS_INVITATION', 'ocs_invitation');
+define('OCS_SQLSTORE_NS_REMOTE_SHARE', 'ocs_remote_share');
+
+class SQLStore implements IStore
+{
+ /**
+ * @var \sqlConfDriver
+ */
+ protected $storage;
+
+ public function __construct()
+ {
+ $storage = \ConfService::getConfStorageImpl();
+ if($storage->getId() == "conf.sql") {
+ $this->confStorage = $storage;
+ }
+ }
+
+ /**
+ * Persists an invitation to store
+ * @param ShareInvitation $invitation
+ * @return ShareInvitation|false The invitation with its new ID.
+ */
+ public function storeInvitation(ShareInvitation $invitation)
+ {
+ $id = $invitation->getId();
+ if(empty($id)){
+ $id = $this->getGUID();
+ }
+ $this->storage->simpleStoreSet(OCS_SQLSTORE_NS_INVITATION, $id, OCS_SQLSTORE_FORMAT, $invitation->getLinkHash());
+ $invitation->setId($id);
+ return $invitation;
+ }
+
+ /**
+ * Find all invitatins for a given token
+ * @param string $linkToken
+ * @return ShareInvitation[]
+ */
+ public function invitationsForLink($linkToken)
+ {
+ return $this->storage->simpleStoreList(OCS_SQLSTORE_NS_INVITATION, null, "", OCS_SQLSTORE_FORMAT, "", $linkToken);
+ }
+
+ /**
+ * Find an invitation by ID
+ * @param $invitationId
+ * @return ShareInvitation|null
+ */
+ public function invitationById(string $invitationId)
+ {
+ $this->storage->simpleStoreGet(OCS_SQLSTORE_NS_INVITATION, $invitationId, OCS_SQLSTORE_FORMAT, $data);
+ return $data;
+ }
+
+ /**
+ * Delete an invitation
+ * @param ShareInvitation $invitation
+ * @return bool
+ */
+ public function deleteInvitation(ShareInvitation $invitation)
+ {
+ $this->storage->simpleStoreClear(OCS_SQLSTORE_NS_INVITATION, $invitation->getId());
+ }
+
+ /**
+ * Persists a remote share to the store
+ * @param RemoteShare $remoteShare
+ * @return RemoteShare|false The share with eventually its new ID.
+ */
+ public function storeRemoteShare(RemoteShare $remoteShare)
+ {
+ $id = $remoteShare->getId();
+ if(empty($id)){
+ $id = $this->getGUID();
+ }
+ $this->storage->simpleStoreSet(OCS_SQLSTORE_NS_REMOTE_SHARE, $id, OCS_SQLSTORE_FORMAT, $remoteShare->getUser());
+ $remoteShare->setId($id);
+ return $remoteShare;
+
+ }
+
+ /**
+ * Find all remote shares for a given user
+ * @param string $userName
+ * @return RemoteShare[]
+ */
+ public function remoteSharesForUser($userName)
+ {
+ return $this->storage->simpleStoreList(OCS_SQLSTORE_NS_REMOTE_SHARE, null, "", OCS_SQLSTORE_FORMAT, "", $userName);
+ }
+
+ /**
+ * Find a remote share by its id
+ * @param string $remoteShareId
+ * @return RemoteShare|false
+ */
+ public function remoteShareById($remoteShareId)
+ {
+ $this->storage->simpleStoreGet(OCS_SQLSTORE_NS_REMOTE_SHARE, $remoteShareId, OCS_SQLSTORE_FORMAT, $data);
+ return $data;
+ }
+
+ /**
+ * Delete an existing remote share
+ * @param RemoteShare $remoteShare
+ * @return bool
+ */
+ public function deleteRemoteShare(RemoteShare $remoteShare)
+ {
+ return $this->storage->simpleStoreClear(OCS_SQLSTORE_NS_REMOTE_SHARE, $remoteShare->getId());
+ }
+
+ protected function getGUID(){
+ if (function_exists('com_create_guid')){
+ return com_create_guid();
+ }else{
+ mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
+ $charid = strtoupper(md5(uniqid(rand(), true)));
+ $hyphen = chr(45);// "-"
+ $uuid = chr(123)// "{"
+ .substr($charid, 0, 8).$hyphen
+ .substr($charid, 8, 4).$hyphen
+ .substr($charid,12, 4).$hyphen
+ .substr($charid,16, 4).$hyphen
+ .substr($charid,20,12)
+ .chr(125);// "}"
+ return $uuid;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/core/src/plugins/core.ocs/src/Model/ShareInvitation.php b/core/src/plugins/core.ocs/src/Model/ShareInvitation.php
new file mode 100644
index 0000000000..827a00bf3e
--- /dev/null
+++ b/core/src/plugins/core.ocs/src/Model/ShareInvitation.php
@@ -0,0 +1,123 @@
+
+ * This file is part of Pydio.
+ *
+ * Pydio is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pydio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Pydio. If not, see .
+ *
+ * The latest code can be found at .
+ */
+namespace Pydio\OCS\Model;
+
+defined('AJXP_EXEC') or die('Access not allowed');
+
+define('OCS_INVITATION_STATUS_PENDING', 1);
+define('OCS_INVITATION_STATUS_ACCEPTED', 2);
+define('OCS_INVITATION_STATUS_REJECTED', 4);
+
+class ShareInvitation
+{
+ /**
+ * @var integer
+ */
+ var $id;
+ /**
+ * @var string
+ */
+ var $linkHash;
+ /**
+ * @var integer
+ */
+ var $status;
+ /**
+ * @var string
+ */
+ var $message;
+ /**
+ * @var string
+ */
+ var $owner;
+ /**
+ * @var string
+ */
+ var $targetHost;
+ /**
+ * @var string
+ */
+ var $targetUser;
+
+ /**
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ public function setId($id){
+ $this->id = $id;
+ }
+
+ /**
+ * @return string
+ */
+ public function getLinkHash()
+ {
+ return $this->linkHash;
+ }
+
+ /**
+ * @return int
+ */
+ public function getStatus()
+ {
+ return $this->status;
+ }
+
+ /**
+ * @return string
+ */
+ public function getMessage()
+ {
+ return $this->message;
+ }
+
+ /**
+ * @return string
+ */
+ public function getOwner()
+ {
+ return $this->owner;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTargetHost()
+ {
+ return $this->targetHost;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTargetUser()
+ {
+ return $this->targetUser;
+ }
+
+
+
+
+}
\ No newline at end of file