Commit ae70924e authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch '6055-add-a-basic-kerberos-plugin' into '1.4-dev'

Resolve "Add a basic kerberos plugin"

See merge request fusiondirectory/fd-plugins!740
parents b43717af 70012727
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org)
Copyright (C) 2019-2020 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
class KrbExtraDataAttribute extends Attribute
{
function renderFormInput (): string
{
return '';
}
public function htmlIds (): array
{
return [];
}
protected function arrayValue ($value): array
{
$prefix = substr($value, 0, 2);
if ($prefix === hex2bin('0002')) {
$tag = _('Last modification');
//~ - 3-6: are the unix time stamp
//~ - 7-end: zero-terminated string with the principal of the changer
$data = unpack('Vtimestamp/a*user', $value, 2);
$content = sprintf(_('%s - by "%s"'), date('Y-m-d, H:i:s', $data['timestamp']), $data['user']);
} elseif ($prefix === hex2bin('0008')) {
$data = unpack('vversion', $value, 2);
$tag = _('Version');
$content = $data['version'];
} else {
/* Unknown tag, show hexadecimal data */
$tag = bin2hex($prefix);
$content = bin2hex(substr($value, 2));
}
return [$tag, $content];
}
/* Return the value as an array of values to be displayed in a table columns */
function getArrayValue (): array
{
return $this->arrayValue($this->getValue());
}
function displayValue ($value): string
{
return implode(' - ', $this->arrayValue($value));
}
}
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org)
Copyright (C) 2019-2020 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
class NoAddOrderedArrayAttribute extends OrderedArrayAttribute
{
function renderButtons ()
{
return '';
}
public function htmlIds (): array
{
$id = $this->getHtmlId();
$ids = [];
if ($this->attribute !== FALSE) {
$ids = array_merge($ids, $this->attribute->htmlIds());
}
$nb_values = count($this->value);
for ($i = 0; $i < $nb_values; ++$i) {
if ($this->order) {
if ($i > 0) {
$ids[] = $id.'_up_'.$i;
}
if (($i + 1) < $nb_values) {
$ids[] = $id.'_down_'.$i;
}
}
$ids[] = $id.'_del_'.$i;
}
return $ids;
}
}
......@@ -59,11 +59,9 @@ class kerberosAccount extends simplePlugin
'krbUPEnabled', 'This flag is used to find whether directory User Password has to be used as kerberos password',
'krbUPEnabled', FALSE
),
new SetAttribute(
new StringAttribute(
'krbPrincipalKey', 'This attribute holds the principal\'s key (krbPrincipalKey) that is encrypted with the master key (krbMKey). The attribute is ASN.1 encoded.',
'krbPrincipalKey', FALSE
)
new HiddenArrayAttribute(
'krbPrincipalKey', 'This attribute holds the principal\'s key (krbPrincipalKey) that is encrypted with the master key (krbMKey). The attribute is ASN.1 encoded.',
'krbPrincipalKey', FALSE
),
new StringAttribute(
'krbTicketPolicyReference', 'FDN pointing to a Kerberos Ticket Policy object.',
......@@ -119,11 +117,12 @@ class kerberosAccount extends simplePlugin
'krbLoginFailedCount', FALSE,
FALSE, FALSE
),
new SetAttribute(
new StringAttribute(
new NoAddOrderedArrayAttribute(
new KrbExtraDataAttribute(
'krbExtraData', 'This attribute holds the application specific data.',
'krbExtraData', FALSE
)
),
FALSE
),
new SetAttribute(
new StringAttribute(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment