Module: Yast::CaManagementRequestInclude

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) getRequestList(currentCA)

Creates request items

Parameters:

  • name

    of the selected request

Returns:

  • a list request items formated for a UI table



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

def getRequestList(currentCA)
  result = []
  i = 0

  @requestID = []

  ret = Convert.convert(
    YaPI::CaManagement.ReadRequestList(
      { "caName" => currentCA, "caPasswd" => getPassword(currentCA) }
    ),
    :from => "list",
    :to   => "list <map>"
  )
  if ret == nil
    showErrorCaManagement
    return nil
  end
  Builtins.y2milestone("ReadRequestList(%1): %2", currentCA, ret)


  Builtins.foreach(ret) do |element|
    result = Builtins.add(
      result,
      Item(
        Id(i),
        Ops.get_string(element, "commonName", ""),
        Ops.get_string(element, "emailAddress", ""),
        Ops.get_string(element, "organizationName", ""),
        Ops.get_string(element, "organizationalUnitName", ""),
        Ops.get_string(element, "localityName", ""),
        Ops.get_string(element, "stateOrProvinceName", ""),
        Ops.get_string(element, "country", ""),
        Ops.get_string(element, "date", "")
      )
    )
    @requestID = Builtins.add(
      @requestID,
      Ops.get_string(element, "request", "")
    )
    i = Ops.add(i, 1)
  end
  deep_copy(result)
end

- (Yast::Term) getRequestTab

Dialog Tab - request -

Returns:

  • (Yast::Term)

    for requests of a selected CA



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

def getRequestTab
  certTermList = getRequestList(CaMgm.currentCA)
  return nil if certTermList == nil

  contents = VBox(
    VSpacing(1),
    HBox(
      HSpacing(1),
      Table(
        Id(:table),
        Opt(:notify, :immediate),
        Header(
          # To translators: table headers
          _("Common Name"),
          _("E-Mail Address"),
          _("Organization"),
          _("Organizational Unit"),
          _("Locality"),
          _("State"),
          _("Country"),
          _("Generate Time")
        ),
        certTermList
      ),
      HSpacing(1)
    ),
    HBox(HSpacing(1), RichText(Id(:textinfo), ""), HSpacing(1)),
    HBox(
      HSpacing(1),
      PushButton(Id(:import), _("&Import")),
      HSpacing(1),
      MenuButton(
        _("Add"),
        [
          Item(Id(:addCARequest), _("Add Sub-CA Request")),
          Item(Id(:addServerRequest), _("Add Server Request")),
          Item(Id(:addClientRequest), _("Add Client Request"))
        ]
      ),
      HStretch(),
      MenuButton(
        Id(:request),
        _("&Request"),
        [
          Item(Id(:view), _("&View")),
          Item(Id(:reqcpw), _("&Change Password")),
          term(
            :menu,
            _("Sign"),
            [
              Item(Id(:signClient), _("As Client Certificate")),
              Item(Id(:signServer), _("As Server Certificate")),
              Item(Id(:signCA), _("As CA Certificate"))
            ]
          ),
          Item(Id(:delete), _("&Delete")),
          Item(Id(:exportFile), _("Export to File"))
        ]
      ),
      HSpacing(1)
    ),
    VSpacing(1)
  )
  deep_copy(contents)
end

- (Object) handleRequestTab(event)

Handle events in a tab of a dialog



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

def handleRequestTab(event)
  event = deep_copy(event)
  ui = Ops.get(event, "ID")

  initRequestTab if ui == :table

  if ui == :view
    showLongRequestDescription(CaMgm.currentCA, CaMgm.currentRequest)
  end
  if ui == :reqcpw
    # we need to fake a certificate name
    changePassword(CaMgm.currentCA, Ops.add("00:", CaMgm.currentRequest))
  end
  if ui == :delete
    if Popup.ContinueCancelHeadline(
        _("Delete"),
        _("Delete current request?")
      )
      ret = nil
      ret = YaPI::CaManagement.DeleteRequest(
        {
          "caName"   => CaMgm.currentCA,
          "request"  => CaMgm.currentRequest,
          "caPasswd" => getPassword(CaMgm.currentCA)
        }
      )
      Builtins.y2milestone(
        "DeleteRequest(%1) return %2",
        { "caName" => CaMgm.currentCA, "request" => CaMgm.currentRequest },
        ret
      )
      showErrorCaManagement if ret == nil || ret == false
      ui = :again
    end
  end
  if ui == :signServer || ui == :signClient || ui == :signCA
    signRequestSequence(ui)
    ui = :again
  end
  if ui == :exportFile
    #Popup::Error(_("Currently not supported."));
    newreqfile = UI.AskForSaveFileName(".", "*", _("Save as"))
    if newreqfile != nil && newreqfile != ""
      ret = Convert.to_string(
        YaPI::CaManagement.ExportRequest(
          {
            "caName"          => CaMgm.currentCA,
            "caPasswd"        => getPassword(CaMgm.currentCA),
            "request"         => CaMgm.currentRequest,
            "destinationFile" => newreqfile
          }
        )
      )
      if ret != nil && ret == "1"
        Popup.Message(_("Saved to file successfully."))
      else
        showErrorCaManagement
      end
    end
  end
  if ui == :import
    importRequestFromDisk(CaMgm.currentCA)
    ui = :again
  end
  if ui == :addCARequest
    newCARequestSequence
    ui = :again
  end
  if ui == :addServerRequest
    newServerRequestSequence
    ui = :again
  end
  if ui == :addClientRequest
    newClientRequestSequence
    ui = :again
  end

  Convert.to_symbol(ui)
