Implemented more attribute classes

This commit is contained in:
2023-03-02 18:21:53 +11:00
parent 7d19b89637
commit a99770951d
26 changed files with 245 additions and 181 deletions

View File

@@ -14,7 +14,7 @@ class Attribute
// Attribute Name
protected string $name;
protected ?AttributeType $schema;
protected ?AttributeType $schema = NULL;
/*
# Source of this attribute definition
@@ -28,7 +28,7 @@ class Attribute
protected bool $is_deletable = FALSE;
// Is this attribute an internal attribute
protected bool $is_internal;
protected bool $is_internal = FALSE;
// Is this attribute the RDN?
protected bool $is_rdn = FALSE;
@@ -95,7 +95,9 @@ class Attribute
$this->name = $name;
$this->values = collect($values);
$this->schema = config('server')->schema('attributetypes',$name);
// No need to load our schema for internal attributes
if (! $this->is_internal)
$this->schema = config('server')->schema('attributetypes',$name);
/*
# Should this attribute be hidden

View File

@@ -7,6 +7,6 @@ use App\Classes\LDAP\Attribute;
/**
* Represents an attribute whose values are binary
*/
abstract class Binary extends Attribute
class Binary extends Attribute
{
}

View File

@@ -5,7 +5,7 @@ namespace App\Classes\LDAP\Attribute\Binary;
use App\Classes\LDAP\Attribute\Binary;
/**
* Represents an attribute whose values are jpeg pictures
* Represents an JpegPhoto Attribute
*/
final class JpegPhoto extends Binary
{

View File

@@ -20,13 +20,24 @@ class Factory
* Map of attributes to appropriate class
*/
public const map = [
'createtimestamp' => Internal\Timestamp::class,
'creatorsname' => Internal\EntryDN::class,
'entrycsn' => Internal\EntryCSN::class,
'entrydn' => Internal\EntryDN::class,
'entryuuid' => Internal\EntryUUID::class,
'gidnumber' => GidNumber::class,
'hassubordinates' => Internal\HasSubordinates::class,
'jpegphoto' => Binary\JpegPhoto::class,
'modifytimestamp' => Internal\Timestamp::class,
'modifiersname' => Internal\EntryDN::class,
'objectclass' => ObjectClass::class,
'structuralobjectclass' => Internal\StructuralObjectClass::class,
'subschemasubentry' => Internal\SubschemaSubentry::class,
'supportedcontrol' => Schema\OID::class,
'supportedextension' => Schema\OID::class,
'supportedfeatures' => Schema\OID::class,
'supportedsaslmechanisms' => Schema\Mechanisms::class,
'userpassword' => Password::class,
];
/**

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Classes\LDAP\Attribute;
use App\Classes\LDAP\Attribute;
/**
* Represents an GidNumber Attribute
*/
final class GidNumber extends Attribute
{
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Classes\LDAP\Attribute\Internal;
use App\Classes\LDAP\Attribute\Internal;
/**
* Represents an EntryCSN Attribute
*/
final class EntryCSN extends Internal
{
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Classes\LDAP\Attribute\Internal;
use App\Classes\LDAP\Attribute\Internal;
/**
* Represents an EntryDN Attribute
*/
final class EntryDN extends Internal
{
}

View File

@@ -5,7 +5,7 @@ namespace App\Classes\LDAP\Attribute\Internal;
use App\Classes\LDAP\Attribute\Internal;
/**
* Represents an attribute whose values are binary
* Represents an EntryUUID Attribute
*/
final class EntryUUID extends Internal
{

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Classes\LDAP\Attribute\Internal;
use App\Classes\LDAP\Attribute\Internal;
/**
* Represents an HasSubordinates Attribute
*/
final class HasSubordinates extends Internal
{
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Classes\LDAP\Attribute\Internal;
use App\Classes\LDAP\Attribute\Internal;
/**
* Represents an StructuralObjectClass Attribute
*/
final class StructuralObjectClass extends Internal
{
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Classes\LDAP\Attribute\Internal;
use App\Classes\LDAP\Attribute\Internal;
/**
* Represents an SubschemaSubentry Attribute
*/
final class SubschemaSubentry extends Internal
{
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Classes\LDAP\Attribute\Internal;
use Carbon\Carbon;
use App\Classes\LDAP\Attribute\Internal;
/**
* Represents an attribute whose values are timestamps
*/
final class Timestamp extends Internal
{
public function __toString(): string
{
return Carbon::createFromTimestamp(strtotime($this->values[0]))->format(config('ldap.datetime_format','Y-m-d H:i:s'));
}
}

View File

@@ -5,7 +5,7 @@ namespace App\Classes\LDAP\Attribute;
use App\Classes\LDAP\Attribute;
/**
* Represents an attribute whose values are jpeg pictures
* Represents an ObjectClass Attribute
*/
final class ObjectClass extends Attribute
{

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Classes\LDAP\Attribute;
use App\Classes\LDAP\Attribute;
/**
* Represents an attribute whose values are passwords
*/
class Password extends Attribute
{
public function __toString(): string
{
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'));
}
}

View File

@@ -5,7 +5,7 @@ namespace App\Classes\LDAP\Attribute\Schema;
use App\Classes\LDAP\Attribute\Schema;
/**
* Represents an attribute whose values are binary
* Represents a Mechanisms Attribute
*/
final class Mechanisms extends Schema
{

View File

@@ -5,7 +5,7 @@ namespace App\Classes\LDAP\Attribute\Schema;
use App\Classes\LDAP\Attribute\Schema;
/**
* Represents an attribute whose values are binary
* Represents an OID Attribute
*/
final class OID extends Schema
{