diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2012-07-26 13:57:50 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2012-07-26 13:57:50 +0200 |
commit | cb5d935b82643a3e3c369c11835ca1f5b2ad0b58 (patch) | |
tree | f7be9dc9dfc43a49432836a9caa1acf76f6ba42e /lib | |
parent | bdb406916cf7306abf03a83e4fde81baf71d22bc (diff) | |
download | nextcloud-server-cb5d935b82643a3e3c369c11835ca1f5b2ad0b58.tar.gz nextcloud-server-cb5d935b82643a3e3c369c11835ca1f5b2ad0b58.zip |
implemented publicKeyGet() and privateKeyGet() calls
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ocs.php | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/lib/ocs.php b/lib/ocs.php index 218f7a93124..9d30b062bce 100644 --- a/lib/ocs.php +++ b/lib/ocs.php @@ -652,17 +652,25 @@ class OC_OCS { */ private static function publicKeyGet($format, $user) { $login=OC_OCS::checkpassword(); - if(OC_User::userExists($user)){ - //TODO: GET public key - $xml=array();
- $xml['key']="this is the public key of $user";
- $txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'cloud', '', 1, 0, 0);
- echo($txt); - }else{ - echo self::generateXml('', 'fail', 300, 'User does not exist'); + if(OC_App::isEnabled('files_encryption') && OCA_Encryption\Crypt::mode($user) === 'client') { + if(OC_User::userExists($user)){ + if (($key = OCA_Encryption\Keymanager::getPublicKey($user))) { + $xml=array();
+ $xml['key'] = $key;
+ $txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'cloud', '', 1, 0, 0);
+ echo($txt); + } + else { + echo self::generateXml('', 'fail', 404, 'public key does not exist'); + } + } else { + echo self::generateXml('', 'fail', 300, 'User does not exist'); + } + } else { + echo self::generateXml('', 'fail', 300, 'Client side encryption not enabled for user ' . $user);
} } - + /**
* set the public key of a user
* @param string $format
@@ -690,22 +698,25 @@ class OC_OCS { * @param string $user * @return string xml/json */ - private static function privateKeyGet($format, $user) { - $login=OC_OCS::checkpassword(); - if(OC_Group::inGroup($login, 'admin') or ($login==$user)) { - if(OC_User::userExists($user)){ - //TODO: GET private key - $xml=array();
- $xml['key']="this is the private key of $user";
- $txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'cloud', '', 1, 0, 0);
- echo($txt); - }else{ - echo self::generateXml('', 'fail', 300, 'User does not exist'); - } - }else{ - echo self::generateXml('', 'fail', 300, 'You don´t have permission to access this ressource.'); - } - } + private static function privateKeyGet($format, $user) {
+ $login=OC_OCS::checkpassword(); + if(($login==$user)) {
+ if(OC_App::isEnabled('files_encryption') && OCA_Encryption\Crypt::mode($user) === 'client') { + if (($key = OCA_Encryption\Keymanager::getPrivateKey($user))) {
+ $xml=array();
+ $xml['key']=$key;
+ $txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'cloud', '', 1, 0, 0);
+ echo($txt);
+ } else {
+ echo self::generateXml('', 'fail', 404, 'private Key does not exist');
+ } + } 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.'); + }
+ } /**
* set the private key of a user
@@ -735,7 +746,7 @@ class OC_OCS { * @param string $file
* @return string xml/json
*/
- private static function privateKeyGet($format, $user, $file) {
+ private static function fileKeyGet($format, $user, $file) {
$login=OC_OCS::checkpassword();
if(OC_Group::inGroup($login, 'admin') or ($login==$user)) {
if(OC_User::userExists($user)){
@@ -760,7 +771,7 @@ class OC_OCS { * @param string $key
* @return string xml/json
*/
- private static function privateKeySet($format, $user, $file, $key) {
+ private static function fileKeySet($format, $user, $file, $key) {
$login=OC_OCS::checkpassword();
if($login == $user) {
if(OC_User::userExists($user)){
|