end

- (Object) initialize_ca_management_request(include_target)



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

def initialize_ca_management_request(include_target)
  Yast.import "CaMgm"
  Yast.import "Wizard"
  Yast.import "Label"
  Yast.import "Popup"

  textdomain "ca-management"

  Yast.include include_target, "ca-management/signRequest.rb"

  @requestID = []

  # help text 1/6
  @requestHelptext = _(
    "<p>First, see a list view with all available requests of this CA. The columns are the DN of the request including the e-mail address.</p>"
  )
  # help text 2/6
  @requestHelptext = Ops.add(
    @requestHelptext,
    _("<p>Select one of the requests and execute some actions.</p>")
  )
  # help text 3/6
  @requestHelptext = Ops.add(
    @requestHelptext,
    _(
      "<p><b>View</b> opens a window with a text representation of the complete request.</p>"
    )
  )
  # help text 4/6
  @requestHelptext = Ops.add(
    @requestHelptext,
    _(
      "<p>You can also <b>Sign</b>, <b>Delete</b>, or <b>Export</b> a request.</p>"
    )
  )
  # help text 5/6
  @requestHelptext = Ops.add(
    @requestHelptext,
    _(
      "<p>With <b>Import</b>, read a new request. With <b>Add</b>, generate a new request.</p>"
    )
  )
  # help text 6/6
  @requestHelptext = Ops.add(
    @requestHelptext,
    _(
      "<p>In the area below, see the most important values of the selected request.</p>"
    )
  )
end

- (Object) initRequestTab

Initialize the tab of the dialog



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

def initRequestTab
  anyitems = UI.QueryWidget(Id(:table), :CurrentItem) != nil
  UI.ChangeWidget(Id(:request), :Enabled, anyitems)

  id = Convert.to_integer(UI.QueryWidget(Id(:table), :CurrentItem))
  CaMgm.currentRequest = Ops.get(@requestID, id, "")

  if anyitems
    ret = Convert.to_map(
      YaPI::CaManagement.ReadRequest(
        {
          "caName"   => CaMgm.currentCA,
          "caPasswd" => getPassword(CaMgm.currentCA),
          "request"  => CaMgm.currentRequest,
          "type"     => "parsed"
        }
      )
    )
    Builtins.y2milestone(
      "ReadRequest(%1,%2): %3",
      CaMgm.currentCA,
      CaMgm.currentRequest,
      ret
    )

    # Add generation time to map
    itemTerm = Convert.to_term(UI.QueryWidget(Id(:table), term(:Item, id)))
    ret = Builtins.add(ret, "date", Ops.get_string(itemTerm, 8, ""))

    UI.ChangeWidget(
      Id(:textinfo),
      :Value,
      getRequestDescription(ret, false)
    )
  end

  nil
end

- (Object) newCARequestSequence

Creating new CA Request sequence

Returns:

  • sequence result



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File '../../src/include/ca-management/request.rb', line 133

def newCARequestSequence
  aliases = {
    "new_certinit"      => lambda { new_cert_init("Sub CA Request") },
    "new_certSaveDef"   => lambda { new_cert_save_default },
    "new_cert1"         => lambda { new_cert1("Sub CA Request") },
    "new_cert2"         => lambda { new_cert2("Sub CA Request") },
    "new_cert3"         => lambda { new_cert3("Sub CA Request") },
    "new_cert_advanced" => lambda do
      new_cert_advanced(false, "Sub-CA Request")
    end
  }

  Wizard.CreateDialog
  Wizard.SetDesktopTitleAndIcon("ca_mgm")
  ret = WizardSequencer(aliases, CaMgm.certificateSequence)

  UI.CloseDialog

  ret
end

- (Object) newClientRequestSequence

Creating new Client Request sequence

Returns:

  • sequence result



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File '../../src/include/ca-management/request.rb', line 87

