More work on displaying and editing an LDAP entry
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Classes\LDAP\Attribute\Binary;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
use App\Classes\LDAP\Attribute\Binary;
|
||||
|
||||
/**
|
||||
@@ -16,26 +18,11 @@ final class JpegPhoto extends Binary
|
||||
$this->internal = FALSE;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
public function render(bool $edit=FALSE): View
|
||||
{
|
||||
// We'll use finfo to try and figure out what type of image is stored
|
||||
$f = new \finfo;
|
||||
|
||||
$result = '<table class="table table-borderless p-0 m-0"><tr>';
|
||||
|
||||
foreach ($this->values as $value) {
|
||||
switch ($x=$f->buffer($value,FILEINFO_MIME_TYPE)) {
|
||||
case 'image/jpeg':
|
||||
default:
|
||||
$result .= sprintf('<td><img class="jpegphoto" src="data:%s;base64, %s" />%s</td>',
|
||||
$x,
|
||||
base64_encode($value),
|
||||
$this->is_deletable ? sprintf('<br><span class="btn btn-sm btn-danger"><i class="fas fa-trash-alt"></i> %s</span>',__('Delete')) : '');
|
||||
}
|
||||
}
|
||||
|
||||
$result .= '</tr></table>';
|
||||
|
||||
return $result;
|
||||
return view('components.attribute.binary.jpegphoto')
|
||||
->with('edit',$edit)
|
||||
->with('o',$this)
|
||||
->with('f',new \finfo);
|
||||
}
|
||||
}
|
@@ -21,15 +21,16 @@ class Factory
|
||||
*/
|
||||
public const map = [
|
||||
'createtimestamp' => Internal\Timestamp::class,
|
||||
'creatorsname' => Internal\EntryDN::class,
|
||||
'entrycsn' => Internal\EntryCSN::class,
|
||||
'entrydn' => Internal\EntryDN::class,
|
||||
'entryuuid' => Internal\EntryUUID::class,
|
||||
'creatorsname' => Internal\DN::class,
|
||||
'contextcsn' => Internal\CSN::class,
|
||||
'entrycsn' => Internal\CSN::class,
|
||||
'entrydn' => Internal\DN::class,
|
||||
'entryuuid' => Internal\UUID::class,
|
||||
'gidnumber' => GidNumber::class,
|
||||
'hassubordinates' => Internal\HasSubordinates::class,
|
||||
'jpegphoto' => Binary\JpegPhoto::class,
|
||||
'modifytimestamp' => Internal\Timestamp::class,
|
||||
'modifiersname' => Internal\EntryDN::class,
|
||||
'modifiersname' => Internal\DN::class,
|
||||
'objectclass' => ObjectClass::class,
|
||||
'structuralobjectclass' => Internal\StructuralObjectClass::class,
|
||||
'subschemasubentry' => Internal\SubschemaSubentry::class,
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Classes\LDAP\Attribute;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
use App\Classes\LDAP\Attribute;
|
||||
|
||||
/**
|
||||
@@ -10,4 +12,11 @@ use App\Classes\LDAP\Attribute;
|
||||
abstract class Internal extends Attribute
|
||||
{
|
||||
protected bool $is_internal = TRUE;
|
||||
|
||||
public function render(bool $edit=FALSE): View
|
||||
{
|
||||
// @note Internal attributes cannot be edited
|
||||
return view('components.attribute.internal')
|
||||
->with('o',$this);
|
||||
}
|
||||
}
|
@@ -5,8 +5,8 @@ namespace App\Classes\LDAP\Attribute\Internal;
|
||||
use App\Classes\LDAP\Attribute\Internal;
|
||||
|
||||
/**
|
||||
* Represents an EntryDN Attribute
|
||||
* Represents an CSN Attribute
|
||||
*/
|
||||
final class EntryDN extends Internal
|
||||
final class CSN extends Internal
|
||||
{
|
||||
}
|
@@ -5,8 +5,8 @@ namespace App\Classes\LDAP\Attribute\Internal;
|
||||
use App\Classes\LDAP\Attribute\Internal;
|
||||
|
||||
/**
|
||||
* Represents an EntryCSN Attribute
|
||||
* Represents an DN Attribute
|
||||
*/
|
||||
final class EntryCSN extends Internal
|
||||
final class DN extends Internal
|
||||
{
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Classes\LDAP\Attribute\Internal;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
use App\Classes\LDAP\Attribute\Internal;
|
||||
|
||||
@@ -11,8 +11,10 @@ use App\Classes\LDAP\Attribute\Internal;
|
||||
*/
|
||||
final class Timestamp extends Internal
|
||||
{
|
||||
public function __toString(): string
|
||||
public function render(bool $edit=FALSE): View
|
||||
{
|
||||
return Carbon::createFromTimestamp(strtotime($this->values[0]))->format(config('ldap.datetime_format','Y-m-d H:i:s'));
|
||||
// @note Internal attributes cannot be edited
|
||||
return view('components.attribute.internal.timestamp')
|
||||
->with('o',$this);
|
||||
}
|
||||
}
|
@@ -5,8 +5,8 @@ namespace App\Classes\LDAP\Attribute\Internal;
|
||||
use App\Classes\LDAP\Attribute\Internal;
|
||||
|
||||
/**
|
||||
* Represents an EntryUUID Attribute
|
||||
* Represents an UUID Attribute
|
||||
*/
|
||||
final class EntryUUID extends Internal
|
||||
final class UUID extends Internal
|
||||
{
|
||||
}
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Classes\LDAP\Attribute;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
use App\Classes\LDAP\Attribute;
|
||||
|
||||
/**
|
||||
@@ -9,8 +11,19 @@ use App\Classes\LDAP\Attribute;
|
||||
*/
|
||||
final class ObjectClass extends Attribute
|
||||
{
|
||||
public function __toString(): string
|
||||
public function __get(string $key): mixed
|
||||
{
|
||||
return $this->values->sort()->join('<br>');
|
||||
switch ($key) {
|
||||
case 'is_structural': return FALSE; // @todo - need to determine which of the values is the structural objectclass value(s)
|
||||
default:
|
||||
return parent::__get($key);
|
||||
}
|
||||
}
|
||||
|
||||
public function render(bool $edit=FALSE): View
|
||||
{
|
||||
return view('components.attribute.objectclass')
|
||||
->with('edit',$edit)
|
||||
->with('o',$this);
|
||||
}
|
||||
}
|
@@ -2,16 +2,19 @@
|
||||
|
||||
namespace App\Classes\LDAP\Attribute;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
use App\Classes\LDAP\Attribute;
|
||||
|
||||
/**
|
||||
* Represents an attribute whose values are passwords
|
||||
*/
|
||||
class Password extends Attribute
|
||||
final class Password extends Attribute
|
||||
{
|
||||
public function __toString(): string
|
||||
public function render(bool $edit=FALSE): View
|
||||
{
|
||||
return str_repeat('*',10)
|
||||
.sprintf('<br><span class="btn btn-sm btn-outline-dark"><i class="fas fa-user-check"></i> %s</span>',__('Check Password'));
|
||||
return view('components.attribute.password')
|
||||
->with('edit',$edit)
|
||||
->with('o',$this);
|
||||
}
|
||||
}
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Classes\LDAP\Attribute;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
@@ -47,4 +48,11 @@ abstract class Schema extends Attribute
|
||||
|
||||
return Arr::get(($array ? $array->get($string) : []),$key);
|
||||
}
|
||||
|
||||
public function render(bool $edit=FALSE): View
|
||||
{
|
||||
// @note Schema attributes cannot be edited
|
||||
return view('components.attribute.internal')
|
||||
->with('o',$this);
|
||||
}
|
||||
}
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Classes\LDAP\Attribute\Schema;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
use App\Classes\LDAP\Attribute\Schema;
|
||||
|
||||
/**
|
||||
@@ -9,21 +11,6 @@ use App\Classes\LDAP\Attribute\Schema;
|
||||
*/
|
||||
final class Mechanisms extends Schema
|
||||
{
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->values
|
||||
->transform(function($item) {
|
||||
$format = sprintf('<abbr class="pb-1" title="%s"><i class="fas fa-book pe-2"></i>%s</abbr>%s<p class="mb-0">%s</p>',
|
||||
$item,
|
||||
static::get($item,'title'),
|
||||
($x=static::get($item,'ref')) ? sprintf('<abbr class="ps-2" title="%s"><i class="fas fa-comment-dots"></i></abbr>',$x) : '',
|
||||
static::get($item,'desc'),
|
||||
);
|
||||
|
||||
return $format;
|
||||
})->join('<br>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an SASL Mechanism name, returns a verbose description of the Mechanism.
|
||||
* This function parses ldap_supported_saslmechanisms.txt and looks up the specified
|
||||
@@ -41,8 +28,15 @@ final class Mechanisms extends Schema
|
||||
* @param string $key The title|ref|desc to return
|
||||
* @return string|NULL
|
||||
*/
|
||||
protected static function get(string $string,string $key): ?string
|
||||
public static function get(string $string,string $key): ?string
|
||||
{
|
||||
return parent::_get(config_path('ldap_supported_saslmechanisms.txt'),$string,$key);
|
||||
}
|
||||
|
||||
public function render(bool $edit=FALSE): View
|
||||
{
|
||||
// @note Schema attributes cannot be edited
|
||||
return view('components.attribute.schema.mechanisms')
|
||||
->with('o',$this);
|
||||
}
|
||||
}
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Classes\LDAP\Attribute\Schema;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
use App\Classes\LDAP\Attribute\Schema;
|
||||
|
||||
/**
|
||||
@@ -9,25 +11,6 @@ use App\Classes\LDAP\Attribute\Schema;
|
||||
*/
|
||||
final class OID extends Schema
|
||||
{
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->values
|
||||
->transform(function($item) {
|
||||
if (preg_match('/[0-9]+\.[0-9]+\.[0-9]+/',$item)) {
|
||||
$format = sprintf('<abbr class="pb-1" title="%s"><i class="fas fa-list-ol pe-2"></i>%s</abbr>%s<p class="mb-0">%s</p>',
|
||||
$item,
|
||||
static::get($item,'title'),
|
||||
($x=static::get($item,'ref')) ? sprintf('<abbr class="ps-2" title="%s"><i class="fas fa-comment-dots"></i></abbr>',$x) : '',
|
||||
static::get($item,'desc'),
|
||||
);
|
||||
|
||||
return $format;
|
||||
|
||||
} else
|
||||
return $item;
|
||||
})->join('<br>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an LDAP OID number, returns a verbose description of the OID.
|
||||
* This function parses ldap_supported_oids.txt and looks up the specified
|
||||
@@ -46,8 +29,15 @@ final class OID extends Schema
|
||||
* @return string|null
|
||||
* @testedby TranslateOidTest::testRootDSE()
|
||||
*/
|
||||
protected static function get(string $string,string $key): ?string
|
||||
public static function get(string $string,string $key): ?string
|
||||
{
|
||||
return parent::_get(config_path('ldap_supported_oids.txt'),$string,$key);
|
||||
}
|
||||
|
||||
public function render(bool $edit=FALSE): View
|
||||
{
|
||||
// @note Schema attributes cannot be edited
|
||||
return view('components.attribute.schema.oid')
|
||||
->with('o',$this);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user