Module: Yast::CaManagementStartupInclude

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) deleteCurrentCA

Deleting current CA



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

def deleteCurrentCA
  Builtins.y2milestone("deleting CA: %1", CaMgm.currentCA)

  message = Builtins.sformat(_("Really delete CA %1?"), CaMgm.currentCA)

  if Popup.YesNoHeadline(_("Delete"), message) &&
      getPassword(CaMgm.currentCA) != nil
    if YaPI::CaManagement.DeleteCA(
        {
          "caName"   => CaMgm.currentCA,
          "caPasswd" => getPassword(CaMgm.currentCA)
        }
      ) == nil
      messageMap = YaPI.Error
      if Ops.get_string(messageMap, "code", "") == "CA_STILL_IN_USE"
        if Popup.YesNoHeadline(
            _("Force Delete"),
            _("This CA is still in use. Delete it?")
          )
          if YaPI::CaManagement.DeleteCA(
              {
                "caName"   => CaMgm.currentCA,
                "caPasswd" => getPassword(CaMgm.currentCA),
                "force"    => "1"
              }
            ) == nil
            showErrorCaManagement
          end
        end
      else
        showErrorCaManagement
      end
    end
  end

  nil
end

- (Object) getCAList(subCA)

Creates CA items

Parameters:

  • subCA (String)
    • name ob the sub CA or empty if root

Returns:

  • a list of CA items of the sub CA, formated for a UI tree



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

def getCAList(subCA)
  result = []

  if Ops.less_or_equal(Builtins.size(subCA), 0)
    @CAList = YaPI::CaManagement.ReadCATree
    Builtins.y2milestone("Output of ReadCATree: %1", @CAList)
    if @CAList == nil
      showErrorCaManagement
      return deep_copy(result)
    end
  end
  Builtins.foreach(@CAList) do |elementList|
    if Ops.get_string(elementList, 1, "") == subCA
      subCA2 = getCAList(Ops.get_string(elementList, 0, ""))
      if Ops.greater_than(Builtins.size(subCA2), 0)
        result = Builtins.add(
          result,
          Item(
            Id(Ops.get_string(elementList, 0, "")),
            Ops.get_string(elementList, 0, ""),
            true,
            subCA2
          )
        )
      else
        result = Builtins.add(
          result,
          Item(
            Id(Ops.get_string(elementList, 0, "")),
            Ops.get_string(elementList, 0, "")
          )
        )
      end
    end
  end

  deep_copy(result)
end

- (Object) initialize_ca_management_startup(include_target)



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File '../../src/include/ca-management/startup.rb', line 43

def initialize_ca_management_startup(include_target)
  Yast.import "UI"

  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"

  @CAList = [] # CA list tree
end

- (Object) Startup

startup dialog

Returns:

  • finish,enter, 'createRoot



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

def Startup
  # help text 1/3
  helptext = _("<p>Select one CA and press <b>Enter CA</b>.</p>")
  # help text 2/3
  helptext = Ops.add(
    helptext,
    _(
      "<p><b>Create Root CA</b> generates a new root certificate authority.</p>"
    )
  )
  # help text 3/3
  helptext = Ops.add(
    helptext,
    _(
      "<p>For more information about CA Management, please read the manual.</p>"
    )
  )

  termList = getCAList("")

  buttons = VBox()
  # To translators: pushbutton label
  buttons = Builtins.add(
    buttons,
    HBox(HWeight(1, PushButton(Id(:enter), Opt(:key_F4), _("&Enter CA"))))
  )
  buttons = Builtins.add(
    buttons,
    HBox(HWeight(1, PushButton(Id(:delete), Opt(:key_F5), _("&Delete CA"))))
  )
  buttons = Builtins.add(buttons, VStretch())
  # To translators: pushbutton label
  buttons = Builtins.add(
    buttons,
    HBox(
      HWeight(
        1,
        PushButton(Id(:createRoot), Opt(:key_F3), _("&Create Root CA"))
      )
    )
  )
  # To translators: pushbutton label
  buttons = Builtins.add(
    buttons,
    HBox(HWeight(1, PushButton(Id(:import), _("&Import CA"))))
  )

  contents = HBox()
  contents = Builtins.add(
    contents,
    HWeight(
      9,
      Tree(
        Id(:tree),
        Opt(:notify, :vstretch),
        # To translators: tree headers
        _("CA Tree"),
        termList
      )
    )
  )
  contents = Builtins.add(contents, HWeight(4, buttons))


  # To translators: dialog label
  Wizard.SetContents(_("CA Selection"), contents, helptext, false, true)
  Wizard.SetNextButton(:next, Label.FinishButton)
  UI.ChangeWidget(Id(:abort), :Enabled, false)

  firstEntry = Ops.get(@CAList, 0) { ["", ""] }
  CaMgm.currentCA = Ops.get(firstEntry, 0, "")

  UI.ChangeWidget(Id(:tree), :CurrentItem, CaMgm.currentCA)

  ui = nil
  begin
    anyitems = UI.QueryWidget(Id(:tree), :CurrentItem) != nil
    UI.ChangeWidget(Id(:enter), :Enabled, anyitems)
    UI.ChangeWidget(Id(:delete), :Enabled, anyitems)

    ui = Convert.to_symbol(UI.UserInput)
    if Builtins.contains([:enter, :delete], ui) && anyitems
      CaMgm.currentCA = Convert.to_string(
        UI.QueryWidget(Id(:tree), :CurrentItem)
      )
      if ui == :enter
        # checking password
        ui = :again if getPassword(CaMgm.currentCA) == nil
      end
      deleteCurrentCA if ui == :delete
    end
    importCAFromDisk if ui == :import
  end until Builtins.contains(
    [:createRoot, :enter, :next, :import, :delete, :cancel],
    ui
  )

  ui
end