Example #1
0
 private void loadStates() {
   boolean b = enableDefaultEncryption.isSelected();
   cboSavpOption.setEnabled(b);
   this.encryptionProtocolPreferences.setEnabled(b);
   enableSipZrtpAttribute.setEnabled(
       b && this.encryptionConfigurationTableModel.isEnabledLabel("ZRTP"));
   tabCiphers.setEnabled(b && this.encryptionConfigurationTableModel.isEnabledLabel("SDES"));
 }
Example #2
0
  /**
   * Saves the user input when the "Next" wizard buttons is clicked.
   *
   * @param registration the SIPAccountRegistration
   * @return
   */
  public boolean commitPanel(SecurityAccountRegistration registration) {
    registration.setDefaultEncryption(enableDefaultEncryption.isSelected());
    registration.setEncryptionProtocols(encryptionConfigurationTableModel.getEncryptionProtocols());
    registration.setEncryptionProtocolStatus(
        encryptionConfigurationTableModel.getEncryptionProtocolStatus());
    registration.setSipZrtpAttribute(enableSipZrtpAttribute.isSelected());
    registration.setSavpOption(((SavpOption) cboSavpOption.getSelectedItem()).option);
    registration.setSDesCipherSuites(cipherModel.getEnabledCiphers());

    return true;
  }
Example #3
0
  /**
   * Loads the account with the given identifier.
   *
   * @param accountID the account identifier
   */
  public void loadAccount(AccountID accountID) {
    enableDefaultEncryption.setSelected(
        accountID.getAccountPropertyBoolean(ProtocolProviderFactory.DEFAULT_ENCRYPTION, true));

    Map<String, Integer> encryptionProtocols =
        accountID.getIntegerPropertiesByPrefix(ProtocolProviderFactory.ENCRYPTION_PROTOCOL, true);
    Map<String, Boolean> encryptionProtocolStatus =
        accountID.getBooleanPropertiesByPrefix(
            ProtocolProviderFactory.ENCRYPTION_PROTOCOL_STATUS, true, false);
    this.loadEncryptionProtocols(encryptionProtocols, encryptionProtocolStatus);

    enableSipZrtpAttribute.setSelected(
        accountID.getAccountPropertyBoolean(
            ProtocolProviderFactory.DEFAULT_SIPZRTP_ATTRIBUTE, true));
    cboSavpOption.setSelectedIndex(
        accountID.getAccountPropertyInt(
            ProtocolProviderFactory.SAVP_OPTION, ProtocolProviderFactory.SAVP_OFF));
    cipherModel.loadData(
        accountID.getAccountPropertyString(ProtocolProviderFactory.SDES_CIPHER_SUITES));
    loadStates();
  }
  /** Loads the configuration form obtained from the chat room. */
  protected void loadConfigurationForm() {
    Iterator<ChatRoomConfigurationFormField> configurationSet = configForm.getConfigurationSet();

    while (configurationSet.hasNext()) {
      ChatRoomConfigurationFormField formField = configurationSet.next();

      Iterator<?> values = formField.getValues();
      Iterator<String> options = formField.getOptions();

      JComponent field;
      JLabel label = new JLabel("", JLabel.RIGHT);

      if (formField.getLabel() != null) label.setText(formField.getLabel() + ": ");

      String fieldType = formField.getType();

      if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_BOOLEAN)) {
        // Create a check box when the field is of type boolean.
        field = new SIPCommCheckBox(formField.getLabel());
        label.setText("");

        if (values.hasNext()) {
          ((JCheckBox) field).setSelected((Boolean) values.next());
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) {
        field = new JLabel();

        if (values.hasNext()) {
          String value = values.next().toString();

          ((JLabel) field).setText(value);
          field.setFont(new Font(null, Font.ITALIC, 10));
          field.setForeground(Color.GRAY);
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_LIST_MULTI)) {
        field = new TransparentPanel(new GridLayout(0, 1));

        field.setBorder(BorderFactory.createLineBorder(Color.GRAY));

        Hashtable<Object, JCheckBox> optionCheckBoxes = new Hashtable<Object, JCheckBox>();

        while (options.hasNext()) {
          Object option = options.next();
          JCheckBox checkBox = new SIPCommCheckBox(option.toString());

          field.add(checkBox);
          optionCheckBoxes.put(option, checkBox);
        }

        while (values.hasNext()) {
          Object value = values.next();

          (optionCheckBoxes.get(value)).setSelected(true);
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_LIST_SINGLE)) {
        field = new JComboBox();

        while (options.hasNext()) {
          ((JComboBox) field).addItem(options.next());
        }

        if (values.hasNext()) {
          ((JComboBox) field).setSelectedItem(values.next());
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_MULTI)) {
        field = new JEditorPane();

        if (values.hasNext()) {
          String value = values.next().toString();

          ((JEditorPane) field).setText(value);
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_SINGLE)
          || fieldType.equals(ChatRoomConfigurationFormField.TYPE_ID_SINGLE)) {
        field = new JTextField();

        if (values.hasNext()) {
          String value = values.next().toString();

          ((JTextField) field).setText(value);
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_PRIVATE)) {
        field = new JPasswordField();

        if (values.hasNext()) {
          String value = values.next().toString();

          ((JPasswordField) field).setText(value);
        }
      } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_ID_MULTI)) {
        StringBuffer buff = new StringBuffer();

        while (values.hasNext()) {
          String value = values.next().toString();
          buff.append(value);

          if (values.hasNext()) buff.append(System.getProperty("line.separator"));
        }
        field = new JTextArea(buff.toString());
      } else {
        if (label.getText() == null) continue;

        field = new JTextField();

        if (values.hasNext()) {
          String value = values.next().toString();

          ((JTextField) field).setText(value);
        }
      }

      // If the field is not fixed (i.e. could be changed) we would like
      // to save it in a list in order to use it later when user saves
      // the configuration data.
      if (!fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) {
        uiFieldsTable.put(formField.getName(), field);
      }

      JPanel fieldPanel = new TransparentPanel(new GridLayout(1, 2));
      fieldPanel.setOpaque(false);

      if (!(field instanceof JLabel))
        fieldPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
      else fieldPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 1, 0));

      fieldPanel.add(label);
      fieldPanel.add(field);

      this.mainPanel.add(fieldPanel);
    }
  }