Merge branch 'master' into fix-shared-links
commit
c6985d6cd4
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012, Bjoern Schiessle <schiessle@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
use OCA\Encryption\Keymanager;
|
||||
|
||||
OCP\JSON::checkAppEnabled('files_encryption');
|
||||
OCP\JSON::checkLoggedIn();
|
||||
OCP\JSON::callCheck();
|
||||
|
||||
$mode = $_POST['mode'];
|
||||
$changePasswd = false;
|
||||
$passwdChanged = false;
|
||||
|
||||
if ( isset($_POST['newpasswd']) && isset($_POST['oldpasswd']) ) {
|
||||
$oldpasswd = $_POST['oldpasswd'];
|
||||
$newpasswd = $_POST['newpasswd'];
|
||||
$changePasswd = true;
|
||||
$passwdChanged = Keymanager::changePasswd($oldpasswd, $newpasswd);
|
||||
}
|
||||
|
||||
$query = \OC_DB::prepare( "SELECT mode FROM *PREFIX*encryption WHERE uid = ?" );
|
||||
$result = $query->execute(array(\OCP\User::getUser()));
|
||||
|
||||
if ($result->fetchRow()){
|
||||
$query = OC_DB::prepare( 'UPDATE *PREFIX*encryption SET mode = ? WHERE uid = ?' );
|
||||
} else {
|
||||
$query = OC_DB::prepare( 'INSERT INTO *PREFIX*encryption ( mode, uid ) VALUES( ?, ? )' );
|
||||
}
|
||||
|
||||
if ( (!$changePasswd || $passwdChanged) && $query->execute(array($mode, \OCP\User::getUser())) ) {
|
||||
OCP\JSON::success();
|
||||
} else {
|
||||
OCP\JSON::error();
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2012, Bjoern Schiessle <schiessle@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
$(document).ready(function(){
|
||||
$('input[name=encryption_mode]').change(function(){
|
||||
var prevmode = document.getElementById('prev_encryption_mode').value
|
||||
var client=$('input[value="client"]:checked').val()
|
||||
,server=$('input[value="server"]:checked').val()
|
||||
,user=$('input[value="user"]:checked').val()
|
||||
,none=$('input[value="none"]:checked').val()
|
||||
if (client) {
|
||||
$.post(OC.filePath('files_encryption', 'ajax', 'mode.php'), { mode: 'client' });
|
||||
if (prevmode == 'server') {
|
||||
OC.dialogs.info(t('encryption', 'Please switch to your ownCloud client and change your encryption password to complete the conversion.'), t('encryption', 'switched to client side encryption'));
|
||||
}
|
||||
} else if (server) {
|
||||
if (prevmode == 'client') {
|
||||
OC.dialogs.form([{text:'Login password', name:'newpasswd', type:'password'},{text:'Encryption password used on the client', name:'oldpasswd', type:'password'}],t('encryption', 'Change encryption password to login password'), function(data) {
|
||||
$.post(OC.filePath('files_encryption', 'ajax', 'mode.php'), { mode: 'server', newpasswd: data[0].value, oldpasswd: data[1].value }, function(result) {
|
||||
if (result.status != 'success') {
|
||||
document.getElementById(prevmode+'_encryption').checked = true;
|
||||
OC.dialogs.alert(t('encryption', 'Please check your passwords and try again.'), t('encryption', 'Could not change your file encryption password to your login password'))
|
||||
} else {
|
||||
console.log("alles super");
|
||||
}
|
||||
}, true);
|
||||
});
|
||||
} else {
|
||||
$.post(OC.filePath('files_encryption', 'ajax', 'mode.php'), { mode: 'server' });
|
||||
}
|
||||
} else {
|
||||
$.post(OC.filePath('files_encryption', 'ajax', 'mode.php'), { mode: 'none' });
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -1,8 +1,12 @@
|
||||
<?php $TRANSLATIONS = array(
|
||||
"Please switch to your ownCloud client and change your encryption password to complete the conversion." => "Schakel om naar uw eigen ownCloud client en wijzig uw versleutelwachtwoord om de conversie af te ronden.",
|
||||
"switched to client side encryption" => "overgeschakeld naar client side encryptie",
|
||||
"Change encryption password to login password" => "Verander encryptie wachtwoord naar login wachtwoord",
|
||||
"Please check your passwords and try again." => "Controleer uw wachtwoorden en probeer het opnieuw.",
|
||||
"Could not change your file encryption password to your login password" => "Kon het bestandsencryptie wachtwoord niet veranderen naar het login wachtwoord",
|
||||
"Encryption" => "Versleuteling",
|
||||
"File encryption is enabled." => "Bestandsversleuteling geactiveerd.",
|
||||
"The following file types will not be encrypted:" => "De volgende bestandstypen zullen niet worden versleuteld:",
|
||||
"Exclude the following file types from encryption:" => "Sluit de volgende bestandstypen uit van versleuteling:",
|
||||
"None" => "Geen"
|
||||
);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,325 +1,323 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud
|
||||
*
|
||||
* @author Bjoern Schiessle
|
||||
* @copyright 2012 Bjoern Schiessle <schiessle@owncloud.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library 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 this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Encryption;
|
||||
|
||||
/**
|
||||
* @brief Class to manage storage and retrieval of encryption keys
|
||||
* @note Where a method requires a view object, it's root must be '/'
|
||||
*/
|
||||
class Keymanager {
|
||||
|
||||
/**
|
||||
* @brief retrieve the ENCRYPTED private key from a user
|
||||
*
|
||||
* @return string private key or false
|
||||
* @note the key returned by this method must be decrypted before use
|
||||
*/
|
||||
public static function getPrivateKey( \OC_FilesystemView $view, $user ) {
|
||||
|
||||
$path = '/' . $user . '/' . 'files_encryption' . '/' . $user.'.private.key';
|
||||
|
||||
$key = $view->file_get_contents( $path );
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief retrieve public key for a specified user
|
||||
* @return string public key or false
|
||||
*/
|
||||
public static function getPublicKey( \OC_FilesystemView $view, $userId ) {
|
||||
|
||||
return $view->file_get_contents( '/public-keys/' . '/' . $userId . '.public.key' );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief retrieve both keys from a user (private and public)
|
||||
* @return array keys: privateKey, publicKey
|
||||
*/
|
||||
public static function getUserKeys( \OC_FilesystemView $view, $userId ) {
|
||||
|
||||
return array(
|
||||
'publicKey' => self::getPublicKey( $view, $userId )
|
||||
, 'privateKey' => self::getPrivateKey( $view, $userId )
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieve public keys of all users with access to a file
|
||||
* @param string $path Path to file
|
||||
* @return array of public keys for the given file
|
||||
* @note Checks that the sharing app is enabled should be performed
|
||||
* by client code, that isn't checked here
|
||||
*/
|
||||
public static function getPublicKeys( \OC_FilesystemView $view, $userId, $filePath ) {
|
||||
|
||||
$path = ltrim( $path, '/' );
|
||||
|
||||
$filepath = '/' . $userId . '/files/' . $filePath;
|
||||
|
||||
// Check if sharing is enabled
|
||||
if ( OC_App::isEnabled( 'files_sharing' ) ) {
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
// check if it is a file owned by the user and not shared at all
|
||||
$userview = new \OC_FilesystemView( '/'.$userId.'/files/' );
|
||||
|
||||
if ( $userview->file_exists( $path ) ) {
|
||||
|
||||
$users[] = $userId;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$view = new \OC_FilesystemView( '/public-keys/' );
|
||||
|
||||
$keylist = array();
|
||||
|
||||
$count = 0;
|
||||
|
||||
foreach ( $users as $user ) {
|
||||
|
||||
$keylist['key'.++$count] = $view->file_get_contents( $user.'.public.key' );
|
||||
|
||||
}
|
||||
|
||||
return $keylist;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief store file encryption key
|
||||
*
|
||||
* @param string $path relative path of the file, including filename
|
||||
* @param string $key
|
||||
* @return bool true/false
|
||||
* @note The keyfile is not encrypted here. Client code must
|
||||
* asymmetrically encrypt the keyfile before passing it to this method
|
||||
*/
|
||||
public static function setFileKey( \OC_FilesystemView $view, $path, $userId, $catfile ) {
|
||||
|
||||
$basePath = '/' . $userId . '/files_encryption/keyfiles';
|
||||
|
||||
$targetPath = self::keySetPreparation( $view, $path, $basePath, $userId );
|
||||
|
||||
if ( $view->is_dir( $basePath . '/' . $targetPath ) ) {
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
// Save the keyfile in parallel directory
|
||||
return $view->file_put_contents( $basePath . '/' . $targetPath . '.key', $catfile );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief retrieve keyfile for an encrypted file
|
||||
* @param string file name
|
||||
* @return string file key or false on failure
|
||||
* @note The keyfile returned is asymmetrically encrypted. Decryption
|
||||
* of the keyfile must be performed by client code
|
||||
*/
|
||||
public static function getFileKey( \OC_FilesystemView $view, $userId, $filePath ) {
|
||||
|
||||
$filePath_f = ltrim( $filePath, '/' );
|
||||
|
||||
$catfilePath = '/' . $userId . '/files_encryption/keyfiles/' . $filePath_f . '.key';
|
||||
|
||||
if ( $view->file_exists( $catfilePath ) ) {
|
||||
|
||||
return $view->file_get_contents( $catfilePath );
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Delete a keyfile
|
||||
*
|
||||
* @param OC_FilesystemView $view
|
||||
* @param string $userId username
|
||||
* @param string $path path of the file the key belongs to
|
||||
* @return bool Outcome of unlink operation
|
||||
* @note $path must be relative to data/user/files. e.g. mydoc.txt NOT
|
||||
* /data/admin/files/mydoc.txt
|
||||
*/
|
||||
public static function deleteFileKey( \OC_FilesystemView $view, $userId, $path ) {
|
||||
|
||||
$trimmed = ltrim( $path, '/' );
|
||||
$keyPath = '/' . $userId . '/files_encryption/keyfiles/' . $trimmed . '.key';
|
||||
|
||||
// Unlink doesn't tell us if file was deleted (not found returns
|
||||
// true), so we perform our own test
|
||||
if ( $view->file_exists( $keyPath ) ) {
|
||||
|
||||
return $view->unlink( $keyPath );
|
||||
|
||||
} else {
|
||||
|
||||
\OC_Log::write( 'Encryption library', 'Could not delete keyfile; does not exist: "' . $keyPath, \OC_Log::ERROR );
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief store private key from the user
|
||||
* @param string key
|
||||
* @return bool
|
||||
* @note Encryption of the private key must be performed by client code
|
||||
* as no encryption takes place here
|
||||
*/
|
||||
public static function setPrivateKey( $key ) {
|
||||
|
||||
$user = \OCP\User::getUser();
|
||||
|
||||
$view = new \OC_FilesystemView( '/' . $user . '/files_encryption' );
|
||||
|
||||
\OC_FileProxy::$enabled = false;
|
||||
|
||||
if ( !$view->file_exists( '' ) ) $view->mkdir( '' );
|
||||
|
||||
return $view->file_put_contents( $user . '.private.key', $key );
|
||||
|
||||
\OC_FileProxy::$enabled = true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief store private keys from the user
|
||||
*
|
||||
* @param string privatekey
|
||||
* @param string publickey
|
||||
* @return bool true/false
|
||||
*/
|
||||
public static function setUserKeys($privatekey, $publickey) {
|
||||
|
||||
return ( self::setPrivateKey( $privatekey ) && self::setPublicKey( $publickey ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief store public key of the user
|
||||
*
|
||||
* @param string key
|
||||
* @return bool true/false
|
||||
*/
|
||||
public static function setPublicKey( $key ) {
|
||||
|
||||
$view = new \OC_FilesystemView( '/public-keys' );
|
||||
|
||||
\OC_FileProxy::$enabled = false;
|
||||
|
||||
if ( !$view->file_exists( '' ) ) $view->mkdir( '' );
|
||||
|
||||
return $view->file_put_contents( \OCP\User::getUser() . '.public.key', $key );
|
||||
|
||||
\OC_FileProxy::$enabled = true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @note 'shareKey' is a more user-friendly name for env_key
|
||||
*/
|
||||
public static function setShareKey( \OC_FilesystemView $view, $path, $userId, $shareKey ) {
|
||||
|
||||
$basePath = '/' . $userId . '/files_encryption/share-keys';
|
||||
|
||||
$shareKeyPath = self::keySetPreparation( $view, $path, $basePath, $userId );
|
||||
|
||||
return $view->file_put_contents( $basePath . '/' . $shareKeyPath . '.shareKey', $shareKey );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Make preparations to vars and filesystem for saving a keyfile
|
||||
*/
|
||||
public static function keySetPreparation( \OC_FilesystemView $view, $path, $basePath, $userId ) {
|
||||
|
||||
$targetPath = ltrim( $path, '/' );
|
||||
|
||||
$path_parts = pathinfo( $targetPath );
|
||||
|
||||
// If the file resides within a subdirectory, create it
|
||||
if (
|
||||
isset( $path_parts['dirname'] )
|
||||
&& ! $view->file_exists( $basePath . '/' . $path_parts['dirname'] )
|
||||
) {
|
||||
|
||||
$view->mkdir( $basePath . '/' . $path_parts['dirname'] );
|
||||
|
||||
}
|
||||
|
||||
return $targetPath;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief change password of private encryption key
|
||||
*
|
||||
* @param string $oldpasswd old password
|
||||
* @param string $newpasswd new password
|
||||
* @return bool true/false
|
||||
*/
|
||||
public static function changePasswd($oldpasswd, $newpasswd) {
|
||||
|
||||
if ( \OCP\User::checkPassword(\OCP\User::getUser(), $newpasswd) ) {
|
||||
return Crypt::changekeypasscode($oldpasswd, $newpasswd);
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Fetch the legacy encryption key from user files
|
||||
* @param string $login used to locate the legacy key
|
||||
* @param string $passphrase used to decrypt the legacy key
|
||||
* @return true / false
|
||||
*
|
||||
* if the key is left out, the default handeler will be used
|
||||
*/
|
||||
public function getLegacyKey() {
|
||||
|
||||
$user = \OCP\User::getUser();
|
||||
$view = new \OC_FilesystemView( '/' . $user );
|
||||
return $view->file_get_contents( 'encryption.key' );
|
||||
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud
|
||||
*
|
||||
* @author Bjoern Schiessle
|
||||
* @copyright 2012 Bjoern Schiessle <schiessle@owncloud.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library 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 this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Encryption;
|
||||
|
||||
/**
|
||||
* @brief Class to manage storage and retrieval of encryption keys
|
||||
* @note Where a method requires a view object, it's root must be '/'
|
||||
*/
|
||||
class Keymanager {
|
||||
|
||||
/**
|
||||
* @brief retrieve the ENCRYPTED private key from a user
|
||||
*
|
||||
* @return string private key or false
|
||||
* @note the key returned by this method must be decrypted before use
|
||||
*/
|
||||
public static function getPrivateKey( \OC_FilesystemView $view, $user ) {
|
||||
|
||||
$path = '/' . $user . '/' . 'files_encryption' . '/' . $user.'.private.key';
|
||||
|
||||
$key = $view->file_get_contents( $path );
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief retrieve public key for a specified user
|
||||
* @param \OC_FilesystemView $view
|
||||
* @param $userId
|
||||
* @return string public key or false
|
||||
*/
|
||||
public static function getPublicKey( \OC_FilesystemView $view, $userId ) {
|
||||
|
||||
return $view->file_get_contents( '/public-keys/' . '/' . $userId . '.public.key' );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief retrieve both keys from a user (private and public)
|
||||
* @param \OC_FilesystemView $view
|
||||
* @param $userId
|
||||
* @return array keys: privateKey, publicKey
|
||||
*/
|
||||
public static function getUserKeys( \OC_FilesystemView $view, $userId ) {
|
||||
|
||||
return array(
|
||||
'publicKey' => self::getPublicKey( $view, $userId )
|
||||
, 'privateKey' => self::getPrivateKey( $view, $userId )
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieve public keys of all users with access to a file
|
||||
* @param string $path Path to file
|
||||
* @return array of public keys for the given file
|
||||
* @note Checks that the sharing app is enabled should be performed
|
||||
* by client code, that isn't checked here
|
||||
*/
|
||||
public static function getPublicKeys( \OC_FilesystemView $view, $userId, $filePath ) {
|
||||
|
||||
$path = ltrim( $path, '/' );
|
||||
|
||||
$filepath = '/' . $userId . '/files/' . $filePath;
|
||||
|
||||
// Check if sharing is enabled
|
||||
if ( OC_App::isEnabled( 'files_sharing' ) ) {
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
// check if it is a file owned by the user and not shared at all
|
||||
$userview = new \OC_FilesystemView( '/'.$userId.'/files/' );
|
||||
|
||||
if ( $userview->file_exists( $path ) ) {
|
||||
|
||||
$users[] = $userId;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$view = new \OC_FilesystemView( '/public-keys/' );
|
||||
|
||||
$keylist = array();
|
||||
|
||||
$count = 0;
|
||||
|
||||
foreach ( $users as $user ) {
|
||||
|
||||
$keylist['key'.++$count] = $view->file_get_contents( $user.'.public.key' );
|
||||
|
||||
}
|
||||
|
||||
return $keylist;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief store file encryption key
|
||||
*
|
||||
* @param string $path relative path of the file, including filename
|
||||
* @param string $key
|
||||
* @return bool true/false
|
||||
* @note The keyfile is not encrypted here. Client code must
|
||||
* asymmetrically encrypt the keyfile before passing it to this method
|
||||
*/
|
||||
public static function setFileKey( \OC_FilesystemView $view, $path, $userId, $catfile ) {
|
||||
|
||||
$basePath = '/' . $userId . '/files_encryption/keyfiles';
|
||||
|
||||
$targetPath = self::keySetPreparation( $view, $path, $basePath, $userId );
|
||||
|
||||
if ( $view->is_dir( $basePath . '/' . $targetPath ) ) {
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
// Save the keyfile in parallel directory
|
||||
return $view->file_put_contents( $basePath . '/' . $targetPath . '.key', $catfile );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief retrieve keyfile for an encrypted file
|
||||
* @param \OC_FilesystemView $view
|
||||
* @param $userId
|
||||
* @param $filePath
|
||||
* @internal param \OCA\Encryption\file $string name
|
||||
* @return string file key or false
|
||||
* @note The keyfile returned is asymmetrically encrypted. Decryption
|
||||
* of the keyfile must be performed by client code
|
||||
*/
|
||||
public static function getFileKey( \OC_FilesystemView $view, $userId, $filePath ) {
|
||||
|
||||
$filePath_f = ltrim( $filePath, '/' );
|
||||
|
||||
$catfilePath = '/' . $userId . '/files_encryption/keyfiles/' . $filePath_f . '.key';
|
||||
|
||||
if ( $view->file_exists( $catfilePath ) ) {
|
||||
|
||||
return $view->file_get_contents( $catfilePath );
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Delete a keyfile
|
||||
*
|
||||
* @param OC_FilesystemView $view
|
||||
* @param string $userId username
|
||||
* @param string $path path of the file the key belongs to
|
||||
* @return bool Outcome of unlink operation
|
||||
* @note $path must be relative to data/user/files. e.g. mydoc.txt NOT
|
||||
* /data/admin/files/mydoc.txt
|
||||
*/
|
||||
public static function deleteFileKey( \OC_FilesystemView $view, $userId, $path ) {
|
||||
|
||||
$trimmed = ltrim( $path, '/' );
|
||||
$keyPath = '/' . $userId . '/files_encryption/keyfiles/' . $trimmed . '.key';
|
||||
|
||||
// Unlink doesn't tell us if file was deleted (not found returns
|
||||
// true), so we perform our own test
|
||||
if ( $view->file_exists( $keyPath ) ) {
|
||||
|
||||
return $view->unlink( $keyPath );
|
||||
|
||||
} else {
|
||||
|
||||
\OC_Log::write( 'Encryption library', 'Could not delete keyfile; does not exist: "' . $keyPath, \OC_Log::ERROR );
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief store private key from the user
|
||||
* @param string key
|
||||
* @return bool
|
||||
* @note Encryption of the private key must be performed by client code
|
||||
* as no encryption takes place here
|
||||
*/
|
||||
public static function setPrivateKey( $key ) {
|
||||
|
||||
$user = \OCP\User::getUser();
|
||||
|
||||
$view = new \OC_FilesystemView( '/' . $user . '/files_encryption' );
|
||||
|
||||
\OC_FileProxy::$enabled = false;
|
||||
|
||||
if ( !$view->file_exists( '' ) )
|
||||
$view->mkdir( '' );
|
||||
|
||||
return $view->file_put_contents( $user . '.private.key', $key );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief store private keys from the user
|
||||
*
|
||||
* @param string privatekey
|
||||
* @param string publickey
|
||||
* @return bool true/false
|
||||
*/
|
||||
public static function setUserKeys($privatekey, $publickey) {
|
||||
|
||||
return ( self::setPrivateKey( $privatekey ) && self::setPublicKey( $publickey ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief store public key of the user
|
||||
*
|
||||
* @param string key
|
||||
* @return bool true/false
|
||||
*/
|
||||
public static function setPublicKey( $key ) {
|
||||
|
||||
$view = new \OC_FilesystemView( '/public-keys' );
|
||||
|
||||
\OC_FileProxy::$enabled = false;
|
||||
|
||||
if ( !$view->file_exists( '' ) )
|
||||
$view->mkdir( '' );
|
||||
|
||||
return $view->file_put_contents( \OCP\User::getUser() . '.public.key', $key );
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief store file encryption key
|
||||
*
|
||||
* @param string $path relative path of the file, including filename
|
||||
* @param string $key
|
||||
* @param null $view
|
||||
* @param string $dbClassName
|
||||
* @return bool true/false
|
||||
* @note The keyfile is not encrypted here. Client code must
|
||||
* asymmetrically encrypt the keyfile before passing it to this method
|
||||
*/
|
||||
public static function setShareKey( \OC_FilesystemView $view, $path, $userId, $shareKey ) {
|
||||
|
||||
$basePath = '/' . $userId . '/files_encryption/share-keys';
|
||||
|
||||
$shareKeyPath = self::keySetPreparation( $view, $path, $basePath, $userId );
|
||||
|
||||
return $view->file_put_contents( $basePath . '/' . $shareKeyPath . '.shareKey', $shareKey );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Make preparations to vars and filesystem for saving a keyfile
|
||||
*/
|
||||
public static function keySetPreparation( \OC_FilesystemView $view, $path, $basePath, $userId ) {
|
||||
|
||||
$targetPath = ltrim( $path, '/' );
|
||||
|
||||
$path_parts = pathinfo( $targetPath );
|
||||
|
||||
// If the file resides within a subdirectory, create it
|
||||
if (
|
||||
isset( $path_parts['dirname'] )
|
||||
&& ! $view->file_exists( $basePath . '/' . $path_parts['dirname'] )
|
||||
) {
|
||||
|
||||
$view->mkdir( $basePath . '/' . $path_parts['dirname'] );
|
||||
|
||||
}
|
||||
|
||||
return $targetPath;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Fetch the legacy encryption key from user files
|
||||
* @param string $login used to locate the legacy key
|
||||
* @param string $passphrase used to decrypt the legacy key
|
||||
* @return true / false
|
||||
*
|
||||
* if the key is left out, the default handler will be used
|
||||
*/
|
||||
public function getLegacyKey() {
|
||||
|
||||
$user = \OCP\User::getUser();
|
||||
$view = new \OC_FilesystemView( '/' . $user );
|
||||
return $view->file_get_contents( 'encryption.key' );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
<?php $TRANSLATIONS = array(
|
||||
"Password" => "Лозинка",
|
||||
"Submit" => "Пошаљи"
|
||||
"Submit" => "Пошаљи",
|
||||
"Download" => "Преузми"
|
||||
);
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
OCP\JSON::checkLoggedIn();
|
||||
OCP\JSON::callCheck();
|
||||
|
||||
$file = $_REQUEST['file'];
|
||||
|
||||
$path_parts = pathinfo($file);
|
||||
if ($path_parts['dirname'] == '.') {
|
||||
$delimiter = strrpos($file, '.d');
|
||||
$filename = substr($file, 0, $delimiter);
|
||||
$timestamp = substr($file, $delimiter+2);
|
||||
} else {
|
||||
$filename = $file;
|
||||
$timestamp = null;
|
||||
}
|
||||
|
||||
if (OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp)) {
|
||||
OCP\JSON::success(array("data" => array("filename" => $file)));
|
||||
} else {
|
||||
$l = OC_L10N::get('files_trashbin');
|
||||
OCP\JSON::error(array("data" => array("message" => $l->t("Couldn't delete %s permanently", array($file)))));
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
OC::$CLASSPATH['OCA_Trash\Hooks'] = 'apps/files_trashbin/lib/hooks.php';
|
||||
OC::$CLASSPATH['OCA_Trash\Trashbin'] = 'apps/files_trashbin/lib/trash.php';
|
||||
OC::$CLASSPATH['OCA\Files_Trashbin\Hooks'] = 'apps/files_trashbin/lib/hooks.php';
|
||||
OC::$CLASSPATH['OCA\Files_Trashbin\Trashbin'] = 'apps/files_trashbin/lib/trash.php';
|
||||
|
||||
|
||||
OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA_Trash\Hooks", "remove_hook");
|
||||
OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\Files_Trashbin\Hooks", "remove_hook");
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/* disable download and sharing actions */
|
||||
var disableDownloadActions = true;
|
||||
var disableSharing = true;
|
||||
var trashBinApp = true;
|
||||
@ -1,7 +1,14 @@
|
||||
<?php $TRANSLATIONS = array(
|
||||
"Couldn't delete %s permanently" => "%s не может быть удалён навсегда",
|
||||
"Couldn't restore %s" => "%s не может быть восстановлен",
|
||||
"perform restore operation" => "выполнить операцию восстановления",
|
||||
"delete file permanently" => "удалить файл навсегда",
|
||||
"Name" => "Имя",
|
||||
"Deleted" => "Удалён",
|
||||
"1 folder" => "1 папка",
|
||||
"{count} folders" => "{count} папок",
|
||||
"1 file" => "1 файл",
|
||||
"{count} files" => "{count} файлов"
|
||||
"{count} files" => "{count} файлов",
|
||||
"Nothing in here. Your trash bin is empty!" => "Здесь ничего нет. Ваша корзина пуста!",
|
||||
"Restore" => "Восстановить"
|
||||
);
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
<?php $TRANSLATIONS = array(
|
||||
"Could not revert: %s" => "No s'ha pogut revertir: %s",
|
||||
"success" => "èxit",
|
||||
"File %s was reverted to version %s" => "El fitxer %s s'ha revertit a la versió %s",
|
||||
"failure" => "fallada",
|
||||
"File %s could not be reverted to version %s" => "El fitxer %s no s'ha pogut revertir a la versió %s",
|
||||
"No old versions available" => "No hi ha versións antigues disponibles",
|
||||
"No path specified" => "No heu especificat el camí",
|
||||
"History" => "Historial",
|
||||
"Revert a file to a previous version by clicking on its revert button" => "Reverteix un fitxer a una versió anterior fent clic en el seu botó de reverteix",
|
||||
"Files Versioning" => "Fitxers de Versions",
|
||||
"Enable" => "Habilita"
|
||||
);
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
<?php $TRANSLATIONS = array(
|
||||
"Could not revert: %s" => "Nelze navrátit: %s",
|
||||
"success" => "úspěch",
|
||||
"File %s was reverted to version %s" => "Soubor %s byl navrácen na verzi %s",
|
||||
"failure" => "sehlhání",
|
||||
"File %s could not be reverted to version %s" => "Soubor %s nemohl být navrácen na verzi %s",
|
||||
"No old versions available" => "Nejsou dostupné žádné starší verze",
|
||||
"No path specified" => "Nezadána cesta",
|
||||
"History" => "Historie",
|
||||
"Revert a file to a previous version by clicking on its revert button" => "Navraťte soubor do předchozí verze kliknutím na tlačítko navrátit",
|
||||
"Files Versioning" => "Verzování souborů",
|
||||
"Enable" => "Povolit"
|
||||
);
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
<?php $TRANSLATIONS = array(
|
||||
"Could not revert: %s" => "No se puede revertir: %s",
|
||||
"success" => "exitoso",
|
||||
"File %s was reverted to version %s" => "El archivo %s fue revertido a la version %s",
|
||||
"failure" => "fallo",
|
||||
"File %s could not be reverted to version %s" => "El archivo %s no puede ser revertido a la version %s",
|
||||
"No old versions available" => "No hay versiones antiguas disponibles",
|
||||
"No path specified" => "Ruta no especificada",
|
||||
"History" => "Historial",
|
||||
"Revert a file to a previous version by clicking on its revert button" => "Revertir un archivo a una versión anterior haciendo clic en el boton de revertir",
|
||||
"Files Versioning" => "Versionado de archivos",
|
||||
"Enable" => "Habilitar"
|
||||
);
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
<?php $TRANSLATIONS = array(
|
||||
"Could not revert: %s" => "Impossible de restaurer %s",
|
||||
"success" => "succès",
|
||||
"File %s was reverted to version %s" => "Le fichier %s a été restauré dans sa version %s",
|
||||
"failure" => "échec",
|
||||
"File %s could not be reverted to version %s" => "Le fichier %s ne peut être restauré dans sa version %s",
|
||||
"No old versions available" => "Aucune ancienne version n'est disponible",
|
||||
"No path specified" => "Aucun chemin spécifié",
|
||||
"History" => "Historique",
|
||||
"Revert a file to a previous version by clicking on its revert button" => "Restaurez un fichier dans une version antérieure en cliquant sur son bouton de restauration",
|
||||
"Files Versioning" => "Versionnage des fichiers",
|
||||
"Enable" => "Activer"
|
||||
);
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
<?php $TRANSLATIONS = array(
|
||||
"Could not revert: %s" => "Impossibild ripristinare: %s",
|
||||
"success" => "completata",
|
||||
"File %s was reverted to version %s" => "Il file %s è stato ripristinato alla versione %s",
|
||||
"failure" => "non riuscita",
|
||||
"File %s could not be reverted to version %s" => "Il file %s non può essere ripristinato alla versione %s",
|
||||
"No old versions available" => "Non sono disponibili versioni precedenti",
|
||||
"No path specified" => "Nessun percorso specificato",
|
||||
"History" => "Cronologia",
|
||||
"Revert a file to a previous version by clicking on its revert button" => "Ripristina un file a una versione precedente facendo clic sul rispettivo pulsante di ripristino",
|
||||
"Files Versioning" => "Controllo di versione dei file",
|
||||
"Enable" => "Abilita"
|
||||
);
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
<?php $TRANSLATIONS = array(
|
||||
"Could not revert: %s" => "元に戻せませんでした: %s",
|
||||
"success" => "成功",
|
||||
"File %s was reverted to version %s" => "ファイル %s をバージョン %s に戻しました",
|
||||
"failure" => "失敗",
|
||||
"File %s could not be reverted to version %s" => "ファイル %s をバージョン %s に戻せませんでした",
|
||||
"No old versions available" => "利用可能な古いバージョンはありません",
|
||||
"No path specified" => "パスが指定されていません",
|
||||
"History" => "履歴",
|
||||
"Revert a file to a previous version by clicking on its revert button" => "もとに戻すボタンをクリックすると、ファイルを過去のバージョンに戻します",
|
||||
"Files Versioning" => "ファイルのバージョン管理",
|
||||
"Enable" => "有効化"
|
||||
);
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
<?php $TRANSLATIONS = array(
|
||||
"Could not revert: %s" => "Nevarēja atgriezt — %s",
|
||||
"success" => "veiksme",
|
||||
"File %s was reverted to version %s" => "Datne %s tika atgriezt uz versiju %s",
|
||||
"failure" => "neveiksme",
|
||||
"File %s could not be reverted to version %s" => "Datni %s nevarēja atgriezt uz versiju %s",
|
||||
"No old versions available" => "Nav pieejamu vecāku versiju",
|
||||
"No path specified" => "Nav norādīts ceļš",
|
||||
"History" => "Vēsture",
|
||||
"Revert a file to a previous version by clicking on its revert button" => "Atgriez datni uz iepriekšēju versiju, spiežot uz tās atgriešanas pogu",
|
||||
"Files Versioning" => "Datņu versiju izskošana",
|
||||
"Enable" => "Aktivēt"
|
||||
);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue