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-01 22:54:30 +00:00
|
|
|
'entryuuid' => Internal\EntryUUID::class,
|
2023-02-19 09:25:32 +00:00
|
|
|
'jpegphoto' => Binary\JpegPhoto::class,
|
2023-03-01 22:54:30 +00:00
|
|
|
'objectclass' => ObjectClass::class,
|
|
|
|
'supportedcontrol' => Schema\OID::class,
|
|
|
|
'supportedextension' => Schema\OID::class,
|
|
|
|
'supportedfeatures' => Schema\OID::class,
|
|
|
|
'supportedsaslmechanisms' => Schema\Mechanisms::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);
|
|
|
|
}
|
|
|
|
}
|