content: package ciscoroutertool.gui;
  
  /**
   * Allows a user to set the username and password for the application
   * @version 0.01ALPHA
   * @author Andrew Johnston
   */
  public class SecurityDialog extends javax.swing.JFrame {
  
      /**
       * Creates new form SecurityDialog
       */
      public SecurityDialog() {
          initComponents();
          radioDisableSecurity.setSelected(true);
          fieldUsername.setEnabled(false);
          fieldPassword.setEnabled(false);
      }
  
      /**
       * Creates new form SecurityDialog
       */
      public SecurityDialog(String username, String pass) {
          initComponents();
          radioEnableSecurity.setSelected(true);
          fieldUsername.setText(username);
          fieldPassword.setText(pass);
      }
  
      /**
       * This method is called from within the constructor to initialize the form.
       * WARNING: Do NOT modify this code. The content of this method is always
       * regenerated by the Form Editor.
       */
      @SuppressWarnings("unchecked")
      // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
      private void initComponents() {
  
          radioEnableSecurity = new javax.swing.JRadioButton();
          fieldUsername = new javax.swing.JTextField();
          jLabel1 = new javax.swing.JLabel();
          radioDisableSecurity = new javax.swing.JRadioButton();
          jLabel2 = new javax.swing.JLabel();
          fieldPassword = new javax.swing.JPasswordField();
          jLabel3 = new javax.swing.JLabel();
          btnClose = new javax.swing.JButton();
          btnSave = new javax.swing.JButton();
  
          radioEnableSecurity.setText("Enable User/Pass");
          radioEnableSecurity.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  radioEnableSecurityActionPerformed(evt);
              }
          });
  
          fieldUsername.setMinimumSize(new java.awt.Dimension(100, 20));
  
          jLabel1.setText("Username:");
  
          radioDisableSecurity.setText("Disable User/Pass");
          radioDisableSecurity.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  radioDisableSecurityActionPerformed(evt);
              }
          });
  
          jLabel2.setText("Password: ");
  
          jLabel3.setText("NOTE: This will allow anyone to run scans on the devices.");
  
          btnClose.setText("Close");
          btnClose.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  btnCloseActionPerformed(evt);
              }
          });
  
          btnSave.setText("Save");
          btnSave.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  btnSaveActionPerformed(evt);
              }
          });
  
          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
          getContentPane().setLayout(layout);
          layout.setHorizontalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                      .addGroup(layout.createSequentialGroup()
                          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                              .addGroup(layout.createSequentialGroup()
                                  .addGap(26, 26, 26)
                                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                      .addComponent(radioDisableSecurity)
                                      .addComponent(radioEnableSecurity)
                                      .addGroup(layout.createSequentialGroup()
                                          .addGap(21, 21, 21)
                                          .addComponent(jLabel3))))
                              .addGroup(layout.createSequentialGroup()
                                  .addGap(40, 40, 40)
                                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                      .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                      .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                      .addComponent(fieldPassword, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE)
                                      .addComponent(fieldUsername, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                          .addGap(0, 22, Short.MAX_VALUE))
                      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                          .addGap(0, 0, Short.MAX_VALUE)
                          .addComponent(btnSave)
                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                          .addComponent(btnClose)))
                  .addContainerGap())
          );
          layout.setVerticalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                  .addContainerGap(31, Short.MAX_VALUE)
                  .addComponent(radioEnableSecurity)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                      .addComponent(fieldUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                      .addComponent(jLabel1))
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                      .addComponent(jLabel2)
                      .addComponent(fieldPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                  .addComponent(radioDisableSecurity)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                  .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addGap(22, 22, 22)
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                      .addComponent(btnClose)
                      .addComponent(btnSave))
                  .addContainerGap())
          );
  
          pack();
      }// </editor-fold>//GEN-END:initComponents
  
      private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
          if (radioEnableSecurity.isSelected()) {
              String username = fieldUsername.getText();
              String password = new String(fieldPassword.getPassword());
              MainGUI.settingsManager.setAuth(username, password);
          } else {
              MainGUI.settingsManager.removeSecurity();
          }
          this.dispose();
      }//GEN-LAST:event_btnSaveActionPerformed
  
      private void radioDisableSecurityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioDisableSecurityActionPerformed
          radioEnableSecurity.setSelected(false);
          fieldUsername.setEnabled(false);
          fieldPassword.setEnabled(false);
      }//GEN-LAST:event_radioDisableSecurityActionPerformed
  
      private void radioEnableSecurityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioEnableSecurityActionPerformed
          radioDisableSecurity.setSelected(false);
          fieldUsername.setEnabled(true);
          fieldPassword.setEnabled(true);
      }//GEN-LAST:event_radioEnableSecurityActionPerformed
  
      private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseActionPerformed
          this.setVisible(false);
      }//GEN-LAST:event_btnCloseActionPerformed
  
     
      // Variables declaration - do not modify//GEN-BEGIN:variables
      private javax.swing.JButton btnClose;
      private javax.swing.JButton btnSave;
      private javax.swing.JPasswordField fieldPassword;
      private javax.swing.JTextField fieldUsername;
      private javax.swing.JLabel jLabel1;
      private javax.swing.JLabel jLabel2;
      private javax.swing.JLabel jLabel3;
      private javax.swing.JRadioButton radioDisableSecurity;
      private javax.swing.JRadioButton radioEnableSecurity;
      // End of variables declaration//GEN-END:variables
  }
  