Module: Yast::CaManagementCertificateInclude
- Defined in:
- ../../src/include/ca-management/certificate.rb
Instance Method Summary (collapse)
-
- (Object) getCertDescription(certMap)
getCertDescription - description of a certificate.
-
- (Object) getCertificateList(currentCA, password)
Creates certikficate items.
-
- (Yast::Term) getCertificateTab
Dialog Tab - certificate -.
-
- (Object) handleCertificateTab(event)
Handle events in a tab of a dialog.
-
- (Object) initCertificateTab
Initialize the tab of the dialog.
- - (Object) initialize_ca_management_certificate(include_target)
-
- (Object) newClientCertificateSequence
Creating new Client Certificate sequence.
-
- (Object) newServerCertificateSequence
Creating new Server Certificate sequence.
-
- (Object) revokeCertificate
Dialog for revoking a certificate.
-
- (Object) showLongCertDescription(_CAname, _Certname)
showLongCertDescription - description of a certificate in textform.
Instance Method Details
- (Object) getCertDescription(certMap)
getCertDescription - description of a certificate
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 |
# File '../../src/include/ca-management/certificate.rb', line 286 def getCertDescription(certMap) certMap = deep_copy(certMap) text = _("<p><b>Description</b></p>") if certMap == nil showErrorCaManagement return _("\nCertificate not found") end text = Ops.add(text, "<pre>") text = Ops.add( Ops.add(text, "Fingerprint: "), Ops.get_string(certMap, "FINGERPRINT", "") ) dn = Ops.get_map(certMap, "DN_HASH", {}) if Ops.greater_than(Builtins.size(dn), 0) text = Ops.add( Ops.add(text, "\nCommon Name: "), Ops.get_string(Ops.get_list(dn, "CN", []), 0, "") ) text = Ops.add( Ops.add(text, "\nOrganization: "), Ops.get_string(Ops.get_list(dn, "O", []), 0, "") ) text = Ops.add( Ops.add(text, "\nLocation: "), Ops.get_string(Ops.get_list(dn, "L", []), 0, "") ) text = Ops.add( Ops.add(text, "\nState: "), Ops.get_string(Ops.get_list(dn, "ST", []), 0, "") ) text = Ops.add( Ops.add(text, "\nCountry: "), Ops.get_string(Ops.get_list(dn, "C", []), 0, "") ) text = Ops.add( Ops.add(text, "\nEMAIL: "), Ops.get_string(Ops.get_list(dn, "emailAddress", []), 0, "") ) end text = Ops.add( Ops.add(text, "\nIs CA: "), Ops.get_string(certMap, "IS_CA", "") ) text = Ops.add( Ops.add(text, "\nKey Size: "), Ops.get_string(certMap, "KEYSIZE", "") ) text = Ops.add( Ops.add(text, "\nSerialnumber: "), Ops.get_string(certMap, "SERIAL", "") ) text = Ops.add( Ops.add(text, "\nVersion: "), Ops.get_string(certMap, "VERSION", "") ) text = Ops.add( Ops.add(text, "\nValid from: "), Ops.get_string(certMap, "NOTBEFORE", "") ) text = Ops.add( Ops.add(text, "\nValid to: "), Ops.get_string(certMap, "NOTAFTER", "") ) text = Ops.add( Ops.add(text, "\nalgo. of pub. Key : "), Ops.get_string(certMap, "PUBKEY_ALGORITHM", "") ) text = Ops.add( Ops.add(text, "\nalgo. of signature: "), Ops.get_string(certMap, "SIGNATURE_ALGORITHM", "") ) text = Ops.add(text, "</pre>") text end |
- (Object) getCertificateList(currentCA, password)
Creates certikficate items
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 |
# File '../../src/include/ca-management/certificate.rb', line 366 def getCertificateList(currentCA, password) result = [] i = 0 @certificateID = [] ret = Convert.convert( YaPI::CaManagement.ReadCertificateList( { "caName" => currentCA, "caPasswd" => password } ), :from => "list", :to => "list <map>" ) if ret == nil showErrorCaManagement CaMgm.passwdMap = Builtins.remove(CaMgm.passwdMap, currentCA) return nil end Builtins.y2milestone("ReadCertificateList(%1): %2", currentCA, ret) Builtins.foreach(ret) do |element| # Certificate status displayed in a table (Valid, Revoked, Expired) st = _("Valid") if Ops.get_string(element, "status", "") == "revoked" # Certificate status displayed in a table (Valid, Revoked, Expired) st = _("Revoked") end if Ops.get_string(element, "status", "") == "expired" # Certificate status displayed in a table (Valid, Revoked, Expired) st = _("Expired") end result = Builtins.add( result, Item( Id(i), st, 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", "") ) ) @certificateID = Builtins.add( @certificateID, Ops.get_string(element, "certificate", "") ) i = Ops.add(i, 1) end deep_copy(result) end |
- (Yast::Term) getCertificateTab
Dialog Tab - certificate -
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 |
# File '../../src/include/ca-management/certificate.rb', line 423 def getCertificateTab password = getPassword(CaMgm.currentCA) return nil if password == nil certTermList = getCertificateList(CaMgm.currentCA, password) return nil if certTermList == nil contents = VBox( VSpacing(1), HBox( HSpacing(1), Table( Id(:table), Opt(:notify, :immediate), Header( # To translators: table headers _("Status"), _("Common Name"), _("E-Mail Address"), _("Organization"), _("Organizational Unit"), _("Locality"), _("State"), _("Country") ), certTermList ), HSpacing(1) ), HBox(HSpacing(1), RichText(Id(:textinfo), ""), HSpacing(1)), HBox( HSpacing(1), MenuButton( _("Add"), [ Item(Id(:addServerCerti), _("Add Server Certificate")), Item(Id(:addClientCerti), _("Add Client Certificate")) ] ), PushButton(Id(:view), _("&View")), PushButton(Id(:certcpw), _("&Change Password")), PushButton(Id(:revoke), _("&Revoke")), PushButton(Id(:delete), _("&Delete")), HStretch(), MenuButton( Id(:export), _("Export"), [ Item(Id(:exportFile), _("Export to File")), Item(Id(:exportLDAP), _("Export to LDAP")), Item(Id(:exportCommon), _("Export as Common Server Certificate")) ] ), HSpacing(1) ), VSpacing(1) ) deep_copy(contents) end |
- (Object) handleCertificateTab(event)
Handle events in a tab of a dialog
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 |
# File '../../src/include/ca-management/certificate.rb', line 557 def handleCertificateTab(event) event = deep_copy(event) ui = Ops.get(event, "ID") initCertificateTab if ui == :table if ui == :view showLongCertDescription(CaMgm.currentCA, CaMgm.currentCertificate) end if ui == :certcpw changePassword(CaMgm.currentCA, CaMgm.currentCertificate) end if ui == :delete if Popup.ContinueCancelHeadline( _("Delete"), _("Delete current certificate?") ) ret = nil ret = YaPI::CaManagement.DeleteCertificate( { "caName" => CaMgm.currentCA, "certificate" => CaMgm.currentCertificate, "caPasswd" => getPassword(CaMgm.currentCA) } ) Builtins.y2milestone( "DeleteCertificate(%1) return %2", { "caName" => CaMgm.currentCA, "certificate" => CaMgm.currentCertificate }, ret ) showErrorCaManagement if ret == nil || ret == false ui = :again end end if ui == :revoke revokeCertificate ui = :again end if ui == :exportFile exportCertificateToFile(CaMgm.currentCA, CaMgm.currentCertificate) end if ui == :exportLDAP id = Convert.to_integer(UI.QueryWidget(Id(:table), :CurrentItem)) table_item = Convert.to_term( UI.QueryWidget(Id(:table), term(:Item, id)) ) exportToLDAP( "CERT", CaMgm.currentCA, Ops.get_string(table_item, 2, ""), #common name Ops.get_string(table_item, 3, ""), #EMAIL CaMgm.currentCertificate, @currentSubjectAltName ) end if ui == :exportCommon id = Convert.to_integer(UI.QueryWidget(Id(:table), :CurrentItem)) table_item = Convert.to_term( UI.QueryWidget(Id(:table), term(:Item, id)) ) exportCommonServerCertificate( CaMgm.currentCA, CaMgm.currentCertificate, Ops.get_string(table_item, 2, "") ) end if ui == :addServerCerti newServerCertificateSequence ui = :again end if ui == :addClientCerti newClientCertificateSequence ui = :again end Convert.to_symbol(ui) end |
- (Object) initCertificateTab
Initialize the tab of the dialog
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 |
# File '../../src/include/ca-management/certificate.rb', line 484 def initCertificateTab anyitems = UI.QueryWidget(Id(:table), :CurrentItem) != nil UI.ChangeWidget(Id(:delete), :Enabled, anyitems) UI.ChangeWidget(Id(:revoke), :Enabled, anyitems) UI.ChangeWidget(Id(:view), :Enabled, anyitems) UI.ChangeWidget(Id(:certcpw), :Enabled, anyitems) UI.ChangeWidget(Id(:export), :Enabled, anyitems) id = Convert.to_integer(UI.QueryWidget(Id(:table), :CurrentItem)) CaMgm.currentCertificate = Ops.get(@certificateID, id, "") if anyitems ret = Convert.to_map( YaPI::CaManagement.ReadCertificate( { "caName" => CaMgm.currentCA, "caPasswd" => getPassword(CaMgm.currentCA), "certificate" => CaMgm.currentCertificate, "type" => "parsed" } ) ) Builtins.y2milestone( "ReadCertificate(%1,%2): %3", CaMgm.currentCA, CaMgm.currentCertificate, ret ) UI.ChangeWidget(Id(:textinfo), :Value, getCertDescription(ret)) table_item = Convert.to_term( UI.QueryWidget(Id(:table), term(:Item, id)) ) valid = Ops.get_string(table_item, 1, "") == _("Valid") UI.ChangeWidget(Id(:delete), :Enabled, !valid) UI.ChangeWidget(Id(:revoke), :Enabled, valid) # do not export certificates which are a CA or revoked certificate UI.ChangeWidget( Id(:export), :Enabled, valid && Ops.get_string(ret, "IS_CA", "") != "1" ) opensslExtentions = Ops.get_map(ret, "OPENSSL_EXTENSIONS", {}) first = true @currentSubjectAltName = "" Builtins.foreach( Convert.convert( Ops.get(opensslExtentions, "X509v3 Subject Alternative Name", []), :from => "list", :to => "list <string>" ) ) do |entry| if first @currentSubjectAltName = entry first = false else @currentSubjectAltName = Ops.add( Ops.add(@currentSubjectAltName, ","), entry ) end end else @currentSubjectAltName = "" end nil end |
- (Object) initialize_ca_management_certificate(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 84 |
# File '../../src/include/ca-management/certificate.rb', line 34 def initialize_ca_management_certificate(include_target) textdomain "ca-management" Yast.import "CaMgm" Yast.import "Wizard" Yast.import "Label" Yast.import "Popup" Yast.import "YaPI::CaManagement" @certificateID = [] # help text 1/6 @certificateHelptext = _( "<p>First, see a list view with all available certificates from this CA. The columns are the DN of the certificates including the e-mail address and the state of the certificate (such as valid or revoked).</p>" ) # help text 2/6 @certificateHelptext = Ops.add( @certificateHelptext, _("<p>Select one of the certificates and execute some actions.</p>") ) # help text 3/6 @certificateHelptext = Ops.add( @certificateHelptext, _( "<p><b>View</b> opens a window with a text representation of the complete certificate.</p>" ) ) # help text 4/6 @certificateHelptext = Ops.add( @certificateHelptext, _( "<p>Furthermore, you can <b>Revoke</b>, <b>Delete</b>, or <b>Export</b> a certificate.</p>" ) ) # help text 5/6 @certificateHelptext = Ops.add( @certificateHelptext, _( "<p>With <b>Add</b>, generate a new server or client certificate.</p>" ) ) # help text 6/6 @certificateHelptext = Ops.add( @certificateHelptext, _( "<p>In the area below, see the most important values of the selected certificate.</p>" ) ) @currentSubjectAltName = "" end |
- (Object) newClientCertificateSequence
Creating new Client Certificate sequence
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File '../../src/include/ca-management/certificate.rb', line 111 def newClientCertificateSequence aliases = { "new_certinit" => lambda { new_cert_init("Client Certificate") }, "new_certSaveDef" => lambda { new_cert_save_default }, "new_cert1" => lambda { new_cert1("Client Certificate") }, "new_cert2" => lambda { new_cert2("Client Certificate") }, "new_cert3" => lambda { new_cert3("Client Certificate") }, "new_cert_advanced" => lambda do new_cert_advanced(false, "Client Certificate") end } Wizard.CreateDialog Wizard.SetDesktopTitleAndIcon("ca_mgm") ret = WizardSequencer(aliases, CaMgm.certificateSequence) UI.CloseDialog ret end |
- (Object) newServerCertificateSequence
Creating new Server Certificate sequence
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File '../../src/include/ca-management/certificate.rb', line 88 def newServerCertificateSequence aliases = { "new_certinit" => lambda { new_cert_init("Server Certificate") }, "new_certSaveDef" => lambda { new_cert_save_default }, "new_cert1" => lambda { new_cert1("Server Certificate") }, "new_cert2" => lambda { new_cert2("Server Certificate") }, "new_cert3" => lambda { new_cert3("Server Certificate") }, "new_cert_advanced" => lambda do new_cert_advanced(false, "Server Certificate") end } Wizard.CreateDialog Wizard.SetDesktopTitleAndIcon("ca_mgm") ret = WizardSequencer(aliases, CaMgm.certificateSequence) UI.CloseDialog ret end |
- (Object) revokeCertificate
Dialog for revoking a certificate
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 |
# File '../../src/include/ca-management/certificate.rb', line 134 def revokeCertificate UI.OpenDialog( Opt(:decorated), HBox( HSpacing(2), VBox( VSpacing(1), # popup window header Heading(_("Revoke Certificate")), VSpacing(1), Label( _( "You are only revoking the certificate. No new CRL will be created." ) ), Frame( _("Reasons"), RadioButtonGroup( Id(:rb), VBox( Left(RadioButton(Id("none"), "&no reason set", true)), Left(RadioButton(Id("unspecified"), "&unspecified")), Left(RadioButton(Id("keyCompromise"), "&keyCompromise")), Left(RadioButton(Id("CACompromise"), "CAC&ompromise")), Left( RadioButton(Id("affiliationChanged"), "&affiliationChanged") ), Left(RadioButton(Id("superseded"), "&superseded")), Left( RadioButton( Id("cessationOfOperation"), "&cessationOfOperation" ) ), Left(RadioButton(Id("certificateHold"), "c&ertificateHold")) ) ) ), VSpacing(1), HBox( PushButton(Id(:ok), Opt(:default, :key_F10), Label.OKButton), HStretch(), PushButton(Id(:cancel), Opt(:key_F9), Label.AbortButton) ), # push button label VSpacing(1) ), HSpacing(2) ) ) ui = nil begin ui = Convert.to_symbol(UI.UserInput) reason = Convert.to_string(UI.QueryWidget(Id(:rb), :CurrentButton)) if ui == :ok # Revoke certificate ret = nil if reason != "none" ret = YaPI::CaManagement.RevokeCertificate( { "caName" => CaMgm.currentCA, "caPasswd" => getPassword(CaMgm.currentCA), "certificate" => CaMgm.currentCertificate, "crlReason" => reason } ) else ret = YaPI::CaManagement.RevokeCertificate( { "caName" => CaMgm.currentCA, "caPasswd" => getPassword(CaMgm.currentCA), "certificate" => CaMgm.currentCertificate } ) end Builtins.y2milestone( "RevokeCertificate(%1) return %2", { "caName" => CaMgm.currentCA, "certificate" => CaMgm.currentCertificate, "crlReason" => reason }, ret ) if ret == nil || ret == false showErrorCaManagement ret = false end end end until Builtins.contains([:ok, :cancel], ui) UI.CloseDialog nil end |
- (Object) showLongCertDescription(_CAname, _Certname)
showLongCertDescription - description of a certificate in textform
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 |
# File '../../src/include/ca-management/certificate.rb', line 234 def showLongCertDescription(_CAname, _Certname) ret = Convert.to_string( YaPI::CaManagement.ReadCertificate( { "caName" => _CAname, "caPasswd" => getPassword(_CAname), "certificate" => _Certname, "type" => "plain" } ) ) Builtins.y2milestone( "ReadCertificate(%1,%2): %3", _CAname, _Certname, 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 |