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
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:
parent
8b0af505a1
commit
b1d153aa9f
@ -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
|
||||
|
@ -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();
|
17
app/Classes/LDAP/Attribute/CertificateList.php
Normal file
17
app/Classes/LDAP/Attribute/CertificateList.php
Normal 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;
|
||||
}
|
@ -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,
|
||||
];
|
||||
|
||||
|
2
public/js/custom.js
vendored
2
public/js/custom.js
vendored
@ -44,8 +44,10 @@ function getNode(item) {
|
||||
location.reload();
|
||||
break;
|
||||
case 500:
|
||||
case 555: // Missing Method
|
||||
$('.main-content').empty().append(e.responseText);
|
||||
break;
|
||||
|
||||
default:
|
||||
alert('Well that didnt work? Code ['+e.status+']');
|
||||
}
|
||||
|
@ -1,12 +1,29 @@
|
||||
@use(App\Classes\LDAP\Attribute\Certificate)
|
||||
@use(App\Classes\LDAP\Attribute\CertificateList)
|
||||
@use(App\Classes\LDAP\Attribute\Binary\JpegPhoto)
|
||||
@use(App\Classes\LDAP\Attribute\ObjectClass)
|
||||
@use(App\Classes\LDAP\Attribute\UserCertificate)
|
||||
@php($clone=FALSE)
|
||||
<span class="p-0 m-0">
|
||||
@if($o->is_rdn)
|
||||
<button class="btn btn-sm btn-outline-focus mt-3" disabled><i class="fas fa-fw fa-exchange"></i> @lang('Rename')</button>
|
||||
@elseif($edit && $o->can_addvalues)
|
||||
@switch(get_class($o))
|
||||
@case(Certificate::class)
|
||||
@case(CertificateList::class)
|
||||
<span @class(['btn','btn-sm','btn-outline-primary','mt-3','addable','d-none'=>(! $new)]) id="{{ $o->name }}-replace" disabled><i class="fas fa-fw fa-certificate"></i> @lang('Replace')</span>
|
||||
@section('page-scripts')
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#{{ $o->name }}-replace.addable').click(function(e) {
|
||||
alert('Sorry, not implemented yet');
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@append
|
||||
@break
|
||||
|
||||
@case(ObjectClass::class)
|
||||
<span type="button" @class(['btn','btn-sm','btn-outline-primary','mt-3','addable','d-none'=>(! $new)]) data-bs-toggle="modal" data-bs-target="#new_objectclass-modal"><i class="fas fa-fw fa-plus"></i> @lang('Add Objectclass')</span>
|
||||
|
||||
@ -230,21 +247,6 @@
|
||||
@append
|
||||
@break
|
||||
|
||||
@case(UserCertificate::class)
|
||||
<span @class(['btn','btn-sm','btn-outline-primary','mt-3','addable','d-none'=>(! $new)]) id="{{ $o->name }}-replace" disabled><i class="fas fa-fw fa-certificate"></i> @lang('Replace Certificate')</span>
|
||||
@section('page-scripts')
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#{{ $o->name }}-replace.addable').click(function(e) {
|
||||
alert('Sorry, not implemented yet');
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@append
|
||||
@break
|
||||
|
||||
<!-- All other attributes -->
|
||||
@default
|
||||
@if($o->isDynamic()) @break @endif
|
||||
|
@ -1,7 +1,10 @@
|
||||
<!-- $o=UserCertificate::class -->
|
||||
@use(App\Classes\LDAP\Attribute\Certificate)
|
||||
|
||||
<!-- $o=Certificate::class -->
|
||||
<x-attribute.layout :edit="$edit" :new="$new" :o="$o" langtag="binary">
|
||||
@foreach($o->tagValuesOld('binary') as $key => $value)
|
||||
@if($edit)
|
||||
<!-- If this attribute is not handle, it'll be an Attribute::class, we'll just render it normally -->
|
||||
@if(($o instanceof Certificate) && $edit)
|
||||
<input type="hidden" name="name={{ $o->name_lc }}[binary][]" value="{{ md5($value) }}">
|
||||
|
||||
<div class="input-group has-validation mb-3">
|
@ -0,0 +1,7 @@
|
||||
<!-- $o=CertificateList::class -->
|
||||
<x-attribute.layout :edit="$edit" :new="$new" :o="$o" langtag="binary">
|
||||
@foreach($o->tagValuesOld('binary') as $key => $value)
|
||||
<!-- If this attribute is not handle, it'll be an Attribute::class, we'll just render it normally -->
|
||||
<span class="form-control mb-1"><pre class="m-0">{{ $o->render_item_old('binary.'.$key) }}</pre></span>
|
||||
@endforeach
|
||||
</x-attribute.layout>
|
Loading…
x
Reference in New Issue
Block a user