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,15 +652,23 @@ 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_App::isEnabled('files_encryption') && OCA_Encryption\Crypt::mode($user) === 'client') {
if(OC_User::userExists($user)){ if(OC_User::userExists($user)){
//TODO: GET public key if (($key = OCA_Encryption\Keymanager::getPublicKey($user))) {
$xml=array(); $xml=array();
$xml['key']="this is the public 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 {
echo self::generateXml('', 'fail', 404, 'public key does not exist');
}
} else { } else {
echo self::generateXml('', 'fail', 300, 'User does not exist'); echo self::generateXml('', 'fail', 300, 'User does not exist');
} }
} else {
echo self::generateXml('', 'fail', 300, 'Client side encryption not enabled for user ' . $user);
}
} }
/** /**
@ -692,15 +700,18 @@ class OC_OCS {
*/ */
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 {
echo self::generateXml('', 'fail', 300, 'Client side encryption not enabled for user ' . $user);
} }
}else{ }else{
echo self::generateXml('', 'fail', 300, 'You don´t have permission to access this ressource.'); echo self::generateXml('', 'fail', 300, 'You don´t have permission to access this ressource.');
@ -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)){