Class: Watobo::Gui::ClientCertDialog

Inherits:
FXDialogBox
  • Object
show all
Includes:
Responder
Defined in:
lib/watobo/gui/client_cert_dialog.rb

Constant Summary collapse

NO_SELECTION =
"no site selected"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner, prefs = {}) ⇒ ClientCertDialog

Returns a new instance of ClientCertDialog.


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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/watobo/gui/client_cert_dialog.rb', line 37

def initialize(owner, prefs={})

  super(owner, "Client Certificates", :opts => DECOR_ALL)     
  FXMAPFUNC(SEL_COMMAND, ID_ACCEPT, :onAccept)

  @password_policy = {
    :save_passwords => false
  }

  @cert_path = nil
  @client_certificates = {}
  
  current_certs = Watobo.project.getClientCertificates
  @client_certificates = current_certs unless current_certs.nil?

  @password_policy.update prefs[:password_policy] if prefs.has_key? :password_policy

  @site_dt = FXDataTarget.new('')
  @client_cert_dt = FXDataTarget.new('')
  @client_key_dt = FXDataTarget.new('')
  @password_dt = FXDataTarget.new('')
  @retype_dt = FXDataTarget.new('')

  main_frame = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_GROOVE)

  frame = FXHorizontalFrame.new(main_frame, :opts => LAYOUT_FILL_X)

  @scope_only_cb = FXCheckButton.new(frame, "scope only", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
  @scope_only_cb.setCheck(false)

  @scope_only_cb.connect(SEL_COMMAND) { updateSitesCombo() }

  @sites_combo = FXComboBox.new(frame, 5,  @site_dt, FXDataTarget::ID_VALUE,
  COMBOBOX_STATIC|FRAME_SUNKEN|FRAME_THICK|LAYOUT_SIDE_TOP|LAYOUT_FILL_X)

  @sites_combo.numVisible = @sites_combo.numItems >= 20 ? 20 : @sites_combo.numItems
  @sites_combo.numColumns = 25
  @sites_combo.editable = true
  updateSitesCombo()

  @sites_combo.connect(SEL_COMMAND, method(:update_fields))
  matrix = FXMatrix.new(main_frame, 3, :opts => MATRIX_BY_COLUMNS|LAYOUT_FILL_X|LAYOUT_FILL_Y)

  FXLabel.new(matrix, "Certificate File:", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
  @client_cert_txt = FXTextField.new(matrix,  25,
  :target => @client_cert_dt, :selector => FXDataTarget::ID_VALUE,
  :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT)

  FXButton.new(matrix, "Select").connect(SEL_COMMAND){ select_cert_file }

  FXLabel.new(matrix, "Key File:", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
  @client_key_txt = FXTextField.new(matrix, 25,
  :target => @client_key_dt, :selector => FXDataTarget::ID_VALUE,
  :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT)
  FXButton.new(matrix, "Select").connect(SEL_COMMAND){ select_key_file }

#  matrix = FXMatrix.new(main_frame, 2, :opts => MATRIX_BY_COLUMNS|LAYOUT_FILL_X|LAYOUT_FILL_Y)
  FXLabel.new(matrix, "Password:", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
  @password_txt = FXTextField.new(matrix, 25,
  :target => @password_dt, :selector => FXDataTarget::ID_VALUE,
  :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT|TEXTFIELD_PASSWD)
  
   FXButton.new(matrix, "", :opts=>FRAME_NONE).disable

  FXLabel.new(matrix, "Retype:", nil, LAYOUT_TOP|JUSTIFY_RIGHT)
  @retype_txt = FXTextField.new(matrix, 25,
  :target => @retype_dt, :selector => FXDataTarget::ID_VALUE,
  :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_RIGHT|TEXTFIELD_PASSWD)
  
  FXButton.new(matrix, "", :opts=>FRAME_NONE).disable

# @save_pws_cbt = FXCheckButton.new(matrix, "save passwords")
#  @save_pws_cbt.checkState = false
#  @save_pws_cbt.checkState = true if @password_policy[:save_passwords] == true
#  note_label = FXLabel.new(matrix, "This setting affects all passwords!!!")

  buttons = FXHorizontalFrame.new(main_frame, :opts => LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH,
  :padLeft => 40, :padRight => 40, :padTop => 20, :padBottom => 20)

  accept = FXButton.new(buttons, "&Accept", nil, self, ID_ACCEPT,
  FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
  accept.enable
  # Cancel
  FXButton.new(buttons, "&Cancel", nil, self, ID_CANCEL,
  FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
end

Instance Attribute Details

#client_certificatesObject (readonly)

Returns the value of attribute client_certificates


29
30
31
# File 'lib/watobo/gui/client_cert_dialog.rb', line 29

def client_certificates
  @client_certificates
end

Instance Method Details

#savePasswords?Boolean

Returns:

  • (Boolean)

30
31
32
33
# File 'lib/watobo/gui/client_cert_dialog.rb', line 30

def savePasswords?()
  return false
  #@save_pws_cbt.checked?
end