Module: Yast::CaManagementCertDefaultInclude

Defined in:
../../src/include/ca-management/certDefault.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) edit_default1

Editing default certificate settings ( 1. step )

Returns:

  • `next, 'abort



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
# File '../../src/include/ca-management/certDefault.rb', line 49

def edit_default1
  # help text 1/4
  helptext = _(
    "<p>When creating a new subCA or certificate, the system suggests some default values.</p>"
  )
  # help text 2/4
  helptext = Ops.add(
    helptext,
    _("<p>With this workflow, change these default settings.</p>")
  )
  # help text 3/4
  helptext = Ops.add(
    helptext,
    _(
      "<p>However, the modified settings will be used for <b>new</B> entries only.</p>"
    )
  )
  # help text 4/4
  helptext = Ops.add(
    helptext,
    _(
      "<p>You can edit the default settings for <b>subCAs</b>, <b>client certificates</b>, and  <b>server certificates</b>.</p>"
    )
  )

  contents = VBox()

  contents = Builtins.add(
    contents,
    Frame(
      _("Default Settings for:"),
      RadioButtonGroup(
        Id(:rb),
        VBox(
          Left(RadioButton(Id("Sub CA"), _("&Sub CA"))),
          Left(
            RadioButton(Id("Client Certificate"), _("&Client Certificate"))
          ),
          Left(
            RadioButton(Id("Server Certificate"), _("S&erver Certificate"))
          )
        )
      )
    )
  )

  Wizard.SetContents(
    _("Edit Default Settings"),
    contents,
    helptext,
    true,
    true
  )
  Wizard.RestoreNextButton
  Wizard.DisableBackButton
  UI.ChangeWidget(Id(:rb), :CurrentButton, CaMgm.currentDefault)

  ui = nil
  begin
    ui = Convert.to_symbol(UI.UserInput)

    if ui == :next
      kind = Convert.to_string(UI.QueryWidget(Id(:rb), :CurrentButton))
      CaMgm.initializeDefault = true if kind != CaMgm.currentDefault

      if CaMgm.initializeDefault
        new_cert_init(kind)
        new_cert_save_default
        CaMgm.initializeDefault = false
      end
    end
    CaMgm.currentDefault = Convert.to_string(
      UI.QueryWidget(Id(:rb), :CurrentButton)
    )
  end until Builtins.contains([:next, :abort], ui)

  ui
end

- (Object) edit_default2

Saving default settings ( 3. step )

Returns:

  • 'back 'cancel



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
# File '../../src/include/ca-management/certDefault.rb', line 131

def edit_default2
  i = 0
  nextLine = false

  # help text 1/2
  helptext = _(
    "<p>This frame gives an overview of all default settings before they are saved.</p>"
  )
  # help text 2/2
  helptext = Ops.add(
    helptext,
    _("<p>Click <b>Save</b> to finish the input.</p>")
  )

  text = _("<p><b>Summary</b></p>")
  text = Ops.add(text, "<pre>")

  text = Ops.add(
    Ops.add(Ops.add(text, "Basic Constaints:         "), CaMgm.adv_ca),
    CaMgm.adv_cri_ca ? _(" (critical)\n") : "\n"
  )

  if CaMgm.adv_pathlen
    text = Ops.add(
      Ops.add(
        Ops.add(text, _("Path Length:              ")),
        CaMgm.adv_pathlenValue
      ),
      "\n"
    )
  end

  if Ops.greater_than(Builtins.size(CaMgm.adv_distribution_point), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "CRL Distribution Point:   "),
        CaMgm.adv_distribution_point
      ),
      CaMgm.adv_cri_distribution_point ? _(" (critical)\n") : "\n"
    )
  end

  if Ops.greater_than(Builtins.size(CaMgm.adv_issuer_alt_name_list), 0) ||
      CaMgm.adv_copy_issuer_alt_name
    text = Ops.add(
      Ops.add(text, "Issuer Alt Name:          "),
      CaMgm.adv_cri_issuer_alt_name ? _("(critical) ") : ""
    )
    text = Ops.add(
      text,
      CaMgm.adv_copy_issuer_alt_name ?
        _("Copy Subject Alt Name from CA") :
        ""
    )
    i = 0
    if CaMgm.adv_cri_issuer_alt_name || CaMgm.adv_copy_issuer_alt_name
      i = Ops.add(i, 1)
      text = Ops.add(text, "\n")
    end
    Builtins.foreach(CaMgm.adv_issuer_alt_name_list) do |element|
      if i == 0
        text = Ops.add(
          Ops.add(Ops.add(text, Ops.get_string(element, "kind", "")), ":"),
          Ops.get_string(element, "name", "")
        )
      else
        text = Ops.add(
          Ops.add(
            Ops.add(
              Ops.add(text, "                          "),
              Ops.get_string(element, "kind", "")
            ),
            ":"
          ),
          Ops.get_string(element, "name", "")
        )
      end
      text = Ops.add(text, "\n")
      i = Ops.add(i, 1)
    end
    text = Ops.add(text, "\n") if i == 0
  end

  if CaMgm.adv_digitalSignature || CaMgm.adv_nonRepudiation ||
      CaMgm.adv_cRLSign ||
      CaMgm.adv_keyEncipherment ||
      CaMgm.adv_dataEncipherment ||
      CaMgm.adv_encipherOnly ||
      CaMgm.adv_keyAgreement ||
      CaMgm.adv_keyCertSign ||
      CaMgm.adv_decipherOnly
    text = Ops.add(
      Ops.add(text, "Key Usage:                "),
      CaMgm.adv_cri_key_usage ? _("(critical)\n") : ""
    )
    nextLine = CaMgm.adv_cri_key_usage
    if CaMgm.adv_digitalSignature
      if !nextLine
        nextLine = true
        text = Ops.add(text, "digitalSignature\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "digitalSignature\n"
        )
      end
    end
    if CaMgm.adv_nonRepudiation
      if !nextLine
        nextLine = true
        text = Ops.add(text, "nonRepudiation\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "nonRepudiation\n"
        )
      end
    end
    if CaMgm.adv_cRLSign
      if !nextLine
        nextLine = true
        text = Ops.add(text, "cRLSign\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "cRLSign\n"
        )
      end
    end
    if CaMgm.adv_keyEncipherment
      if !nextLine
        nextLine = true
        text = Ops.add(text, "keyEncipherment\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "keyEncipherment\n"
        )
      end
    end
    if CaMgm.adv_dataEncipherment
      if !nextLine
        nextLine = true
        text = Ops.add(text, "dataEncipherment\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "dataEncipherment\n"
        )
      end
    end

    if CaMgm.adv_encipherOnly
      if !nextLine
        nextLine = true
        text = Ops.add(text, "encipherOnly\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "encipherOnly\n"
        )
      end
    end
    if CaMgm.adv_keyAgreement
      if !nextLine
        nextLine = true
        text = Ops.add(text, "keyAgreement\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "keyAgreement\n"
        )
      end
    end
    if CaMgm.adv_keyCertSign
      if !nextLine
        nextLine = true
        text = Ops.add(text, "keyCertSign\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "keyCertSign\n"
        )
      end
    end
    if CaMgm.adv_decipherOnly
      if !nextLine
        nextLine = true
        text = Ops.add(text, "decipherOnly\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "decipherOnly\n"
        )
      end
    end
    if !nextLine
      nextLine = true
      text = Ops.add(text, "\n")
    end
  end

  if Ops.greater_than(Builtins.size(CaMgm.adv_nsComment), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, _("nsComment:                ")),
        CaMgm.adv_nsComment
      ),
      CaMgm.adv_cri_nsComment ? _(" (critical)\n") : "\n"
    )
  end

  if CaMgm.adv_client || CaMgm.adv_server || CaMgm.adv_sslCA ||
      CaMgm.adv_email ||
      CaMgm.adv_reserved ||
      CaMgm.adv_emailCA ||
      CaMgm.adv_objsign ||
      CaMgm.adv_objCA
    text = Ops.add(
      Ops.add(text, _("nsCertType:               ")),
      CaMgm.adv_cri_nsCertType ? _(" (critical)\n") : ""
    )
    nextLine = CaMgm.adv_cri_nsCertType
    if CaMgm.adv_client
      if !nextLine
        nextLine = true
        text = Ops.add(text, "client\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "client\n"
        )
      end
    end
    if CaMgm.adv_server
      if !nextLine
        nextLine = true
        text = Ops.add(text, "server\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "server\n"
        )
      end
    end
    if CaMgm.adv_sslCA
      if !nextLine
        nextLine = true
        text = Ops.add(text, "sslCA\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "sslCA\n"
        )
      end
    end
    if CaMgm.adv_email
      if !nextLine
        nextLine = true
        text = Ops.add(text, "email\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "email\n"
        )
      end
    end
    if CaMgm.adv_reserved
      if !nextLine
        nextLine = true
        text = Ops.add(text, "reserved\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "reserved\n"
        )
      end
    end

    if CaMgm.adv_emailCA
      if !nextLine
        nextLine = true
        text = Ops.add(text, "emailCA\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "emailCA\n"
        )
      end
    end
    if CaMgm.adv_objsign
      if !nextLine
        nextLine = true
        text = Ops.add(text, "objsign\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "objsign\n"
        )
      end
    end
    if CaMgm.adv_objCA
      if !nextLine
        nextLine = true
        text = Ops.add(text, "objCA\n")
      else
        text = Ops.add(
          Ops.add(text, "                          "),
          "objCA\n"
        )
      end
    end
    if !nextLine
      nextLine = true
      text = Ops.add(text, "\n")
    end
  end
  if Ops.greater_than(Builtins.size(CaMgm.adv_nsSslServerName), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "nsSslServerName:          "),
        CaMgm.adv_nsSslServerName
      ),
      CaMgm.adv_cri_nsSslServerName ? _(" (critical)\n") : "\n"
    )
  end

  if Ops.greater_than(Builtins.size(CaMgm.adv_subject_alt_name_list), 0) ||
      CaMgm.adv_copy_subject_alt_name
    text = Ops.add(
      Ops.add(text, "Subject Alt Name:         "),
      CaMgm.adv_cri_subject_alt_name ? _("(critical) ") : ""
    )
    text = Ops.add(
      text,
      CaMgm.adv_copy_subject_alt_name ?
        _("Copy Standard E-Mail Address") :
        ""
    )
    i = 0
    if CaMgm.adv_cri_subject_alt_name || CaMgm.adv_copy_subject_alt_name
      i = Ops.add(i, 1)
      text = Ops.add(text, "\n")
    end
    Builtins.foreach(CaMgm.adv_subject_alt_name_list) do |element|
      if i == 0
        text = Ops.add(
          Ops.add(Ops.add(text, Ops.get_string(element, "kind", "")), ":"),
          Ops.get_string(element, "name", "")
        )
      else
        text = Ops.add(
          Ops.add(
            Ops.add(
              Ops.add(text, "                          "),
              Ops.get_string(element, "kind", "")
            ),
            ":"
          ),
          Ops.get_string(element, "name", "")
        )
      end
      text = Ops.add(text, "\n")
      i = Ops.add(i, 1)
    end
    text = Ops.add(text, "\n") if i == 0
  end

  if Ops.greater_than(Builtins.size(CaMgm.exp_subjectKeyIdentifier), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "Subject Key Identifier:   "),
        CaMgm.exp_subjectKeyIdentifier
      ),
      CaMgm.exp_cri_subjectKeyIdentifier ? _(" (critical)\n") : "\n"
    )
  end
  if Ops.greater_than(Builtins.size(CaMgm.exp_authorityKeyIdentifier), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "Authority Key Identifier: "),
        CaMgm.exp_authorityKeyIdentifier
      ),
      CaMgm.exp_cri_authorityKeyIdentifier ? _(" (critical)\n") : "\n"
    )
  end
  if Ops.greater_than(Builtins.size(CaMgm.exp_netscape_nsBaseUrl), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "nsBaseUrl:                "),
        CaMgm.exp_netscape_nsBaseUrl
      ),
      CaMgm.exp_cri_netscape_nsBaseUrl ? _(" (critical)\n") : "\n"
    )
  end
  if Ops.greater_than(Builtins.size(CaMgm.exp_netscape_nsRevocationUrl), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "nsRevocationUrl:          "),
        CaMgm.exp_netscape_nsRevocationUrl
      ),
      CaMgm.exp_cri_netscape_nsRevocationUrl ? _(" (critical)\n") : "\n"
    )
  end
  if Ops.greater_than(
      Builtins.size(CaMgm.exp_netscape_nsCaRevocationUrl),
      0
    )
    text = Ops.add(
      Ops.add(
        Ops.add(text, "nsCaRevocationUrl:        "),
        CaMgm.exp_netscape_nsCaRevocationUrl
      ),
      CaMgm.exp_cri_netscape_nsCaRevocationUrl ? _(" (critical)\n") : "\n"
    )
  end
  if Ops.greater_than(Builtins.size(CaMgm.exp_netscape_nsRenewalUrl), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "nsRenewalUrl:             "),
        CaMgm.exp_netscape_nsRenewalUrl
      ),
      CaMgm.exp_cri_netscape_nsRenewalUrl ? _(" (critical)\n") : "\n"
    )
  end
  if Ops.greater_than(Builtins.size(CaMgm.exp_netscape_nsCaPolicyUrl), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "nsCaPolicyUrl:            "),
        CaMgm.exp_netscape_nsCaPolicyUrl
      ),
      CaMgm.exp_cri_netscape_nsCaPolicyUrl ? _(" (critical)\n") : "\n"
    )
  end
  if Ops.greater_than(Builtins.size(CaMgm.exp_authorityInfoAccess), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "authorityInfoAccess:      "),
        CaMgm.exp_authorityInfoAccess
      ),
      CaMgm.exp_cri_authorityInfoAccess ? _(" (critical)\n") : "\n"
    )
  end
  if Ops.greater_than(Builtins.size(CaMgm.exp_extendedKeyUsage), 0)
    text = Ops.add(
      Ops.add(
        Ops.add(text, "extendedKeyUsage:         "),
        CaMgm.exp_extendedKeyUsage
      ),
      CaMgm.exp_cri_extendedKeyUsage ? _(" (critical)\n") : "\n"
    )
  end

  text = Ops.add(text, "</pre>")

  contents = VBox()
  contents = Builtins.add(contents, RichText(text))

  # To translators: dialog label
  Wizard.SetContents(
    _("Save Settings (step 3/3)"),
    contents,
    helptext,
    true,
    true
  )
  Wizard.SetNextButton(:next, Label.SaveButton)

  ui = nil
  begin
    ui = Convert.to_symbol(UI.UserInput)

    if ui == :next
      #creating new certificate
      if !new_cert_write_default
        showErrorCaManagement
        ui = :again
      else
        Popup.Message(_("Default has been saved."))
      end
    end
  end until Builtins.contains([:back, :next, :abort], ui)

  ui
end

- (Object) initialize_ca_management_certDefault(include_target)



34
35
36
37
38
39
40
41
42
43
44
45
# File '../../src/include/ca-management/certDefault.rb', line 34

def initialize_ca_management_certDefault(include_target)
  textdomain "ca-management"

  Yast.import "CaMgm"
  Yast.import "Wizard"
  Yast.import "Label"
  Yast.import "Popup"
  Yast.import "YaPI::CaManagement"

  Yast.include include_target, "ca-management/util.rb"
  Yast.include include_target, "ca-management/new_cert_read_write.rb"
end