Change Attribute/UserCertificate into Syntax/Certificate for any Certificate attributes. Add Syntax/CertificateList.
All checks were successful
Create Docker Image / Test Application (x86_64) (push) Successful in 29s
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 1m30s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 4m34s
Create Docker Image / Final Docker Image Manifest (push) Successful in 8s

This commit is contained in:
2025-04-10 22:08:18 +10:00
parent 8b0af505a1
commit b1d153aa9f
8 changed files with 76 additions and 29 deletions

View File

@@ -37,6 +37,9 @@ class Attribute implements \Countable, \ArrayAccess
// The objectclasses of the entry that has this attribute
protected(set) Collection $oc;
private const SYNTAX_CERTIFICATE = '1.3.6.1.4.1.1466.115.121.1.8';
private const SYNTAX_CERTIFICATE_LIST = '1.3.6.1.4.1.1466.115.121.1.9';
/*
# Has the attribute been modified
protected $modified = false;
@@ -123,6 +126,11 @@ class Attribute implements \Countable, \ArrayAccess
*/
}
public function __call(string $name,array $arguments)
{
abort(555,'Method not handled: '.$name);
}
public function __get(string $key): mixed
{
return match ($key) {
@@ -303,9 +311,14 @@ class Attribute implements \Countable, \ArrayAccess
*/
public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
{
$view = view()->exists($x='components.attribute.'.$this->name_lc)
? view($x)
: view('components.attribute');
$view = match ($this->schema->syntax_oid) {
self::SYNTAX_CERTIFICATE => view('components.syntax.certificate'),
self::SYNTAX_CERTIFICATE_LIST => view('components.syntax.certificatelist'),
default => view()->exists($x = 'components.attribute.' . $this->name_lc)
? view($x)
: view('components.attribute'),
};
return $view
->with('o',$this)
@@ -316,7 +329,12 @@ class Attribute implements \Countable, \ArrayAccess
public function render_item_old(string $dotkey): ?string
{
return Arr::get($this->values_old->dot(),$dotkey);
return match ($this->schema->syntax_oid) {
self::SYNTAX_CERTIFICATE => join("\n",str_split(base64_encode(Arr::get($this->values_old->dot(),$dotkey)),80)),
self::SYNTAX_CERTIFICATE_LIST => join("\n",str_split(base64_encode(Arr::get($this->values_old->dot(),$dotkey)),80)),
default => Arr::get($this->values_old->dot(),$dotkey),
};
}
public function render_item_new(string $dotkey): ?string

View File

@@ -11,7 +11,7 @@ use App\Traits\MD5Updates;
/**
* Represents an attribute whose values is a binary user certificate
*/
final class UserCertificate extends Attribute
final class Certificate extends Attribute
{
use MD5Updates;
@@ -38,11 +38,6 @@ final class UserCertificate extends Attribute
return Carbon::createFromTimestampUTC($this->cert_info('validTo_time_t',$key));
}
public function render_item_old(string $dotkey): ?string
{
return join("\n",str_split(base64_encode(parent::render_item_old($dotkey)),80));
}
public function subject($key=0): string
{
$subject = collect($this->cert_info('subject',$key))->reverse();

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Classes\LDAP\Attribute;
use Carbon\Carbon;
use Illuminate\Support\Arr;
use App\Classes\LDAP\Attribute;
use App\Traits\MD5Updates;
/**
* Represents an attribute whose values is a binary user certificate
*/
final class CertificateList extends Attribute
{
use MD5Updates;
}

View File

@@ -20,6 +20,9 @@ class Factory
* Map of attributes to appropriate class
*/
public const map = [
'authorityrevocationlist' => CertificateList::class,
'cacertificate' => Certificate::class,
'certificaterevocationlist' => CertificateList::class,
'createtimestamp' => Internal\Timestamp::class,
'creatorsname' => Internal\DN::class,
'configcontext' => Schema\Generic::class,
@@ -52,7 +55,7 @@ class Factory
'supportedfeatures' => Schema\OID::class,
'supportedldapversion' => Schema\Generic::class,
'supportedsaslmechanisms' => Schema\Mechanisms::class,
'usercertificate' => UserCertificate::class,
'usercertificate' => Certificate::class,
'userpassword' => Password::class,
];