WIP of SMIME support: implement smime type storage

This commit is contained in:
Hadi Nategh 2017-01-25 18:03:35 +01:00
parent 75a83fa35c
commit efbb02b1b7
2 changed files with 16 additions and 3 deletions

View File

@ -1254,6 +1254,19 @@ class Account implements \ArrayAccess
{ {
Credentials::delete($data['acc_id'], $valid_for, Credentials::SMTP, true); Credentials::delete($data['acc_id'], $valid_for, Credentials::SMTP, true);
} }
//Store or delete smime private key
if ($data['acc_smime_password'])
{
Credentials::write($data['acc_id'], $data['acc_imap_username'],
$data['acc_smime_password'], Credentials::SMIME, $data['account_id'][0],
$data['acc_smime_cred_id']);
}
else
{
Credentials::delete($data['acc_id'], $data['account_id'][0], Credentials::SMIME);
}
// store or delete admin credentials // store or delete admin credentials
if ($data['acc_imap_admin_username'] && $data['acc_imap_admin_password']) if ($data['acc_imap_admin_username'] && $data['acc_imap_admin_password'])
{ {

View File

@ -59,7 +59,7 @@ class Credentials
*/ */
const ADMIN = 8; const ADMIN = 8;
/** /**
* Credentials for admin connection * Credentials for SMIME private key
*/ */
const SMIME = 16; const SMIME = 16;
/** /**
@ -277,7 +277,7 @@ class Credentials
* @param int $acc_id id of account * @param int $acc_id id of account
* @param string $username * @param string $username
* @param string $password cleartext password to write * @param string $password cleartext password to write
* @param int $type self::IMAP, self::SMTP or self::ADMIN * @param int $type self::IMAP, self::SMTP, self::ADMIN or self::SMIME
* @param int $account_id if of user-account for whom credentials are * @param int $account_id if of user-account for whom credentials are
* @param int $cred_id =null id of existing credentials to update * @param int $cred_id =null id of existing credentials to update
* @return int cred_id * @return int cred_id
@ -338,7 +338,7 @@ class Credentials
* *
* @param int $acc_id * @param int $acc_id
* @param int|array $account_id =null * @param int|array $account_id =null
* @param int $type =self::ALL self::IMAP, self::SMTP or self::ADMIN * @param int $type = self::IMAP, self::SMTP, self::ADMIN or self::SMIME
* @param boolean $exact_type =false true: delete only cred_type=$type, false: delete cred_type&$type * @param boolean $exact_type =false true: delete only cred_type=$type, false: delete cred_type&$type
* @return int number of rows deleted * @return int number of rows deleted
*/ */