Module: Yast::CaManagementCaInclude

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) editDefaultSequence

Editing certificate defaults

Returns:

  • sequence result



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File '../../src/include/ca-management/ca.rb', line 99

def editDefaultSequence
  aliases = {
    "new_default1" => lambda { edit_default1 },
    "new_default2" => lambda { new_cert_advanced(true, "Default") },
    "new_default3" => lambda { edit_default2 }
  }

  Wizard.CreateDialog
  Wizard.SetDesktopTitleAndIcon("ca_mgm")
  ret = WizardSequencer(aliases, @defaultSequence)

  UI.CloseDialog

  ret
end

- (Yast::Term) getCATab

Dialog Tab - CA -

Returns:

  • (Yast::Term)

    the selected CA



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

def getCATab
  contents = VBox(
    VSpacing(1),
    HBox(HSpacing(1), RichText(Id(:textinfo), ""), HSpacing(1)),
    HBox(
      HSpacing(1),
      # To translators: pushbutton label
      Right(
        MenuButton(
          _("&Advanced..."),
          [
            Item(Id(:information), _("&View")),
            Item(Id(:cacpw), _("&Change CA Password")),
            Item(Id(:createSubCA), _("C&reate SubCA")),
            Item(Id(:exportFile), _("Export to &File")),
            Item(Id(:exportLDAP), _("Export to &LDAP")),
            Item(Id(:editDefault), _("&Edit Default"))
          ]
        )
      ),
      HSpacing(1)
    ),
    VSpacing(1)
  )
  deep_copy(contents)
end

- (Object) getDescriptionCA(_CAname)

getDescriptionCA - description of a CA

Parameters:

  • CA

    name

Returns:

  • a string with the CA description



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

def getDescriptionCA(_CAname)
  text = Builtins.sformat(_("<p><b> Description for %1 </b></p>"), _CAname)

  ret = Convert.to_map(
    YaPI::CaManagement.ReadCA(
      {
        "caName"   => _CAname,
        "caPasswd" => getPassword(_CAname),
        "type"     => "parsed"
      }
    )
  )
  if ret == nil
    showErrorCaManagement
    return _("\nCA not found")
  end
  Builtins.y2milestone("ReadCA(%1): %2", _CAname, ret)

  dn = Ops.get_map(ret, "DN_HASH", {})
  if Ops.greater_than(Builtins.size(dn), 0)
    text = Ops.add(text, _("<p><b>Issued For:</b></p>"))
    text = Ops.add(text, "<pre>")
    text = Ops.add(
      # Preformated Text: take care that all translations have the same length
      Ops.add(text, _("\nCommon Name:  ")),
      Ops.get_string(Ops.get_list(dn, "CN", []), 0, "")
    )
    text = Ops.add(
      # Preformated Text: take care that all translations have the same length
      Ops.add(text, _("\nOrganization: ")),
      Ops.get_string(Ops.get_list(dn, "O", []), 0, "")
    )
    text = Ops.add(
      # Preformated Text: take care that all translations have the same length
      Ops.add(text, _("\nLocation:     ")),
      Ops.get_string(Ops.get_list(dn, "L", []), 0, "")
    )
    text = Ops.add(
      # Preformated Text: take care that all translations have the same length
      Ops.add(text, _("\nState:        ")),
      Ops.get_string(Ops.get_list(dn, "ST", []), 0, "")
    )
    text = Ops.add(
      # Preformated Text: take care that all translations have the same length
      Ops.add(text, _("\nCountry:      ")),
      Ops.get_string(Ops.get_list(dn, "C", []), 0, "")
    )
    text = Ops.add(
      # Preformated Text: take care that all translations have the same length
      Ops.add(text, _("\nEMAIL:        ")),
      Ops.get_string(Ops.get_list(dn, "emailAddress", []), 0, "")
    )
    text = Ops.add(text, "</pre>")
  end

  issuer = Ops.get_map(ret, "ISSUER_HASH", {})
  if Ops.greater_than(Builtins.size(issuer), 0)
    text = Ops.add(text, _("<p><b>Issued By:</b></p>"))
    text = Ops.add(text, "<pre>")
    text = Ops.add(
      # Preformated Text: take care that all translations have the same length
      Ops.add(text, _("\nCommon Name:  ")),
      Ops.get_string(Ops.get_list(issuer, "CN", []), 0, "")
    )
    text = Ops.add(
      # Preformated Text: take care that all translations have the same length
      Ops.add(text, _("\nOrganization: ")),
      Ops.get_string(Ops.get_list(issuer, "O", []), 0, "")
    )
    text = Ops.add(
      # Preformated Text: take care that all translations have the same length
      Ops.add(text, _("\nLocation:     ")),
      Ops.get_string(Ops.get_list(issuer, "L", []), 0, "")
    )
    text = Ops.add(
      # Preformated Text: take care that all translations have the same length
      Ops.add(text, _("\nState:        ")),
      Ops.get_string(Ops.get_list(issuer, "ST", []), 0, "")
    )
    text = Ops.add(
      # Preformated Text: take care that all translations have the same length
      Ops.add(text, _("\nCountry:      ")),
      Ops.get_string(Ops.get_list(issuer, "C", []), 0, "")
    )
    text = Ops.add(
      # Preformated Text: take care that all translations have the same length
      Ops.add(text, _("\nEMAIL:        ")),
      Ops.get_string(Ops.get_list(issuer, "emailAddress", []), 0, "")
    )
    text = Ops.add(text, "</pre>")
  end

  text = Ops.add(
    Ops.add(text, _("\nValid from: ")),
    Ops.get_string(ret, "NOTBEFORE", "")
  )
  text = Ops.add(
    Ops.add(Ops.add(text, "<br>"), _("\nValid to: ")),
    Ops.get_string(ret, "NOTAFTER", "")
  )
  text = Ops.add(
    Ops.add(Ops.add(text, "<br>"), "Fingerprint: "),
    Ops.get_string(ret, "FINGERPRINT", "")
  )

  text