def newClientRequestSequence
  aliases = {
    "new_certinit"      => lambda { new_cert_init("Client Request") },
    "new_certSaveDef"   => lambda { new_cert_save_default },
    "new_cert1"         => lambda { new_cert1("Client Request") },
    "new_cert2"         => lambda { new_cert2("Client Request") },
    "new_cert3"         => lambda { new_cert3("Client Request") },
    "new_cert_advanced" => lambda do
      new_cert_advanced(false, "Client Request")
    end
  }

  Wizard.CreateDialog
  Wizard.SetDesktopTitleAndIcon("ca_mgm")
  ret = WizardSequencer(aliases, CaMgm.certificateSequence)

  UI.CloseDialog

  ret
end

- (Object) newServerRequestSequence

Creating new Server Request sequence

Returns:

  • sequence result



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File '../../src/include/ca-management/request.rb', line 110

def newServerRequestSequence
  aliases = {
    "new_certinit"      => lambda { new_cert_init("Server Request") },
    "new_certSaveDef"   => lambda { new_cert_save_default },
    "new_cert1"         => lambda { new_cert1("Server Request") },
    "new_cert2"         => lambda { new_cert2("Server Request") },
    "new_cert3"         => lambda { new_cert3("Server Request") },
    "new_cert_advanced" => lambda do
      new_cert_advanced(false, "Server Request")
    end
  }

  Wizard.CreateDialog
  Wizard.SetDesktopTitleAndIcon("ca_mgm")
  ret = WizardSequencer(aliases, CaMgm.certificateSequence)

  UI.CloseDialog

  ret
end

- (Object) showLongRequestDescription(_CAname, _Request)

showLongRequestDescription - description of a request in textform

Parameters:

  • CA

    name , certification name



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

def showLongRequestDescription(_CAname, _Request)
  ret = Convert.to_string(
    YaPI::CaManagement.ReadRequest(
      {
        "caName"   => _CAname,
        "caPasswd" => getPassword(_CAname),
        "request"  => _Request,
        "type"     => "plain"
      }
    )
  )

  Builtins.y2milestone("ReadRequest(%1,%2): %3", _CAname, _Request, ret)
  ret = Ops.add(Ops.add("<pre>", ret), "</pre>")

  if ret == nil
    showErrorCaManagement
  else
    UI.OpenDialog(
      Opt(:decorated),
      HBox(
        VSpacing(16),
        VBox(
          HSpacing(100),
          # popup window header
          Heading(_("Description")),
          VSpacing(0.5),
          RichText(ret),
          VSpacing(1.5),
          # push button label
          PushButton(Id(:ok), Opt(:default, :key_F10), Label.OKButton)
        )
      )
    )

    UI.SetFocus(Id(:ok))
    UI.UserInput
    UI.CloseDialog
  end

  nil
end

- (Object) signRequestSequence(kind)

Signing new Request sequence

Parameters:

  • kind (Object)

    (signClient,signServer,`signCA)

Returns:

  • sequence result



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

def signRequestSequence(kind)
  kind = deep_copy(kind)
  aliases = {
    :signClient => {
      "req_init"     => lambda { signRequestInit("Client Request") },
      "req_sign1"    => lambda { signRequest1("Client Request") },
      "req_sign2"    => lambda { signRequest2("Client Request") },
      "req_advanced" => lambda { new_cert_advanced(false, "Sign Request") }
    },
    :signServer => {
      "req_init"     => lambda { signRequestInit("Server Request") },
      "req_sign1"    => lambda { signRequest1("Server Request") },
      "req_sign2"    => lambda { signRequest2("Server Request") },
      "req_advanced" => lambda { new_cert_advanced(false, "Sign Request") }
    },
    :signCA     => {
      "req_init"     => lambda { signRequestInit("CA Request") },
      "req_sign1"    => lambda { signRequest1("CA Request") },
      "req_sign2"    => lambda { signRequest2("CA Request") },
      "req_advanced" => lambda { new_cert_advanced(false, "Sign Request") }
    }
  }


  requestSequence = {
    "ws_start"     => "req_init",
    "req_init"     => { :next => "req_sign1", :abort => :abort },
    "req_sign1"    => {
      :next  => "req_sign2",
      :again => "req_sign1",
      :abort => :abort
    },
    "req_sign2"    => {
      :abort => :abort,
      :next  => :abort,
      :again => "req_sign2",
      :back  => "req_sign1",
      :edit  => "req_advanced"
    },
    "req_advanced" => { :abort => :abort, :back => "req_sign2" }
  }

  Wizard.CreateDialog
  Wizard.SetDesktopTitleAndIcon("ca_mgm")
  ret = WizardSequencer(Ops.get_map(aliases, kind, {}), requestSequence)

  UI.CloseDialog

  ret
end