Module: Yast::CaManagementCrlExportInclude
- Defined in:
- ../../src/include/ca-management/crlExport.rb
Instance Method Summary (collapse)
- - (Object) cleanLdapCred
-
- (Object) exportCRL(ca)
Editing CRL defaults of a selected CA.
- - (Object) initialize_ca_management_crlExport(include_target)
- - (Object) readSettings(ca)
- - (Object) setSettings
- - (Object) showSecurityInfo
- - (Object) updateEnabled
- - (Object) writeSettings(ca)
Instance Method Details
- (Object) cleanLdapCred
174 175 176 177 178 179 180 181 |
# File '../../src/include/ca-management/crlExport.rb', line 174 def cleanLdapCred # cleanup ldap credetials hash ... remove nil values Builtins.foreach(@ldapCred) do |key, val| Ops.set(@ldapCred, key, "") if val == nil end nil end |
- (Object) exportCRL(ca)
Editing CRL defaults of a selected CA
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 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 |
# File '../../src/include/ca-management/crlExport.rb', line 362 def exportCRL(ca) ret = YaPI::CaManagement.ReadCRLDefaults( { "caName" => ca, "caPasswd" => getPassword(ca) } ) Builtins.y2milestone( "ReadCRLDefaults(%1) return %2", { "caName" => ca }, ret ) caption = _("Export CRL") # this default can only be set inside this function @crlfile = Builtins.sformat( "/var/lib/CAM/%1/crl/crl.pem", Builtins.deletechars(ca, " ") ) help_para1 = Builtins.sformat("<p><b>%1</b></p>", caption) help_para2 = _( "<p>Export the CRL of this CA once by selecting <b>Export once</b>.</p>" ) help_para3 = _( "<p>To set up a repeated recreation of the CRL, select <b>Repeated recreation and export</b>. In this case, set the interval for the recreation in <b>Periodic interval</b>. If you set the interval to 24 hours, you can additionally select the hour for the export. Make sure you read and understand the <b>Security Information</b>.</p>" ) help_para4 = _( "<p>You can activate an export of the CRL to a local file or to an LDAP server or both. Set up the respective parameters in <b>Export to local file</b> and <b>Export to LDAP</b>.</p>" ) helptext = Ops.add( Ops.add(Ops.add(help_para1, help_para2), help_para3), help_para4 ) = VBox( RadioButtonGroup( Id(:export_mode), VBox( Left( RadioButton(Id(:mode_once), Opt(:notify), _("Export once"), true) ), Left( RadioButton( Id(:mode_periodically), Opt(:notify), _("Repeated recreation and export") ) ) ) ) ) # fix space issue (bnc#446137) cldapsettings = HBox( Id(:ldapSettings), Top( VBox( TextEntry(Id(:hostname), _("&Host Name:"), ""), TextEntry(Id(:port), _("&Port:"), ""), TextEntry(Id(:dn), _("&DN:")) ) ), Top( VBox( TextEntry(Id(:binddn), _("&Bind DN:"), ""), Password(Id(:ldapPassword), Opt(:hstretch), _("Pass&word")) ) ) ) cfilesettings = VBox( Id(:fileSettings), HBox( TextEntry(Id(:crlfile), _("Save &as"), @crlfile), VBox(VSpacing(1), PushButton(Id(:askFile), Label.BrowseButton)) ), Left( RadioButtonGroup( Id(:fileformat), HBox( Label(_("Export Format")), RadioButton(Id(:ffpem), Opt(:notify), _("PEM Format"), true), RadioButton(Id(:ffder), Opt(:notify), _("DER Format")) ) ) ) ) cinterval = Left( Id(:periodicInterval), HBox( VBox(Label(_("Periodic interval")), VSpacing(1)), HSpacing(3), #`HSquash( `IntField( `id(`interval_days), "&days", 0, 100, 30 )), # Translators: this is used to express a setting of "every XX hour(s)" Label(_("every")), # Translators: this is used to express a setting of "every XX hour(s)" HSquash( IntField( Id(:interval_hours), Opt(:notify), _("&hour(s)"), 1, 24, 12 ) ), # (bnc#446137) # Translators: in case "every XX hour(s)" is set to 24, the user can set "at XX o'clock" HBox( Id(:atHourSetting), Label(_("at")), # Translators: in case "every XX hour(s)" is set to 24, the user can set "at XX o'clock" HSquash(IntField(Id(:interval_athour), _("&o'clock"), 0, 23, 3)) ), # (bnc#446137) HSpacing(3), VBox( VSpacing(1), PushButton(Id(:securityInfo), _("&Security Information")) ) ) ) contents = HBox( HSpacing(1), VBox( Left(Heading(Ops.add(_("CA Name: "), CaMgm.currentCA))), , HBox( HSpacing(3), VBox( VSpacing(@vspace), Left( CheckBox( Id(:exportFile), Opt(:notify), _("Export to file"), true ) ), HBox(HSpacing(@hspace), cfilesettings), VSpacing(@vspace), Left( CheckBox( Id(:exportLDAP), Opt(:notify), _("Export to LDAP"), false ) ), HBox(HSpacing(@hspace), cldapsettings), VSpacing(@vspace), cinterval ) ) ), HSpacing(1) ) Wizard.CreateDialog Wizard.SetContentsButtons( _("Export CRL"), contents, helptext, Label.BackButton, Label.OKButton ) Wizard.DisableBackButton # fill UI with settings readSettings(ca) # read conf file if exists setSettings # push data to UI updateEnabled # gray out or ungray UI elements ui = nil begin ui = Convert.to_symbol(UI.UserInput) add_advanced_issuer_alt_name = "test" if ui == :add if ui == :askFile fformat = "*.pem" fformat = "*.der" if @fileformat == :ffder newcrlfile = UI.AskForSaveFileName(@crlfile, fformat, _("Save as")) @crlfile = newcrlfile if newcrlfile != nil && newcrlfile != "" end if Builtins.contains( [:mode_once, :mode_periodically, :exportFile, :exportLDAP], ui ) updateEnabled end if ui == :ffpem || ui == :ffder @fileformat = Convert.to_symbol( UI.QueryWidget(Id(:fileformat), :Value) ) formatstr = "" outputstr = "" if @fileformat == :ffpem formatstr = "^(.*.)der$" outputstr = "\\1pem" elsif @fileformat == :ffder formatstr = "^(.*.)pem$" outputstr = "\\1der" end newfile = Builtins.regexpsub(@crlfile, formatstr, outputstr) @crlfile = newfile if newfile != nil && newfile != "" end if ui == :interval_hours || ui == :interval_athour @intervalHours = Convert.to_integer( UI.QueryWidget(Id(:interval_hours), :Value) ) @intervalAtHour = Convert.to_integer( UI.QueryWidget(Id(:interval_athour), :Value) ) end showSecurityInfo if ui == :securityInfo if ui == :next updateEnabled @fileformat = Convert.to_symbol( UI.QueryWidget(Id(:fileformat), :Value) ) @crlfile = Convert.to_string(UI.QueryWidget(Id(:crlfile), :Value)) @intervalAtHour = Convert.to_integer( UI.QueryWidget(Id(:interval_athour), :Value) ) @intervalHours = Convert.to_integer( UI.QueryWidget(Id(:interval_hours), :Value) ) Ops.set( @ldapCred, "hostname", Convert.to_string(UI.QueryWidget(Id(:hostname), :Value)) ) Ops.set( @ldapCred, "port", Convert.to_string(UI.QueryWidget(Id(:port), :Value)) ) Ops.set( @ldapCred, "dn", Convert.to_string(UI.QueryWidget(Id(:dn), :Value)) ) Ops.set( @ldapCred, "binddn", Convert.to_string(UI.QueryWidget(Id(:binddn), :Value)) ) Ops.set( @ldapCred, "password", Convert.to_string(UI.QueryWidget(Id(:ldapPassword), :Value)) ) cleanLdapCred writeSettings(ca) cronConfFile = Builtins.sformat( "/etc/cron.d/suse.de-yast2-ca-mgm-exportcrl-%1", ca ) if !@periodic if @file_active exportFormat = "PEM" exportFormat = "DER" if @fileformat == :ffder strret = Convert.to_string( YaPI::CaManagement.ExportCRL( { "caName" => ca, "caPasswd" => getPassword(ca), "exportFormat" => exportFormat, "destinationFile" => @crlfile } ) ) Builtins.y2milestone( "ExportCRL(%1) returned %2", { "caName" => ca, "exportFormat" => exportFormat, "destinationFile" => @crlfile }, ret ) if strret == nil || strret != "1" if Popup.YesNoHeadline( _("Export to file failed."), _("Do you want to retry?") ) ui = :retry end else Popup.Message(_("Saved to file successfully.")) end end if @ldap_active boolret = YaPI::CaManagement.ExportCRLToLDAP( { "caName" => ca, "ldapHostname" => Ops.get(@ldapCred, "hostname", ""), "ldapPort" => Ops.get(@ldapCred, "port", ""), "destinationDN" => Ops.get(@ldapCred, "dn", ""), "BindDN" => Ops.get(@ldapCred, "binddn", ""), "ldapPasswd" => Ops.get(@ldapCred, "ldap_password", "") } ) if boolret Popup.Message(_("Saved to LDAP successfully.")) else if Popup.YesNoHeadline( _("Export to LDAP failed."), _("Do you want to retry?") ) ui = :retry end end end # Remove the cronjob if the setting was reset SCR.Execute(path(".target.remove"), cronConfFile) else configString = Builtins.sformat( "## Configuration of a cron job to export the CRL of the CA: %1", ca ) configString = Ops.add(configString, "\n##") configString = Ops.add( configString, "\n## Created by yast2-ca-management" ) configString = Ops.add( configString, "\n## Changes to this file will be overwritten by yast2-ca-management" ) configString = Ops.add( configString, Builtins.sformat( "\n## Either use yast or change settings here AND in /var/lib/CAM/%1/exportcrl.conf", Builtins.deletechars(ca, " ") ) ) configString = Ops.add(configString, "\n\n\n") hourset = @intervalHours == 24 ? Builtins.sformat("%1", @intervalAtHour) : Builtins.sformat("*/%1", @intervalHours) configString = Ops.add( configString, Builtins.sformat( "* %1 * * * root /usr/bin/exportCRL.pl -c /var/lib/CAM/%2/exportcrl.conf", hourset, Builtins.deletechars(ca, " ") ) ) if SCR.Write(path(".target.string"), cronConfFile, configString) Builtins.y2milestone( "Setup cron job for periodic recreation and export of CRLs of CA %1", ca ) else Builtins.y2error( "Failed to set up a cron job for periodic recreation and export of CRLs of CA %1", ca ) end end end setSettings end until Builtins.contains([:next, :abort], ui) UI.CloseDialog nil end |
- (Object) initialize_ca_management_crlExport(include_target)
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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File '../../src/include/ca-management/crlExport.rb', line 44 def initialize_ca_management_crlExport(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.import "String" Yast.include include_target, "ca-management/util.rb" Yast.include include_target, "ca-management/new_cert_callbacks.rb" @uiInfo = UI.GetDisplayInfo @textmode = Ops.get_boolean(@uiInfo, "TextMode") @hspace = Convert.convert( @textmode ? 4 : 3, :from => "integer", :to => "float" ) @vspace = Convert.convert( @textmode ? 0 : 0.5, :from => "integer", :to => "float" ) # less spacing (bnc#446137) @seenSecurityInfo = false # here are our settings for the CRL of this CA @periodic = false # default off @file_active = true # default on @ldap_active = false # default off @fileformat = :ffpem # default is pem @crlfile = "" # is set from inside the export function @intervalAtHour = 0 @intervalHours = 0 @ldapCred = { "hostname" => "", "port" => "", "dn" => "", "binddn" => "", "password" => "" } @crlConfFormat = { "options" => [ "line_can_continue", "global_values", "join_multiline", "comments_last", "flat" ], "comments" => ["^[ \t]*#.*$", "^[ \t]*$"], "params" => [ { "match" => ["([a-zA-Z0-9_-]+)[ \t]*=[ \t]*([^ \t]*)", "%s = %s"] } ] } end |
- (Object) readSettings(ca)
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 |
# File '../../src/include/ca-management/crlExport.rb', line 184 def readSettings(ca) crlConf = Builtins.sformat( "/var/lib/CAM/%1/exportcrl.conf", Builtins.deletechars(ca, " ") ) if SCR.Execute( path(".target.bash"), Builtins.sformat("[ -f %1 ]", String.Quote(crlConf)) ) == 0 SCR.RegisterAgent( path(".temp_crlexport_agent"), term(:ag_ini, term(:IniAgent, crlConf, @crlConfFormat)) ) @periodic = SCR.Read(path(".temp_crlexport_agent.periodic")) == "true" ? true : false @seenSecurityInfo = true if @periodic getAtHour = Builtins.tointeger( Convert.to_string( SCR.Read(path(".temp_crlexport_agent.interval_athour")) ) ) @intervalAtHour = getAtHour != nil ? getAtHour : @intervalAtHour getHours = Builtins.tointeger( Convert.to_string( SCR.Read(path(".temp_crlexport_agent.interval_hours")) ) ) @intervalHours = getHours != nil ? getHours : @intervalHours @intervalAtHour = 0 if @intervalHours != 24 @file_active = SCR.Read(path(".temp_crlexport_agent.export_file")) == "true" ? true : false @ldap_active = SCR.Read(path(".temp_crlexport_agent.export_ldap")) == "true" ? true : false getCrlfile = Convert.to_string( SCR.Read(path(".temp_crlexport_agent.crlfilename")) ) @crlfile = getCrlfile if getCrlfile != nil && getCrlfile != "" @fileformat = SCR.Read(path(".temp_crlexport_agent.crlfileformat")) == "der" ? :ffder : :ffpem Ops.set( @ldapCred, "hostname", Convert.to_string( SCR.Read(path(".temp_crlexport_agent.ldap_hostname")) ) ) Ops.set( @ldapCred, "port", Convert.to_string(SCR.Read(path(".temp_crlexport_agent.ldap_port"))) ) Ops.set( @ldapCred, "dn", Convert.to_string(SCR.Read(path(".temp_crlexport_agent.ldap_dn"))) ) Ops.set( @ldapCred, "binddn", Convert.to_string(SCR.Read(path(".temp_crlexport_agent.ldap_binddn"))) ) Ops.set( @ldapCred, "password", Convert.to_string( SCR.Read(path(".temp_crlexport_agent.ldap_password")) ) ) @ldapCred = {} if !@ldap_active cleanLdapCred SCR.UnregisterAgent(path(".temp_crlexport_agent")) Builtins.y2milestone( "Found config file for automatic CRL export of CA %1 and read settings.", ca ) else Builtins.y2milestone( "No config file found for automatic CRL export of CA %1", ca ) end nil end |
- (Object) setSettings
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 |
# File '../../src/include/ca-management/crlExport.rb', line 140 def setSettings # write settings to the UI UI.ChangeWidget(Id(:mode_periodically), :Value, @periodic) UI.ChangeWidget(Id(:periodicInterval), :Enabled, @periodic) UI.ChangeWidget(Id(:interval_athour), :Value, @intervalAtHour) UI.ChangeWidget(Id(:interval_hours), :Value, @intervalHours) UI.ChangeWidget( Id(:atHourSetting), :Enabled, @intervalHours == 24 ? true : false ) UI.ChangeWidget(Id(:exportFile), :Value, @file_active) UI.ChangeWidget(Id(:exportLDAP), :Value, @ldap_active) UI.ChangeWidget(Id(:ffpem), :Value, @fileformat == :ffpem ? true : false) UI.ChangeWidget(Id(:ffder), :Value, @fileformat == :ffder ? true : false) UI.ChangeWidget(Id(:crlfile), :Value, @crlfile) UI.ChangeWidget(Id(:hostname), :Value, Ops.get(@ldapCred, "hostname", "")) UI.ChangeWidget(Id(:port), :Value, Ops.get(@ldapCred, "port", "")) UI.ChangeWidget(Id(:dn), :Value, Ops.get(@ldapCred, "dn", "")) UI.ChangeWidget(Id(:binddn), :Value, Ops.get(@ldapCred, "binddn", "")) UI.ChangeWidget( Id(:ldapPassword), :Value, Ops.get(@ldapCred, "password", "") ) nil end |
- (Object) showSecurityInfo
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File '../../src/include/ca-management/crlExport.rb', line 105 def showSecurityInfo Popup.LongText( # Translators: window caption _("Security Information"), # Translators: long help text - security information RichText( _( "Warning!<br>Activating the automatic creation and export of a CRL will write the CA password to a configuration file on disk. The password will be stored there in plain text as it is needed to create a CRL. The file will only be readable for the root user." ) ), 50, 12 ) @seenSecurityInfo = true nil end |
- (Object) updateEnabled
124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File '../../src/include/ca-management/crlExport.rb', line 124 def updateEnabled @periodic = Convert.to_boolean( UI.QueryWidget(Id(:mode_periodically), :Value) ) @file_active = Convert.to_boolean(UI.QueryWidget(Id(:exportFile), :Value)) @ldap_active = Convert.to_boolean(UI.QueryWidget(Id(:exportLDAP), :Value)) UI.ChangeWidget(Id(:periodicInterval), :Enabled, @periodic) UI.ChangeWidget(Id(:fileSettings), :Enabled, @file_active) UI.ChangeWidget(Id(:ldapSettings), :Enabled, @ldap_active) showSecurityInfo if @periodic && !@seenSecurityInfo nil end |
- (Object) writeSettings(ca)
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 |
# File '../../src/include/ca-management/crlExport.rb', line 270 def writeSettings(ca) crlConf = Builtins.sformat( "/var/lib/CAM/%1/exportcrl.conf", Builtins.deletechars(ca, " ") ) if !(SCR.Execute( path(".target.bash"), Builtins.sformat("[ -f %1 ]", String.Quote(crlConf)) ) == 0) SCR.Execute( path(".target.bash"), Builtins.sformat("umask 0077 && touch %1", String.Quote(crlConf)) ) end SCR.RegisterAgent( path(".temp_crlexport_agent"), term(:ag_ini, term(:IniAgent, crlConf, @crlConfFormat)) ) SCR.Write(path(".temp_crlexport_agent.caname"), ca) SCR.Write( path(".temp_crlexport_agent.periodic"), @periodic ? "true" : "false" ) SCR.Write( path(".temp_crlexport_agent.capassword"), @periodic ? getPassword(ca) : "" ) SCR.Write( path(".temp_crlexport_agent.interval_athour"), @intervalHours == 24 ? "0" : Builtins.sformat("%1", @intervalAtHour) ) SCR.Write( path(".temp_crlexport_agent.interval_hours"), Builtins.sformat("%1", @intervalHours) ) SCR.Write( path(".temp_crlexport_agent.export_file"), @file_active == true ? "true" : "false" ) SCR.Write( path(".temp_crlexport_agent.export_ldap"), @ldap_active == true ? "true" : "false" ) SCR.Write( path(".temp_crlexport_agent.crlfilename"), @file_active ? @crlfile : "" ) SCR.Write( path(".temp_crlexport_agent.crlfileformat"), @fileformat == :ffder ? "der" : "pem" ) @ldapCred = {} if !@ldap_active SCR.Write( path(".temp_crlexport_agent.ldap_hostname"), Ops.get(@ldapCred, "hostname", "") ) SCR.Write( path(".temp_crlexport_agent.ldap_port"), Ops.get(@ldapCred, "port", "") ) SCR.Write( path(".temp_crlexport_agent.ldap_dn"), Ops.get(@ldapCred, "dn", "") ) SCR.Write( path(".temp_crlexport_agent.ldap_binddn"), Ops.get(@ldapCred, "binddn", "") ) SCR.Write( path(".temp_crlexport_agent.ldap_password"), Ops.get(@ldapCred, "password", "") ) SCR.UnregisterAgent(path(".temp_crlexport_agent")) Builtins.y2milestone( "Written settings for automatic CRL export to conf file %1", crlConf ) nil end |