implemented publicKeyGet() and privateKeyGet() calls

This commit is contained in:
Bjoern Schiessle 2012-07-26 13:57:50 +02:00
parent bdb406916c
commit cb5d935b82
1 changed files with 38 additions and 27 deletions

View File

@ -652,17 +652,25 @@ class OC_OCS {
*/ */
private static function publicKeyGet($format, $user) { private static function publicKeyGet($format, $user) {
$login=OC_OCS::checkpassword(); $login=OC_OCS::checkpassword();
if(OC_User::userExists($user)){ if(OC_App::isEnabled('files_encryption') && OCA_Encryption\Crypt::mode($user) === 'client') {
//TODO: GET public key if(OC_User::userExists($user)){
$xml=array(); if (($key = OCA_Encryption\Keymanager::getPublicKey($user))) {
$xml['key']="this is the public key of $user"; $xml=array();
$txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'cloud', '', 1, 0, 0); $xml['key'] = $key;
echo($txt); $txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'cloud', '', 1, 0, 0);
}else{ echo($txt);
echo self::generateXml('', 'fail', 300, 'User does not exist'); }
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 * set the public key of a user
* @param string $format * @param string $format
@ -690,22 +698,25 @@ class OC_OCS {
* @param string $user * @param string $user
* @return string xml/json * @return string xml/json
*/ */
private static function privateKeyGet($format, $user) { private static function privateKeyGet($format, $user) {
$login=OC_OCS::checkpassword(); $login=OC_OCS::checkpassword();
if(OC_Group::inGroup($login, 'admin') or ($login==$user)) { if(($login==$user)) {
if(OC_User::userExists($user)){ if(OC_App::isEnabled('files_encryption') && OCA_Encryption\Crypt::mode($user) === 'client') {
//TODO: GET private key if (($key = OCA_Encryption\Keymanager::getPrivateKey($user))) {
$xml=array(); $xml=array();
$xml['key']="this is the private key of $user"; $xml['key']=$key;
$txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'cloud', '', 1, 0, 0); $txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'cloud', '', 1, 0, 0);
echo($txt); echo($txt);
}else{ } else {
echo self::generateXml('', 'fail', 300, 'User does not exist'); echo self::generateXml('', 'fail', 404, 'private Key does not exist');
} }
}else{ } else {
echo self::generateXml('', 'fail', 300, 'You don´t have permission to access this ressource.'); 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 * set the private key of a user
@ -735,7 +746,7 @@ class OC_OCS {
* @param string $file * @param string $file
* @return string xml/json * @return string xml/json
*/ */
private static function privateKeyGet($format, $user, $file) { private static function fileKeyGet($format, $user, $file) {
$login=OC_OCS::checkpassword(); $login=OC_OCS::checkpassword();
if(OC_Group::inGroup($login, 'admin') or ($login==$user)) { if(OC_Group::inGroup($login, 'admin') or ($login==$user)) {
if(OC_User::userExists($user)){ if(OC_User::userExists($user)){
@ -760,7 +771,7 @@ class OC_OCS {
* @param string $key * @param string $key
* @return string xml/json * @return string xml/json
*/ */
private static function privateKeySet($format, $user, $file, $key) { private static function fileKeySet($format, $user, $file, $key) {
$login=OC_OCS::checkpassword(); $login=OC_OCS::checkpassword();
if($login == $user) { if($login == $user) {
if(OC_User::userExists($user)){ if(OC_User::userExists($user)){