2021-12-08 12:26:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Classes\LDAP\Attribute;
|
|
|
|
|
|
|
|
use Illuminate\Support\Arr;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
2023-03-01 22:54:30 +00:00
|
|
|
use App\Classes\LDAP\Attribute;
|
2021-12-08 12:26:12 +00:00
|
|
|
|
2021-12-10 11:39:09 +00:00
|
|
|
/**
|
|
|
|
* This factory is used to return LDAP attributes as an object
|
|
|
|
*
|
|
|
|
* If there is no specific Attribute defined, then the default Attribute::class is return
|
|
|
|
*/
|
2021-12-08 12:26:12 +00:00
|
|
|
class Factory
|
|
|
|
{
|
|
|
|
private const LOGKEY = 'LAf';
|
|
|
|
|
|
|
|
/**
|
2021-12-10 11:39:09 +00:00
|
|
|
* Map of attributes to appropriate class
|
2021-12-08 12:26:12 +00:00
|
|
|
*/
|
|
|
|
public const map = [
|
2023-03-02 07:21:53 +00:00
|
|
|
'createtimestamp' => Internal\Timestamp::class,
|
|
|
|
'creatorsname' => Internal\EntryDN::class,
|
|
|
|
'entrycsn' => Internal\EntryCSN::class,
|
|
|
|
'entrydn' => Internal\EntryDN::class,
|
2023-03-01 22:54:30 +00:00
|
|
|
'entryuuid' => Internal\EntryUUID::class,
|
2023-03-02 07:21:53 +00:00
|
|
|
'gidnumber' => GidNumber::class,
|
|
|
|
'hassubordinates' => Internal\HasSubordinates::class,
|
2023-02-19 09:25:32 +00:00
|
|
|
'jpegphoto' => Binary\JpegPhoto::class,
|
2023-03-02 07:21:53 +00:00
|
|
|
'modifytimestamp' => Internal\Timestamp::class,
|
|
|
|
'modifiersname' => Internal\EntryDN::class,
|
2023-03-01 22:54:30 +00:00
|
|
|
'objectclass' => ObjectClass::class,
|
2023-03-02 07:21:53 +00:00
|
|
|
'structuralobjectclass' => Internal\StructuralObjectClass::class,
|
|
|
|
'subschemasubentry' => Internal\SubschemaSubentry::class,
|
2023-03-01 22:54:30 +00:00
|
|
|
'supportedcontrol' => Schema\OID::class,
|
|
|
|
'supportedextension' => Schema\OID::class,
|
|
|
|
'supportedfeatures' => Schema\OID::class,
|
|
|
|
'supportedsaslmechanisms' => Schema\Mechanisms::class,
|
2023-03-02 07:21:53 +00:00
|
|
|
'userpassword' => Password::class,
|
2021-12-08 12:26:12 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
2021-12-10 11:39:09 +00:00
|
|
|
* Create the new Object for an attribute
|
2021-12-08 12:26:12 +00:00
|
|
|
*
|
|
|
|
* @param string $attribute
|
|
|
|
* @param array $values
|
|
|
|
* @return Attribute
|
|
|
|
*/
|
|
|
|
public static function create(string $attribute,array $values): Attribute
|
|
|
|
{
|
2023-03-01 22:54:30 +00:00
|
|
|
$class = Arr::get(self::map,$attribute,Attribute::class);
|
2021-12-08 12:26:12 +00:00
|
|
|
Log::debug(sprintf('%s:Creating LDAP Attribute [%s] as [%s]',static::LOGKEY,$attribute,$class));
|
|
|
|
|
|
|
|
return new $class($attribute,$values);
|
|
|
|
}
|
|
|
|
}
|