summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2012-07-27 14:00:41 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2012-07-27 14:00:41 +0200
commitf752a2760584614c160e4eaf5bf0fdeb938ee4ae (patch)
treefb4302068392cf3d95a5b78f4127e09a58147ab9 /lib
parent931c4695a60d7c46d225152f0628fdd7f1574027 (diff)
downloadnextcloud-server-f752a2760584614c160e4eaf5bf0fdeb938ee4ae.tar.gz
nextcloud-server-f752a2760584614c160e4eaf5bf0fdeb938ee4ae.zip
write keyfiles to server
Diffstat (limited to 'lib')
-rw-r--r--lib/filestorage/local.php2
-rw-r--r--lib/ocs.php42
2 files changed, 32 insertions, 12 deletions
diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php
index b2eba051515..f04cf7c1076 100644
--- a/lib/filestorage/local.php
+++ b/lib/filestorage/local.php
@@ -12,7 +12,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{
}
}
public function mkdir($path){
- return @mkdir($this->datadir.$path);
+ return @mkdir($this->datadir.$path, 0755, true);
}
public function rmdir($path){
return @rmdir($this->datadir.$path);
diff --git a/lib/ocs.php b/lib/ocs.php
index 5349053ad28..e0c240d3306 100644
--- a/lib/ocs.php
+++ b/lib/ocs.php
@@ -183,11 +183,24 @@ class OC_OCS {
}elseif(($method=='get') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-5]=='cloud') and ($ex[$paracount-4] == 'user') and ($ex[$paracount-2] == 'privatekey')){
$user=$ex[$paracount-3];
OC_OCS::privateKeyGet($format,$user);
+
+ //keysetprivate
}elseif(($method=='post') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-5]=='cloud') and ($ex[$paracount-4] == 'user') and ($ex[$paracount-2] == 'privatekey')){
$user=$ex[$paracount-3];
$key = self::readData('post', 'key', 'string');
OC_OCS::privateKeySet($format,$user, $key);
-
+
+ // keygetfiles
+ }elseif(($method=='get') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-5]=='cloud') and ($ex[$paracount-4] == 'user') and ($ex[$paracount-2] == 'filekey')){
+ $user=$ex[$paracount-3];
+ OC_OCS::fileKeyGet($format,$user);
+
+ //keysetfiles
+ }elseif(($method=='post') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-5]=='cloud') and ($ex[$paracount-4] == 'user') and ($ex[$paracount-2] == 'filekey')){
+ $user=$ex[$paracount-3];
+ $key = self::readData('post', 'key', 'string');
+ $file = self::readData('post', 'file', 'string');
+ OC_OCS::fileKeySet($format,$user, $file, $key);
// add more calls here
// please document all the call in the draft spec
@@ -766,7 +779,7 @@ class OC_OCS {
$login=OC_OCS::checkpassword();
if(OC_Group::inGroup($login, 'admin') or ($login==$user)) {
if(OC_User::userExists($user)){
- //TODO: GET file key
+ //TODO: GET file key, check needed if it is a shared file or not
$xml=array();
$xml['key']="this is the key for $file";
$txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'cloud', '', 1, 0, 0);
@@ -787,18 +800,25 @@ class OC_OCS {
* @param string $key
* @return string xml/json
*/
- private static function fileKeySet($format, $user, $file, $key) {
+ private static function fileKeySet($format, $user, $file, $key) {
$login=OC_OCS::checkpassword();
- if($login == $user) {
- if(OC_User::userExists($user)){
- //TODO: SET file key
- echo self::generateXml('', 'ok', 100, 'File key uploaded');
- }else{
- echo self::generateXml('', 'fail', 300, 'User does not exist');
+ if(($login==$user)) {
+ if(OC_App::isEnabled('files_encryption') && OCA_Encryption\Crypt::mode($user) === 'client') {
+ if (($key = OCA_Encryption\Keymanager::setFileKey($user, $file, $key))) {
+ // TODO: emit hook to move file from tmp location to the right place
+ echo self::generateXml('', 'ok', 100, '');
+ return true;
+ } else {
+ echo self::generateXml('', 'fail', 404, 'could not write key file');
+ }
+ } else {
+ echo self::generateXml('', 'fail', 300, 'Client side encryption not enabled for user ' . $user);
}
}else{
echo self::generateXml('', 'fail', 300, 'You donĀ“t have permission to access this ressource.');
- }
- }
+ }
+ //TODO: emit signal to remove file from tmp location
+ return false;
+ }
}