end

- (Object) handleCATab(event)

Handle events in a tab of a dialog



309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File '../../src/include/ca-management/ca.rb', line 309

def handleCATab(event)
  event = deep_copy(event)
  ret = Ops.get(event, "ID")
  showLongDescriptionCA(CaMgm.currentCA) if ret == :information
  changePassword(CaMgm.currentCA, "") if ret == :cacpw
  exportToLDAP("CA", CaMgm.currentCA, "", "", "", "") if ret == :exportLDAP
  exportCAtoFile(CaMgm.currentCA) if ret == :exportFile
  if ret == :editDefault
    # initialize global variable
    CaMgm.initializeDefault = true
    CaMgm.currentDefault = "Sub CA"
    editDefaultSequence
  end
  newSubCASequence if ret == :createSubCA
  nil
end

- (Object) initCATab

Initialize the tab of the dialog



302
303
304
305
306
# File '../../src/include/ca-management/ca.rb', line 302

def initCATab
  UI.ChangeWidget(Id(:textinfo), :Value, getDescriptionCA(CaMgm.currentCA))

  nil
end

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

def initialize_ca_management_ca(include_target)
  textdomain "ca-management"

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

  Yast.include include_target, "ca-management/crlDefault.rb"
  Yast.include include_target, "ca-management/certDefault.rb"

  @defaultSequence = {
    "ws_start"     => "new_default1",
    "new_default1" => {
      :next  => "new_default2",
      :again => "new_default1",
      :abort => :abort
    },
    "new_default2" => {
      :next  => "new_default3",
      :again => "new_default2",
      :abort => :abort,
      :back  => "new_default1"
    },
    "new_default3" => {
      :next  => :abort,
      :abort => :abort,
      :back  => "new_default2"
    }
  }

  # help text 1/2
  @CAHelptext = _("<p>Here, see the most important values of the CA.</p>")
  # help text 2/2
  @CAHelptext = Ops.add(
    @CAHelptext,
    _(
      "<p>Special information about the current CA is provided by <b>Certificates</b>, <b>CRL</b>, and <b>Advanced</b>.</p>"
    )
  )
end

- (Object) newSubCASequence

Creating new Client Certificate sequence

Returns:

  • sequence result



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File '../../src/include/ca-management/ca.rb', line 78

def newSubCASequence
  aliases = {
    "new_certinit"      => lambda { new_cert_init("Sub CA") },
    "new_certSaveDef"   => lambda { new_cert_save_default },
    "new_cert1"         => lambda { new_cert1("Sub CA") },
    "new_cert2"         => lambda { new_cert2("Sub CA") },
    "new_cert3"         => lambda { new_cert3("Sub CA") },
    "new_cert_advanced" => lambda { new_cert_advanced(false, "Sub CA") }
  }

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

  UI.CloseDialog

  ret
end

- (Object) showLongDescriptionCA(_CAname)

showLongDescriptionCA - description of a CA in textform

Parameters:

  • CA

    name



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

def showLongDescriptionCA(_CAname)
  ret = Convert.to_string(
    YaPI::CaManagement.ReadCA(
      {
        "caName"   => _CAname,
        "caPasswd" => getPassword(_CAname),
        "type"     => "plain"
      }
    )
  )
  Builtins.y2milestone("ReadCA(%1): %2", _CAname, ret)

  if ret == nil
    showErrorCaManagement
  else
    ret = Ops.add(Ops.add("<pre>", ret), "</pre>")
    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