-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreg.go
1585 lines (1338 loc) · 39.4 KB
/
reg.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package radir
/*
reg.go contains Registration methods.
*/
/*
Registration contains information either to be set upon, or derived from,
an LDAP entry that describes a registration.
*/
type Registration struct {
R_DN string `ldap:"dn"`
R_GSR string `ldap:"governingStructureRule"`
R_TTL string `ldap:"rATTL"`
RC_TTL string `ldap:"c-rATTL;collective"`
R_SOC string `ldap:"structuralObjectClass"`
R_CAS []string `ldap:"collectiveAttributeSubentries"`
R_OC []string `ldap:"objectClass"`
R_Desc []string `ldap:"description"` // effective "title" of reg
R_Also []string `ldap:"seeAlso"`
R_LongArc []string `ldap:"longArc"` // only permitted for subArcs of Joint-ISO-ITU-T (2).
R_X660 *X660 // ITU-T Rec. X.660 types
R_X667 *X667 // ITU-T Rec. X.667 types
R_X680 *X680 // ITU-T Rec. X.680 types
R_X690 *X690 // ITU-T Rec. X.690 types
R_Extra *Supplement // Non-standard: Supplemental types
R_Spatial *Spatial // Non-standard: Spatial types
R_DITProfile *DITProfile
r_Parent *Registration
r_Children *Registrations
r_root *registeredRoot
r_se *Subentries
}
/*
registeredRoot contains information about the nature and placement of
this registration. It is populated through subsequent X.680 input, and
will (likely) be queried at any point by other constructs, such as X.660.
*/
type registeredRoot struct {
Depth int // 0 = root, >=1 sub arc (default: -1)
N int // 0, 1 or 2 (default: -1)
Id string // identifier (name) of root
NaNF string // nameAndNumberForm ("Id(N)") of root
Structural string // rootArc or arc
Auxiliary string // iTUTRegistration, iSORegistration or jointISOITUTRegistration
}
/*
Registrations contains slices of [Registration] instances.
*/
type Registrations []*Registration
/*
Get returns an instance of *[Registration] matching the input number form
string value, or a zero instance if not found.
*/
func (r Registrations) Get(n string) (reg *Registration) {
for i := 0; i < r.Len(); i++ {
if elem := r[i].R_X680; elem.R_N == n ||
elem.R_NaNF == n ||
elem.R_ASN1Not == n ||
elem.R_DotNot == n {
reg = r[i]
break
}
}
return
}
/*
Subentries returns, and optionally initializes, the underlying instance
of *[Subentries] that have been associated with the receiver instance.
*/
func (r *Registration) Subentries() *Subentries {
if r.IsZero() {
return &Subentries{}
}
if r.r_se.IsZero() {
sents := make(Subentries, 0)
r.r_se = &sents
}
return r.r_se
}
/*
Walk returns an instance of *[Registration] following an attempt to traverse
the receiver instance using the input dot notation string value. A zero
instance is returned if not found.
*/
func (r *Registration) Walk(id any) (reg *Registration) {
switch tv := id.(type) {
case string:
if _, a, err := cleanASN1(tv); err != nil {
if dot := trimL(tv, `.`); IsNumericOID(dot) {
reg = r.walkN(split(dot, `.`))
}
} else {
nanfs := make([][]string, 0)
for i := 0; i < len(a); i++ {
nanfs = append(nanfs, nanfToSlice(a[i]))
}
reg = r.walkASN1(nanfs)
}
return
}
return
}
func (r *Registration) walkASN1(o [][]string) (reg *Registration) {
if r.IsZero() {
return
}
nanf := mknanf(o[0])
nf := o[0][1]
if nanf == r.X680().NameAndNumberForm() || nf == r.X680().N() {
if len(o) == 1 {
reg = r
} else {
reg = r.walkASN1(o[1:])
}
} else {
kids := r.Children()
for _, rg := range []*Registration{
kids.Get(nanf),
kids.Get(nf),
} {
if !rg.IsZero() {
reg = rg.walkASN1(o)
break
}
}
}
return
}
func (r *Registration) walkN(o []string) (reg *Registration) {
if top := o[0]; top == r.X680().N() {
if o = o[1:]; len(o) > 0 {
reg = r.Children().Get(o[0]).walkN(o)
} else {
reg = r
}
}
return
}
/*
Allocate will traverse the provided dot notation string value and allocate
each sub arc along the way, assigning an X.680 Number Form following child
initialization.
*/
func (r *Registration) Allocate(oid any, ident ...string) (reg *Registration) {
var o []string
var nanfs [][]string
switch tv := oid.(type) {
case string:
// First just check to see if it is already allocated
if _reg := r.Walk(tv); !_reg.IsZero() {
reg = _reg
return
}
if _, a, err := cleanASN1(tv); err != nil {
o = split(trimL(tv, `.`), `.`)
} else {
nanfs = make([][]string, 0)
for i := 0; i < len(a); i++ {
nanfs = append(nanfs, nanfToSlice(a[i]))
}
}
case []string:
if len(tv) == 0 {
return
}
o = tv
case [][]string:
if len(tv) == 0 {
return
}
nanfs = tv
}
if len(nanfs) > 0 {
reg = r.allocateASN1(nanfs)
} else if len(o) > 0 {
reg = r.allocateDotNot(o, ident...)
}
return
}
func (r *Registration) allocateDotNot(o []string, ident ...string) (reg *Registration) {
var identifier string
if len(ident) > 0 {
if IsIdentifier(ident[0]) {
identifier = ident[0]
}
}
if o[0] == r.X680().N() {
if len(o) == 1 {
reg = r
return
}
o = o[1:]
if reg = r.Children().Get(o[0]); reg.IsZero() {
if len(o) == 1 {
reg = r.NewChild(o[0], identifier)
} else {
reg = r.NewChild(o[0], ``)
return
}
reg = reg.allocateDotNot(o, ident...)
} else {
reg = reg.Allocate(o, ident...)
}
}
return
}
func (r *Registration) allocateASN1(o [][]string) (reg *Registration) {
nanf := mknanf(o[0])
if o[0][1] == r.X680().N() || nanf == r.X680().NameAndNumberForm() {
if len(o) == 1 {
reg = r
return
}
o = o[1:]
id := o[0][0]
nf := o[0][1]
if reg = r.Children().Get(nf); reg.IsZero() {
reg = r.NewChild(nf, id)
if len(o) == 1 {
return
}
}
reg = reg.allocateASN1(o)
//} else {
// reg = reg.Allocate(o)
//}
}
return
}
/*
Contains returns a Boolean value indicative of whether an instance of
*[Registration] matching the input number form was found.
*/
func (r Registrations) Contains(n string) bool {
return !r.Get(n).IsZero()
}
/*
valid returns a Boolean value indicative of the minimum requirements of
any *[Registration] instance being satisfied.
*/
func (r *Registration) valid() (ok bool) {
if !r.IsZero() {
if r.R_DN != "" && r.R_X680 != nil {
if isNumber(r.R_X680.R_N) {
ok = strInSlice(`registration`, r.R_OC)
}
}
}
return
}
/*
SetYAxes wraps [Registrations.SetYAxes] for convenient invocation against
the underlying [Registration.Children] instance.
*/
func (r *Registration) SetYAxes(recursive ...bool) {
if !r.IsZero() {
r.Children().SetYAxes(recursive...)
}
}
/*
SetXAxes wraps [Registrations.SetXAxes] for convenient invocation against
the underlying [Registration.Children] instance.
*/
func (r *Registration) SetXAxes(recursive ...bool) {
if !r.IsZero() {
r.Children().SetXAxes(recursive...)
}
}
/*
SetXAxes will link ALL X-Axis (Horizontal) spatial references according
to the number form magnitude-ordered slice instances within the receiver.
This method is merely a convenient alternative to manual (and tedious)
X-Axis associations.
The recursive variadic Boolean value indicates whether the request should
span the entire progeny of X-Axis *[Registration] instances (downward),
or if this request is limited only to the receiver.
This process will result in attempting to set all of "[minArc]", "[maxArc]",
"[leftArc]" and "[rightArc]". It will not set collective variants of these types.
Note this operation has the potential to be convenient, but also quite
intensive if the receiver contains many slice instances.
See also the [Registrations.SetYAxes] method.
[leftArc]: https://datatracker.ietf.org/doc/html/draft-coretta-oiddir-schema#section-2.3.26
[rightArc]: https://datatracker.ietf.org/doc/html/draft-coretta-oiddir-schema#section-2.3.29
[minArc]: https://datatracker.ietf.org/doc/html/draft-coretta-oiddir-schema#section-2.3.27
[maxArc]: https://datatracker.ietf.org/doc/html/draft-coretta-oiddir-schema#section-2.3.30
*/
func (r *Registrations) SetXAxes(recursive ...bool) {
var recurse bool
if len(recursive) > 0 {
recurse = recursive[0]
}
L := r.Len()
switch {
case L == 0:
// Nothing to do.
return
case L == 1:
// Its really not practical to set the
// four X-axis spatial types upon less
// than two slice members. However, if
// recursion is requested, and if that
// one element is a parent, then we'll
// handle it manually.
if single := r.Index(0); single.IsParent() && recurse {
single.SetXAxes(recurse)
}
return
}
min := (*r)[0]
max := (*r)[L-1]
for i := 0; i < L; i++ {
this := (*r)[i]
if this.DN() == "" {
// This absolutely cannot work.
continue
}
if i > 0 {
this.Spatial().SetLeftArc((*r)[i-1].DN())
}
if i < L-1 {
this.Spatial().SetRightArc((*r)[i+1].DN())
}
this.setMinMax(i, L, min, max)
if recurse && this.r_Children != nil {
this.Children().SetXAxes(recurse)
}
}
}
func (r *Registration) setMinMax(i, l int, min, max *Registration) {
if dn := min.DN(); dn != "" {
r.Spatial().SetMinArc(dn)
if r.Spatial().LeftArc() == "" && i == 0 {
// In case we're at the FIRST element
// and NO leftArc was set above ...
r.Spatial().SetLeftArc(dn)
}
}
if dn := max.DN(); dn != "" {
r.Spatial().SetMaxArc(dn)
if r.Spatial().RightArc() == "" && i == l-1 {
// In case we're at the LAST element
// and NO rightArc was set above ...
r.Spatial().SetRightArc(dn)
}
}
}
/*
SetYAxes will link all Y-Axis (Vertical) spatial references according
to vertical (root, parent, child) association. This method is merely a
convenient alternative to manual (and tedious) Y-Axis associations.
The recursive variadic Boolean value indicates whether the request should
span the entire progeny of Y-Axis *[Registration] instances (downward),
or if this request is limited only to the receiver.
This process will result in attempting to set all of "[topArc]", "[supArc]",
and "[subArc]". It will not set collective variants of these types.
Note this operation has the potential to be convenient, but also quite
intensive if the receiver contains many slice instances.
See also the [Registrations.SetXAxes] method.
[supArc]: https://datatracker.ietf.org/doc/html/draft-coretta-oiddir-schema#section-2.3.21
[topArc]: https://datatracker.ietf.org/doc/html/draft-coretta-oiddir-schema#section-2.3.23
[subArc]: https://datatracker.ietf.org/doc/html/draft-coretta-oiddir-schema#section-2.3.25
*/
func (r *Registrations) SetYAxes(recursive ...bool) {
var recurse bool
if len(recursive) > 0 {
recurse = recursive[0]
}
for i := 0; i < r.Len(); i++ {
if reg := (*r)[i]; !reg.IsZero() {
sdn := reg.DN()
tdn := reg.Spatial().TopArc()
children := reg.Children()
LK := children.Len()
for i := 0; i < LK; i++ {
if child := (*children)[i]; !child.IsZero() {
if cdn := child.DN(); cdn != "" {
reg.Spatial().SetSubArc(cdn)
}
if sdn != "" {
child.Spatial().SetSupArc(sdn)
}
if tdn != "" {
child.Spatial().SetTopArc(tdn)
}
if recurse && child.r_Children != nil {
child.Children().SetYAxes(recurse)
}
}
}
}
}
}
/*
Less returns a Boolean value indicative of whether the slice at index
i is deemed to be less than the slice at j in the context of ordering.
Ordering is implemented according to individual number form magnitudes.
*/
func (r *Registrations) Less(i, j int) (less bool) {
L := r.Len()
if L <= i || L <= j {
return
}
S1 := (*r)[i]
S2 := (*r)[j]
if S1.R_X680 == nil || S2.R_X680 == nil {
return
}
// avoid needless initialization
N1 := S1.R_X680.R_N
N2 := S2.R_X680.R_N
if N1 == "" || N2 == "" {
return
}
bint1, ok1 := atobig(N1)
bint2, ok2 := atobig(N2)
if ok1 && ok2 {
less = bint1.Cmp(bint2) == -1
}
return
}
/*
Push appends the non-zero input *[Registration] instance to the receiver
slice instance.
*/
func (r *Registrations) Push(reg *Registration) {
if !r.IsZero() {
if reg.valid() {
*r = append(*r, reg)
}
}
}
/*
Len returns the integer length of the receiver instance.
*/
func (r *Registrations) Len() (l int) {
if !r.IsZero() {
l = len(*r)
}
return
}
/*
Index returns the Nth *[Registration] instance within the receiver instance,
or a zero instance if not found.
*/
func (r *Registrations) Index(idx int) (got *Registration) {
if L := r.Len(); L > 0 {
if 0 <= idx && idx <= L-1 {
got = (*r)[idx]
} else if idx == -1 {
got = (*r)[L-1]
}
}
return
}
/*
IsParent returns a Boolean value indicative of the receiver containing
one or more child *[Registration] instances.
See also [Registrations.HasParents].
*/
func (r *Registration) IsParent() (is bool) {
if !r.IsZero() {
is = r.Children().Len() > 0
}
return
}
/*
HasParents returns a Boolean value indicative of the receiver instance
containing one or more *[Registration] instances who are parents themselves.
See also [Registration.IsParent].
*/
func (r *Registrations) HasParents() bool {
parents := 0
if !r.IsZero() {
for i := 0; i < r.Len(); i++ {
if r.Index(i).IsParent() {
parents++
}
}
}
return parents > 0
}
/*
Swap implements the func(int,int) signature required by the [sort.Interface]
signature. The result is the swapping of the specified receiver slice indices.
*/
func (r *Registrations) Swap(i, j int) {
L := r.Len()
if (-1 < i && i < L) && (-1 < j && j < L) && i != j {
(*r)[i], (*r)[j] = (*r)[j], (*r)[i]
}
}
/*
SortByNumberForm wraps *[Registrations.SortByNumberForm] for convenient
invocation of [sort.Stable] sorting of any underlying *[Registration]
(child) instances.
The recursive variadic Boolean value indicates whether the request should
span the entire progeny of *[Registration] instances (downward), or if this
request is limited only to the receiver.
Note that this particular wrapper serves no purpose when not executed with
positive recursion.
*/
func (r *Registration) SortByNumberForm(recursive ...bool) {
if !r.IsZero() {
if L := r.Children().Len(); L != 0 {
r.Children().SortByNumberForm(recursive...)
}
}
}
/*
SortByNumberForm executes [sort.Stable] to sort the contents of the receiver
slice instance according to NumberForm magnitude, ordered lowest to highest.
The recursive variadic Boolean value indicates whether the request should
span the entire progeny of *[Registration] instances (downward), or if this
request is limited only to the receiver.
*/
func (r *Registrations) SortByNumberForm(recursive ...bool) {
if L := r.Len(); L > 0 {
stabSort(r)
if len(recursive) > 0 {
if recurse := recursive[0]; recurse {
// recurse through each slice reg and sort their
// children, descending indefinitely until done.
for i := 0; i < L; i++ {
r.Index(i).SortByNumberForm(recursive...)
}
}
}
}
}
/*
Parent returns the underlying instance of *[Registration] present within
the receiver, or a zero instance if unset.
The parent instance is set automatically through use of the [Registration.NewChild]
method.
*/
func (r *Registration) Parent() (reg *Registration) {
if !r.IsZero() {
reg = r.r_Parent
}
return
}
/*
Size traverses the extent of the underlying OID tree and returns the
integer total of all non-nil *[Registration] instances found en route.
Note that this process does not traverse "upwards" -- only "downwards".
This means that for a COMPLETE total of an entire root's OIDs, this
method should be executed upon said root *[Registration] instance.
Otherwise, it will only count the number of instances from that point
downward.
*/
func (r *Registration) Size() (size int) {
if !r.IsZero() {
size++
K := r.Children()
LK := K.Len()
for i := 0; i < LK; i++ {
if sub := (*K)[i]; !sub.IsZero() {
size += sub.Size()
}
}
}
return
}
/*
Children returns the underlying instance of *[Registrations] present within
the receiver's child slice instance, or a zero instance if unset.
The child slice instances are set automatically through use of the
[Registration.NewChild] method.
*/
func (r *Registration) Children() (regs *Registrations) {
if !r.IsZero() {
if r.r_Children == nil {
k := make(Registrations, 0)
r.r_Children = &k
}
regs = r.r_Children
}
return
}
/*
IsZero returns a Boolean value indicative of a nil receiver state.
*/
func (r *Registration) IsZero() bool {
return r == nil
}
/*
IsZero returns a Boolean value indicative of a nil receiver state.
*/
func (r *Registrations) IsZero() bool {
return r == nil
}
func (r *Registration) isEmpty() bool {
return structEmpty(r)
}
/*
StructuralObjectClass returns the string-based STRUCTURAL object class,
or a zero string if unset.
Note this value is not specified manually by users.
*/
func (r *Registration) StructuralObjectClass() (soc string) {
if !r.IsZero() {
soc = r.R_SOC
}
return
}
/*
StructuralObjectClassGetFunc executes the [GetOrSetFunc] instance and
returns its own return values. The 'any' value will require type assertion
in order to be accessed reliably. An error is returned if issues arise.
*/
func (r *Registration) StructuralObjectClassGetFunc(getfunc GetOrSetFunc) (any, error) {
return getFieldValueByNameTagAndGoSF(r, getfunc, `structuralObjectClass`)
}
/*
CollectiveAttributeSubentries returns one or more LDAP distinguished names
which identify all "[collectiveAttributeSubentries]" references that serve
to populate the *[Registration] entry.
Note this value is not specified manually by users.
[collectiveAttributeSubentries]: https://www.rfc-editor.org/rfc/rfc3671.html#section-2.2
*/
func (r *Registration) CollectiveAttributeSubentries() (cas []string) {
if !r.IsZero() {
cas = r.R_CAS
}
return
}
/*
CollectiveAttributeSubentriesGetFunc executes the [GetOrSetFunc] instance
and returns its own return values. The 'any' value will require type assertion
in order to be accessed reliably. An error is returned if issues arise.
*/
func (r *Registration) CollectiveAttributeSubentriesGetFunc(getfunc GetOrSetFunc) (any, error) {
return getFieldValueByNameTagAndGoSF(r, getfunc, `collectiveAttributeSubentries`)
}
/*
DN returns the string-based LDAP Distinguished Name value, or a zero
string if unset.
*/
func (r *Registration) DN() (dn string) {
if !r.IsZero() {
dn = r.R_DN
}
return
}
/*
DNGetFunc executes the [GetOrSetFunc] instance and returns its own
return values. The 'any' value will require type assertion in order
to be accessed reliably. An error is returned if issues arise.
*/
func (r *Registration) DNGetFunc(getfunc GetOrSetFunc) (any, error) {
return getFieldValueByNameTagAndGoSF(r, getfunc, `dn`)
}
/*
SetDN assigns the first provided value to the receiver instance as a string DN.
If additional arguments are present, the second value will be asserted as an
instance of [GetOrSetFunc], returning an error if this fails.
*/
func (r *Registration) SetDN(args ...any) error {
return writeFieldByTag(`dn`, r.SetDN, r, args...)
}
/*
GoverningStructureRule returns the "[governingStructureRule]" assigned to
the receiver instance.
Note the "[governingStructureRule]" type is operational, and cannot be set
by the end user. It is also not collective.
Use of this method is only meaningful in environments which employ one or
more "[dITStructureRule]" definitions.
[governingStructureRule]: https://datatracker.ietf.org/doc/html/rfc4512#section-3.4.6
[dITStructureRule]: https://datatracker.ietf.org/doc/html/rfc4512#section-4.1.7.1
*/
func (r *Registration) GoverningStructureRule() (gsr string) {
if !r.IsZero() {
gsr = r.R_GSR
}
return
}
/*
GoverningStructureRuleGetFunc executes the [GetOrSetFunc] instance and
returns its own return values. The 'any' value will require type assertion
in order to be accessed reliably. An error is returned if issues arise.
*/
func (r *Registration) GoverningStructureRuleGetFunc(getfunc GetOrSetFunc) (any, error) {
return getFieldValueByNameTagAndGoSF(r, getfunc, `governingStructureRule`)
}
/*
Description returns one or more string description values assigned to the
receiver instance.
*/
func (r *Registration) Description() (desc []string) {
if !r.IsZero() {
desc = r.R_Desc
}
return
}
/*
SetDescription appends one or more string description values to the receiver
instance. Note that if a slice is passed as X, the destination value will be
clobbered.
*/
func (r *Registration) SetDescription(args ...any) error {
return writeFieldByTag(`description`, r.SetDescription, r, args...)
}
/*
DescriptionGetFunc processes the underlying field value(s) through the
provided [GetOrSetFunc] instance, returning an interface value alongside
an error.
*/
func (r *Registration) DescriptionGetFunc(getfunc GetOrSetFunc) (any, error) {
return getFieldValueByNameTagAndGoSF(r, getfunc, `description`)
}
/*
SeeAlso returns the string DN values assigned to the receiver instance.
*/
func (r *Registration) SeeAlso() (also []string) {
if !r.IsZero() {
also = r.R_Also
}
return
}
/*
SetSeeAlso appends one or more string DN values to the receiver instance.
Note that if a slice is passed as X, the destination value will be clobbered.
*/
func (r *Registration) SetSeeAlso(args ...any) error {
return writeFieldByTag(`seeAlso`, r.SetSeeAlso, r, args...)
}
/*
SeeAlsoGetFunc processes the underlying string DN field value(s) through
the provided [GetOrSetFunc] instance, returning an interface value alongside
an error.
*/
func (r *Registration) SeeAlsoGetFunc(getfunc GetOrSetFunc) (any, error) {
return getFieldValueByNameTagAndGoSF(r, getfunc, `seeAlso`)
}
/*
TTL returns the effective time-to-live for the receiver instance, taking
into account *[DITProfile]-inherited values as well as any subtree-based
(COLLECTIVE) and entry literal values. The output can be used to instruct
instances of [Cache] when, and when not, to cache an instance.
See [Section 2.2.3.4 of the RADUA I-D] for details related to TTL precedence.
[Section 2.2.3.4 of the RADUA I-D]: https://datatracker.ietf.org/doc/html/draft-coretta-oiddir-radua#section-2.2.3.4
*/
func (r *Registration) TTL() string {
return r.R_TTL
}
/*
SetTTL assigns the provided string TTL value to the receiver instance.
*/
func (r *Registration) SetTTL(args ...any) error {
return writeFieldByTag(`rATTL`, r.SetTTL, r, args...)
}
/*
TTLGetFunc processes the underlying TTL field value through the provided
[GetOrSetFunc] instance, returning an interface value alongside an error.
*/
func (r *Registration) TTLGetFunc(getfunc GetOrSetFunc) (any, error) {
return getFieldValueByNameTagAndGoSF(r, getfunc, `rATTL`)
}
/*
Marshal returns an error following an attempt to execute the input meth
"func(any) error" method signature.
The meth value should be the (unexecuted) [go-ldap/v3 Entry.Unmarshal]
method instance for the [Entry] being transferred (marshaled) into the
receiver instance.
Alternatively, if the user has fashioned an alternative method of the
same signature, this may be supplied instead.
[go-ldap/v3 Entry.Unmarshal]: https://pkg.go.dev/github.com/go-ldap/ldap/v3#Entry.Unmarshal
[Entry]: https://pkg.go.dev/github.com/go-ldap/ldap/v3#Entry
*/
func (r *Registration) Marshal(meth func(any) error) (err error) {
if meth == nil {
err = NilMethodErr
return
} else if r == nil {
err = NilRegistrationErr
return
}
for _, err = range []error{
meth(r),
r.X660().marshal(meth),
r.X667().marshal(meth),
r.X680().marshal(meth),
r.X690().marshal(meth),
r.Supplement().marshal(meth),
r.Spatial().marshal(meth),
} {
if err != nil {
return
}
}
// clean-up any duplicate objectClass
// slices that may have appeared, and
// remove any classes that aren't used.
r.refreshObjectClasses()
return
}
/*
Unmarshal transports values from the receiver into an instance of
map[string][]string, which can subsequently be fed to the [go-ldap/v3
NewEntry] function.
[go-ldap/v3 NewEntry]: https://pkg.go.dev/github.com/go-ldap/ldap/v3#NewEntry
*/
func (r *Registration) Unmarshal() (outer map[string][]string) {
if r.IsZero() {
return
}
outer = make(map[string][]string)
for _, inner := range []map[string][]string{
unmarshalStruct(r, outer),
r.X660().unmarshal(),
r.X667().unmarshal(),
r.X680().unmarshal(),
r.X690().unmarshal(),
r.Supplement().unmarshal(),
r.Spatial().unmarshal(),
} {
if inner != nil {
for k, v := range inner {
outer[k] = v
}
}
}
return
}
/*
Unmarshal is a convenience method that returns slices of map[string][]string
instances, each representative of an individual *[Registration] instance
that was deemed valid for unmarshaling to map[string][]string.
*/
func (r *Registrations) Unmarshal() (maps []map[string][]string) {
maps = make([]map[string][]string, 0)
for i := 0; i < len(*r); i++ {
if um := (*r)[i].Unmarshal(); len(um) > 0 {
maps = append(maps, um)
}
}
return
}
/*
Marshal returns an error following an attempt to execute all input method
[go-ldap/v3 Entry.Unmarshal] signatures. The result is a sequence of marshaled
*[Registration] instances being added to the receiver instance.
The input *[DITProfile] value will be used to initialize each *[Registration]
instance using the appropriate configuration.
[go-ldap/v3 Entry.Unmarshal]: https://pkg.go.dev/github.com/go-ldap/ldap/v3#Entry.Unmarshal
*/
func (r *Registrations) Marshal(profile *DITProfile, meths ...func(any) error) (err error) {
if !profile.Valid() {
err = DUAConfigValidityErr
return
}