Fix/improve crypto key handling in contact records
This commit is contained in:
parent
1a60eea869
commit
a6ffdf9ad6
6 changed files with 40 additions and 31 deletions
|
@ -292,7 +292,8 @@ class kolab_addressbook extends rcube_plugin
|
|||
$p['form']['personal']['content']['profession'] = array('size' => 40);
|
||||
$p['form']['personal']['content']['children'] = array('size' => 40);
|
||||
$p['form']['personal']['content']['freebusyurl'] = array('size' => 40);
|
||||
$p['form']['personal']['content']['pgppublickey'] = array('size' => 40);
|
||||
$p['form']['personal']['content']['pgppublickey'] = array('size' => 70);
|
||||
$p['form']['personal']['content']['pkcs7publickey'] = array('size' => 70);
|
||||
|
||||
// re-order fields according to the coltypes list
|
||||
$p['form']['contact']['content'] = $this->_sort_form_fields($p['form']['contact']['content']);
|
||||
|
@ -302,8 +303,9 @@ class kolab_addressbook extends rcube_plugin
|
|||
$p['form']['settings'] = array(
|
||||
'name' => $this->gettext('settings'),
|
||||
'content' => array(
|
||||
'pgppublickey' => array('size' => 40, 'visible' => true),
|
||||
'freebusyurl' => array('size' => 40, 'visible' => true),
|
||||
'pgppublickey' => array('size' => 70, 'visible' => true),
|
||||
'pkcs7publickey' => array('size' => 70, 'visible' => false),
|
||||
)
|
||||
);
|
||||
*/
|
||||
|
|
|
@ -63,9 +63,11 @@ class rcube_kolab_contacts extends rcube_addressbook
|
|||
'label' => 'kolab_addressbook.freebusyurl'),
|
||||
'pgppublickey' => array('type' => 'textarea', 'size' => 70, 'rows' => 10, 'limit' => 1,
|
||||
'label' => 'kolab_addressbook.pgppublickey'),
|
||||
'pkcs7publickey' => array('type' => 'textarea', 'size' => 70, 'rows' => 10, 'limit' => 1,
|
||||
'label' => 'kolab_addressbook.pkcs7publickey'),
|
||||
'notes' => array(),
|
||||
'photo' => array(),
|
||||
// TODO: define more Kolab-specific fields such as: language, latitude, longitude
|
||||
// TODO: define more Kolab-specific fields such as: language, latitude, longitude, crypto settings
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,8 @@ $labels['initials'] = 'Initialen';
|
|||
$labels['profession'] = 'Berufsbezeichnung';
|
||||
$labels['officelocation'] = 'Büro Adresse';
|
||||
$labels['children'] = 'Kinder';
|
||||
$labels['pgppublickey'] = 'Öffentlicher PGP-Schlüssel';
|
||||
$labels['pgppublickey'] = 'PGP-Schlüssel';
|
||||
$labels['pkcs7publickey'] = 'S/MIME-Schlüssel';
|
||||
$labels['freebusyurl'] = 'Frei/Belegt URL';
|
||||
$labels['typebusiness'] = 'Dienstlich';
|
||||
$labels['typebusinessfax'] = 'Dienst';
|
||||
|
|
|
@ -5,7 +5,8 @@ $labels['initials'] = 'Initialen';
|
|||
$labels['profession'] = 'Berufsbezeichnung';
|
||||
$labels['officelocation'] = 'Büro Adresse';
|
||||
$labels['children'] = 'Kinder';
|
||||
$labels['pgppublickey'] = 'Öffentlicher PGP-Schlüssel';
|
||||
$labels['pgppublickey'] = 'PGP-Schlüssel';
|
||||
$labels['pkcs7publickey'] = 'S/MIME-Schlüssel';
|
||||
$labels['freebusyurl'] = 'Frei/Belegt URL';
|
||||
$labels['typebusiness'] = 'Dienstlich';
|
||||
$labels['typebusinessfax'] = 'Dienst';
|
||||
|
|
|
@ -5,7 +5,8 @@ $labels['initials'] = 'Initials';
|
|||
$labels['profession'] = 'Profession';
|
||||
$labels['officelocation'] = 'Office location';
|
||||
$labels['children'] = 'Children';
|
||||
$labels['pgppublickey'] = 'PGP publickey';
|
||||
$labels['pgppublickey'] = 'PGP public key';
|
||||
$labels['pkcs7publickey'] = 'S/MIME public key';
|
||||
$labels['freebusyurl'] = 'Free-busy URL';
|
||||
$labels['typebusiness'] = 'Business';
|
||||
$labels['typebusinessfax'] = 'Business Fax';
|
||||
|
|
|
@ -270,30 +270,31 @@ class kolab_format_contact extends kolab_format
|
|||
}
|
||||
$this->obj->setRelateds($rels);
|
||||
|
||||
if (isset($object['pgppublickey'])) {
|
||||
$replace = -1;
|
||||
$keys = $this->obj->keys();
|
||||
if (!is_object($keys))
|
||||
$keys = new vectorkey;
|
||||
|
||||
for ($i=0; $i < $keys->size(); $i++) {
|
||||
$key = $keys->get($i);
|
||||
if ($key->type() == Key::PGP) {
|
||||
$replace = $i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// insert/replace pgp key entry
|
||||
$key = new Key($object['pgppublickey'], Key::PGP);
|
||||
if ($replace >= 0)
|
||||
$keys->set($replace, $key);
|
||||
else
|
||||
$keys->push($key);
|
||||
|
||||
$this->obj->setKeys($keys);
|
||||
// insert/replace crypto keys
|
||||
$pgp_index = $pkcs7_index = -1;
|
||||
$keys = $this->obj->keys();
|
||||
for ($i=0; $i < $keys->size(); $i++) {
|
||||
$key = $keys->get($i);
|
||||
if ($pgp_index < 0 && $key->type() == Key::PGP)
|
||||
$pgp_index = $i;
|
||||
else if ($pkcs7_index < 0 && $key->type() == Key::PKCS7_MIME)
|
||||
$pkcs7_index = $i;
|
||||
}
|
||||
|
||||
$pgpkey = $object['pgppublickey'] ? new Key($object['pgppublickey'], Key::PGP) : new Key();
|
||||
$pkcs7key = $object['pkcs7publickey'] ? new Key($object['pkcs7publickey'], Key::PKCS7_MIME) : new Key();
|
||||
|
||||
if ($pgp_index >= 0)
|
||||
$keys->set($pgp_index, $pgpkey);
|
||||
else if (!empty($object['pgppublickey']))
|
||||
$keys->push($pgpkey);
|
||||
if ($pkcs7_index >= 0)
|
||||
$keys->set($pkcs7_index, $pkcs7key);
|
||||
else if (!empty($object['pkcs7publickey']))
|
||||
$keys->push($pkcs7key);
|
||||
|
||||
$this->obj->setKeys($keys);
|
||||
|
||||
// TODO: handle language, gpslocation, etc.
|
||||
|
||||
|
||||
|
@ -389,13 +390,14 @@ class kolab_format_contact extends kolab_format
|
|||
// relateds -> spouse, children
|
||||
$this->read_relateds($this->obj->relateds(), $object);
|
||||
|
||||
// crypto settings: currently only pgpkey is supported
|
||||
// crypto settings: currently only key values are supported
|
||||
$keys = $this->obj->keys();
|
||||
for ($i=0; is_object($keys) && $i < $keys->size(); $i++) {
|
||||
$key = $keys->get($i);
|
||||
if ($key->type() == Key::PGP) {
|
||||
if ($key->type() == Key::PGP)
|
||||
$object['pgppublickey'] = $key->key();
|
||||
}
|
||||
else if ($key->type() == Key::PKCS7_MIME)
|
||||
$object['pkcs7publickey'] = $key->key();
|
||||
}
|
||||
|
||||
$this->data = $object;
|
||||
|
|
Loading…
Add table
Reference in a new issue