Exemplo n.º 1
0
 // Check if OK should be enabled
 // Called on:
 //      -- change in text field
 //      -- change in check box selection
 //      -- change in team combo selection
 // Required:
 //      -- userName
 //      -- at least one check box
 //      -- password, if this is an Add, but not if Edit
 // Not required: TBD: ???
 //      -- First and Last Name
 //      -- Team
 private void checkOkSetEnabled() {
   char[] pchars = password.getPassword();
   char[] cchars = confirmPassword.getPassword();
   if (!userName.getText().equals("")
       && (unitizeCheckBox.isSelected()
           || uqcCheckBox.isSelected()
           || codingCheckBox.isSelected()
           || codingqcCheckBox.isSelected()
           || listingCheckBox.isSelected()
           || tallyCheckBox.isSelected()
           || qaCheckBox.isSelected()
           || tlCheckBox.isSelected()
           || adminCheckBox.isSelected())
       && (usersId != 0 || pchars.length != 0)
       && (pchars.length == 0 || cchars.length != 0)) {
     okButton.setEnabled(true);
   } else {
     okButton.setEnabled(false);
   }
   if (pchars.length == 0) {
     confirmPassword.setEditable(false);
   } else {
     confirmPassword.setEditable(true);
   }
   Arrays.fill(pchars, '#');
   Arrays.fill(cchars, '#');
 }
  /**
   * Validates that inputted info is correct, resets password info in database resets textfields to
   * empty string ""
   *
   * @throws SQLException throws exception if connection could not be made
   */
  public void Validator() throws SQLException {
    update.setText("");
    setUser(UsersConnection.getInfo(username.getText(), emailf.getText(), 5));
    boolean validInfo = true;
    String emailinfo = new String(emailf.getText());
    if (emailinfo.equals("")) {
      emailWrong.setText("<html>*You must enter email to<br>update your password<html/>");
      validInfo = false;
    } else if (!emailinfo.equals(u.getEmail())) {
      System.out.println("here!");
      emailWrong.setText("*Wrong email");
      validInfo = false;
    } else emailWrong.setText("");

    String passinfo1 = new String(password1.getPassword());
    if (!passinfo1.equals("") && passinfo1.length() < 4) {
      pass1Wrong.setText("Password must at least 4 charactor");
      validInfo = false;
    } else pass1Wrong.setText("");
    String passinfo2 = new String(password2.getPassword());

    if (passinfo2.equals(passinfo1)) pass2Wrong.setText("");
    else {
      pass2Wrong.setText("*Password does not match");
      validInfo = false;
    }

    if (validInfo) {
      if (!passinfo1.equals("")) u.setPassword(passinfo1);
      init();
      update.setText("Your information is up-dated");
      emailWrong.setText("");
    }
  }
Exemplo n.º 3
0
  private void checkInput() {
    if (0 == userNameField.getText().trim().length()) {
      JOptionPane.showMessageDialog(this, "用户名不能为空", "警告", JOptionPane.WARNING_MESSAGE);
      userNameField.requestFocus();
      return;
    }

    if (0 == passwordField.getPassword().length) {
      JOptionPane.showMessageDialog(this, "密码不能为空", "警告", JOptionPane.WARNING_MESSAGE);
      passwordField.requestFocus();
      return;
    }

    if (!new String(confirmPasswordField.getPassword())
        .equals(new String(passwordField.getPassword()))) {
      JOptionPane.showMessageDialog(this, "两次密码不相同", "警告", JOptionPane.WARNING_MESSAGE);
      passwordField.requestFocus();
      return;
    }

    if (0 == nickNameField.getText().trim().length()) {
      JOptionPane.showMessageDialog(this, "昵称不能为空", "警告", JOptionPane.WARNING_MESSAGE);
      nickNameField.requestFocus();
      return;
    }
  }
Exemplo n.º 4
0
  @SuppressWarnings("empty-statement")
  private String getPassWd(boolean first) {
    String passWd = "";
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    if (first) panel.add(new JLabel("Enter Password\n\n"));
    else panel.add(new JLabel("Re-enter Password\n\n"));
    final JPasswordField passwordField =
        new JPasswordField(10); // box to take passwords from the user
    panel.add(passwordField);
    JOptionPane pane =
        new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION) {
          private static final long serialVersionUID = 1L;

          @Override
          public void selectInitialValue() {
            passwordField.requestFocusInWindow();
          }
        };
    pane.createDialog(null, "Enter Password").setVisible(true);
    passWd =
        passwordField.getPassword().length == 0 ? null : new String(passwordField.getPassword());
    passwordField.setText("");
    return passWd;
  }
Exemplo n.º 5
0
  public static void init(JPasswordField fpasswd) {
    try {
      String resource = "artemis_sqlmap/chado_iBatis_config.xml";
      Reader reader = Resources.getResourceAsReader(resource);

      Properties properties = null;
      if (System.getProperty("chado") != null) {
        String url = System.getProperty("chado");
        int index = url.indexOf("?");
        int index2 = url.indexOf("user="******"://");
        if (index3 < 0) index3 = 0;
        else index3 = index3 + 3;

        properties.put("chado", url.substring(index3, index));

        if (index2 < 0) properties.put("username", url.substring(index + 1));
        else properties.put("username", url.substring(index2 + 5));

        if (fpasswd != null && fpasswd.getPassword().length > 0)
          properties.put("password", new String(fpasswd.getPassword()));
      }

      sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader, properties);
    } catch (Exception e) {
      // If you get an error at this point, it doesnt matter what it was.  It is going to be
      // unrecoverable and we will want the app to blow up hard so we are aware of the
      // problem.  You should always log such errors and re-throw them in such a way that
      // you can be made immediately aware of the problem.
      e.printStackTrace();
      throw new RuntimeException("Error initializing DbSqlConfig class.  Cause: " + e);
    }
  }
  // appelé lorsqu'on appuie sur le bouton "ok"
  public void check() {

    if (!Share.Tools.isSamePassword(password.getPassword(), password2.getPassword())) {
      // Couleur rouge
      color = new Color(255, 0, 0);
      // Permet de changer la couleur
      password.setForeground(color);
      password2.setForeground(color);
    }
  }
Exemplo n.º 7
0
  private RegisterInfo getRegisterInfo() {

    RegisterInfo result =
        new RegisterInfo(
            userNameField.getText(),
            new String(passwordField.getPassword()),
            new String(confirmPasswordField.getPassword()),
            nickNameField.getText());

    return result;
  }
Exemplo n.º 8
0
  /** Modifies the existing password. */
  private void changePassword() {
    UserNotifier un;
    if (!oldPassword.isVisible()) {
      StringBuffer buf = new StringBuffer();
      buf.append(passwordNew.getPassword());
      String newPass = buf.toString();
      if (newPass == null || newPass.length() == 0) {
        un = MetadataViewerAgent.getRegistry().getUserNotifier();
        un.notifyInfo(PASSWORD_CHANGE_TITLE, "Please enter the new password.");
        passwordNew.requestFocus();
        return;
      }
      un = MetadataViewerAgent.getRegistry().getUserNotifier();
      un.notifyInfo(PASSWORD_CHANGE_TITLE, "Password changed.");
      passwordNew.setText("");
      model.resetPassword(newPass);
      return;
    }
    StringBuffer buf = new StringBuffer();
    buf.append(passwordNew.getPassword());
    String newPass = buf.toString();

    String pass = buf.toString();
    buf = new StringBuffer();
    buf.append(passwordConfirm.getPassword());
    String confirm = buf.toString();

    buf = new StringBuffer();
    buf.append(oldPassword.getPassword());
    String old = buf.toString();
    if (old == null || old.trim().length() == 0) {
      un = MetadataViewerAgent.getRegistry().getUserNotifier();
      un.notifyInfo(PASSWORD_CHANGE_TITLE, "Please specify your old password.");
      oldPassword.requestFocus();
      return;
    }
    if (newPass == null || newPass.length() == 0) {
      un = MetadataViewerAgent.getRegistry().getUserNotifier();
      un.notifyInfo(PASSWORD_CHANGE_TITLE, "Please enter your new password.");
      passwordNew.requestFocus();
      return;
    }

    if (pass == null || confirm == null || confirm.length() == 0 || !pass.equals(confirm)) {
      un = MetadataViewerAgent.getRegistry().getUserNotifier();
      un.notifyInfo(
          PASSWORD_CHANGE_TITLE, "The passwords entered do not match. " + "Please try again.");
      passwordNew.setText("");
      passwordConfirm.setText("");
      passwordNew.requestFocus();
      return;
    }
    model.changePassword(old, confirm);
  }
Exemplo n.º 9
0
 /**
  * Check password filled if it is true then save the user data
  *
  * @return true if the data is saved successfully, false if password is entered and it does not
  *     match.
  */
 private boolean save() {
   char[] pchars = password.getPassword();
   String pword = "";
   if (pchars.length > 0) {
     pword = MD5.computeDigest(pchars);
     Arrays.fill(pchars, '\u0000');
     char[] cchars = confirmPassword.getPassword();
     String cword = MD5.computeDigest(cchars);
     Arrays.fill(cchars, '\u0000');
     if (!pword.equals(cword)) {
       Toolkit.getDefaultToolkit().beep();
       JOptionPane.showMessageDialog(
           this,
           "Password must match Confirm Password." + "\nPlease re-enter.",
           "Password Error",
           JOptionPane.ERROR_MESSAGE);
       return false;
     }
   }
   final ClientTask task;
   int teamsId = teamsModel.getSelectedId();
   if (teamsId < 0) {
     teamsId = 0;
   }
   usersData = new UsersData();
   usersData.users_id = usersId;
   usersData.teams_id = teamsId;
   usersData.user_name = userName.getText();
   usersData.first_name = fname.getText();
   usersData.last_name = lname.getText();
   usersData.unitize = unitizeCheckBox.isSelected() ? "Yes" : "No";
   usersData.uqc = uqcCheckBox.isSelected() ? "Yes" : "No";
   usersData.coding = codingCheckBox.isSelected() ? "Yes" : "No";
   usersData.codingqc = codingqcCheckBox.isSelected() ? "Yes" : "No";
   usersData.qa = qaCheckBox.isSelected() ? "Yes" : "No";
   usersData.listing = listingCheckBox.isSelected() ? "Yes" : "No";
   usersData.tally = tallyCheckBox.isSelected() ? "Yes" : "No";
   usersData.teamLeader = tlCheckBox.isSelected() ? "Yes" : "No";
   usersData.admin = adminCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminUsers = adminUsersCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminProject = adminProjectCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminBatch = adminBatchCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminEdit = adminEditCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminImport = adminImportCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminExport = adminExportCheckBox.isSelected() ? "Yes" : "No";
   usersData.canAdminProfit = adminProfitCheckBox.isSelected() ? "Yes" : "No";
   usersData.password = pword;
   usersData.dateOfJoin = field.getText();
   task = new TaskSendUsersData(usersData);
   task.enqueue(this);
   return true;
 }
Exemplo n.º 10
0
 /** Sets the enabled flag of some password controls depending on the text entered. */
 private void handlePasswordEntered() {
   char[] values = passwordNew.getPassword();
   if (oldPassword.isVisible()) {
     char[] oldValues = oldPassword.getPassword();
     char[] confirmValues = passwordConfirm.getPassword();
     if (values != null && oldValues != null && confirmValues != null) {
       passwordButton.setEnabled(
           values.length > 0 && oldValues.length > 0 && confirmValues.length == values.length);
     }
   } else {
     passwordButton.setEnabled(values != null && values.length > 0);
   }
 }
Exemplo n.º 11
0
 /*
  * (non-Javadoc)
  *
  * @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.
  * DocumentEvent)
  */
 @Override
 public void insertUpdate(final DocumentEvent e) {
   if (modifier.get() > 0) {
     return;
   }
   if (!equal(editor.getPassword(), getMask().toCharArray())) {
     onChanged();
   }
   if (editor.getPassword().length > 0 && !equal(editor.getPassword(), getMask().toCharArray())) {
     renderer.setText(getMask());
   } else {
     renderer.setText("");
   }
 }
Exemplo n.º 12
0
  /** Attempts to log in. */
  private void login() {
    firePropertyChange(TO_FRONT_PROPERTY, Boolean.valueOf(false), Boolean.valueOf(true));
    requestFocusOnField();
    StringBuffer buf = new StringBuffer();
    buf.append(pass.getPassword());
    String usr = user.getText(), psw = buf.toString();
    String s = serverText.getText();
    if (CommonsLangUtils.isBlank(usr)
        || CommonsLangUtils.isBlank(s)
        || s.trim().equals(DEFAULT_SERVER)) {
      requestFocusOnField();
      return;
    }
    if (usr != null) usr = usr.trim();
    if (s != null) s = s.trim();
    setControlsEnabled(false);
    LoginCredentials lc;
    if (groupsBox == null) {
      lc = new LoginCredentials(usr, psw, s, speedIndex, selectedPort, encrypted);
    } else {
      long id = -1L;
      if (hasGroupOption() && groupsBox.isVisible())
        // id = getGroupId(groupsBox.getText());
        id = getGroupId(groupNames.get(groupsBox.getSelectedIndex()));

      lc = new LoginCredentials(usr, psw, s, speedIndex, selectedPort, id, encrypted);
    }
    setUserName(usr);
    setEncrypted();
    setControlsEnabled(false);
    loginAttempt = true;
    login.setEnabled(false);
    firePropertyChange(LOGIN_PROPERTY, null, lc);
  }
  @Override
  public void apply(@NotNull HttpConfigurable settings) {
    if (!isValid()) {
      return;
    }

    if (isModified(settings)) {
      settings.AUTHENTICATION_CANCELLED = false;
    }

    settings.USE_PROXY_PAC = myAutoDetectProxyRb.isSelected();
    settings.USE_PAC_URL = myPacUrlCheckBox.isSelected();
    settings.PAC_URL = getText(myPacUrlTextField);
    settings.USE_HTTP_PROXY = myUseHTTPProxyRb.isSelected();
    settings.PROXY_TYPE_IS_SOCKS = mySocks.isSelected();
    settings.PROXY_AUTHENTICATION = myProxyAuthCheckBox.isSelected();
    settings.KEEP_PROXY_PASSWORD = myRememberProxyPasswordCheckBox.isSelected();

    settings.setProxyLogin(getText(myProxyLoginTextField));
    settings.setPlainProxyPassword(new String(myProxyPasswordTextField.getPassword()));
    settings.PROXY_EXCEPTIONS = StringUtil.nullize(myProxyExceptions.getText(), true);

    settings.PROXY_PORT = myProxyPortTextField.getNumber();
    settings.PROXY_HOST = getText(myProxyHostTextField);
  }
  private boolean isValid() {
    if (myUseHTTPProxyRb.isSelected()) {
      String host = getText(myProxyHostTextField);
      if (host == null) {
        return false;
      }

      try {
        HostAndPort parsedHost = HostAndPort.fromString(host);
        if (parsedHost.hasPort()) {
          return false;
        }
        host = parsedHost.getHostText();

        try {
          InetAddresses.forString(host);
          return true;
        } catch (IllegalArgumentException e) {
          // it is not an IPv4 or IPv6 literal
        }

        InternetDomainName.from(host);
      } catch (IllegalArgumentException e) {
        return false;
      }

      if (myProxyAuthCheckBox.isSelected()) {
        return !StringUtil.isEmptyOrSpaces(myProxyLoginTextField.getText())
            && myProxyPasswordTextField.getPassword().length > 0;
      }
    }
    return true;
  }
 private void onRegister(Frame parent) {
   String username = loginField.getText();
   String password = String.valueOf(passwordField.getPassword());
   dispose();
   RegisterDialog registerDialog = new RegisterDialog(username, password, parent);
   registerDialog.setVisible(true);
 }
Exemplo n.º 16
0
 public char[] askPassword() {
   char[] password = null;
   final JDialog dlg = new JDialog(frm, "Password", true);
   final JPasswordField jpf = new JPasswordField(15);
   final JButton[] btns = {new JButton("Enter"), new JButton("Cancel")};
   for (int i = 0; i < btns.length; i++) {
     btns[i].addActionListener(
         new ActionListener() {
           public void actionPerformed(ActionEvent e) {
             dlg.setVisible(false);
           }
         });
   }
   Object[] prts = new Object[] {"Please input a password:"******"Invalid password, passwords must be " + PASSWORD_MIN + " characters long");
     System.exit(1);
   }
   return password;
 }
Exemplo n.º 17
0
  public static char[] showPasswordDialog(Component parent, String titre) {
    final JPasswordField jpf = new JPasswordField();
    JOptionPane jop =
        new JOptionPane(jpf, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    // FIXME: label
    JDialog dialog = jop.createDialog(parent, titre);
    dialog.addComponentListener(
        new ComponentAdapter() {

          public void componentShown(ComponentEvent e) {
            jpf.requestFocusInWindow();
          }
        });
    dialog.setVisible(true);
    if (jop.getValue() == null) {
      return null;
    }
    int result = (Integer) jop.getValue();
    dialog.dispose();
    char[] password = null;
    if (result == JOptionPane.OK_OPTION) {
      password = jpf.getPassword();
    } else {
      return null;
    }
    return password;
  }
 /**
  * Salva os dados inseridos na janela em um objeto do tipo <code>Funcionario</code>
  *
  * @param funcionario <code>Object</code> referênte ao objeto que será salvo
  */
 @Override
 public void salvarCampos(Object funcionario) {
   ((Funcionario) funcionario).setNomeUsuario(loginTextField.getText());
   ((Funcionario) funcionario).setSenha(new String(passwordField.getPassword()));
   ((Funcionario) funcionario)
       .setTipoUsuario(TipoUsuario.obterTipoUsuario(obterRadioBtnSelecionado()));
 }
Exemplo n.º 19
0
  public void login() {
    boolean found = false;

    for (UserProfile up : menu.getMain().getUserProfiles()) {
      if (up.getUsername().equals(username.getText())) {
        char[] pwd = password.getPassword();
        String pwdAsString = "";

        for (char c : pwd) {
          pwdAsString += c;
        }

        if (up.getPassword() == pwdAsString.hashCode()) {
          clearFields();

          menu.getMain().setCurrentUser(up);
          menu.getMain().setUserHistory(up.getUserHistory());
          Spreadsheet.fileSelectEditor.setFtpManager(up.getFtpManager());
          menu.changeView(menu.getMainMenuGUI());
          found = true;

          break;
        }
      }
    }

    if (!found) {
      status.setText("<html><b>Error: </b> Username or password incorrect! </html>");
    }
  }
Exemplo n.º 20
0
 private static void showDialog(String[] login) {
   JTextField uf = new JTextField(20);
   uf.setText(login[0]);
   JPasswordField pf = new JPasswordField(20);
   JPanel p = new JPanel(new GridBagLayout());
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.anchor = GridBagConstraints.FIRST_LINE_START;
   gbc.insets.left = 5;
   gbc.insets.bottom = 5;
   gbc.gridx = 0;
   gbc.gridy = 0;
   p.add(new JLabel("User"), gbc);
   gbc.gridx = 1;
   gbc.gridy = 0;
   p.add(uf, gbc);
   gbc.gridx = 0;
   gbc.gridy = 1;
   p.add(new JLabel("Password"), gbc);
   gbc.gridx = 1;
   gbc.gridy = 1;
   p.add(pf, gbc);
   JOptionPane op = new JOptionPane(p);
   op.setOptions(new String[] {"OK", "Cancel"});
   JDialog dlg = op.createDialog(null, "Login");
   dlg.pack();
   int i = SupportUI.show(dlg, op);
   if (i != 0) {
     System.exit(0);
   }
   login[0] = uf.getText().trim();
   login[1] = new String(pf.getPassword());
 }
Exemplo n.º 21
0
  /*
   * User has hit the OK button; save and check data.
   */
  public void okAction() {
    // Save data from the dialog
    outputFolder = outputDirTF.getText().trim();
    chanName = chanNameTF.getText().trim();
    bUseFTP = bUseFTPCheckB.isSelected();
    ftpHost = ftpHostTF.getText().trim();
    ftpUser = ftpUserTF.getText().trim();
    char[] passwordCharArray = ftpPasswordTF.getPassword();
    ftpPassword = new String(passwordCharArray).trim();
    bManualFlush = manualFlushRB.isSelected();
    flushInterval = (double) flushIntervalInts[flushIntervalComboB.getSelectedIndex()];
    if (bManualFlush) {
      bZipData = false;
    } else {
      if ((int) flushInterval == -1) {
        bZipData = false;
      } else {
        bZipData = true;
      }
    }

    // Check data
    String errStr = canCTrun();
    if (!errStr.isEmpty()) {
      // Was a problem with the data the user entered
      JOptionPane.showMessageDialog(
          this, errStr, "CloudTurbine settings error", JOptionPane.ERROR_MESSAGE);
      return;
    }

    setBClickedOK(true);

    // Pop down the dialog
    setVisible(false);
  }
Exemplo n.º 22
0
 private void updateValues() {
   lastServer = serverField.getText();
   lastShare = shareField.getText();
   lastDomain = domainField.getText();
   lastUsername = usernameField.getText();
   lastPassword = new String(passwordField.getPassword());
 }
Exemplo n.º 23
0
 /** Sets the enabled flag of the {@link #login} button. */
 private void enableControls() {
   boolean enabled = true;
   String s = serverText.getText();
   char[] name = pass.getPassword();
   String usr = user.getText().trim();
   if (CommonsLangUtils.isBlank(s) || CommonsLangUtils.isBlank(usr)) {
     enabled = false;
   } else {
     s = s.trim();
     if (DEFAULT_SERVER.equals(s)) {
       enabled = false;
     }
   }
   login.setEnabled(enabled);
   if (enabled) {
     ActionListener[] listeners = login.getActionListeners();
     if (listeners != null) {
       boolean set = false;
       for (int i = 0; i < listeners.length; i++) {
         if (listeners[i] == this) {
           set = true;
           break;
         }
       }
       if (!set) login.addActionListener(this);
     }
     login.setForeground(defaultForeground);
   } else {
     login.setForeground(FOREGROUND_COLOR);
   }
   layout(hasGroupOption());
 }
Exemplo n.º 24
0
 private void checkLogin() {
   // 对输入进行基本的合法非法判断
   String id = idTxt.getText();
   String passwd = String.valueOf(passwordTxt.getPassword());
   ResultMessage idResult = Utility.checkInputValid(id, 4, 14, false);
   ResultMessage passwdResult = Utility.checkInputValid(passwd, 5, 14, false);
   if (idResult != ResultMessage.SUCCESS) {
     MyOptionPane.showMessageDialog(null, "输入的用户名" + idResult.toFriendlyString() + "!");
     return;
   } else if (passwdResult != ResultMessage.SUCCESS) {
     MyOptionPane.showMessageDialog(null, "输入的密码" + passwdResult.toFriendlyString() + "!");
     return;
   }
   // 登录验证
   ResultMessage loginresult = loginController.login(usertype.getSelectedIndex(), id, passwd);
   if (loginresult == ResultMessage.SUCCESS) {
     new HomeUI(loginController);
     frame.dispose();
   } else {
     if (loginresult == ResultMessage.WRONG_ID) {
       MyOptionPane.showMessageDialog(null, "用户名错误!");
       idTxt.setText("");
       passwordTxt.setText("");
     } else if (loginresult == ResultMessage.WRONG_PASSWD) {
       MyOptionPane.showMessageDialog(null, "密码错误!");
       passwordTxt.setText("");
     } else {
       MyOptionPane.showMessageDialog(null, "服务器未开启!");
     }
   }
 }
Exemplo n.º 25
0
  private boolean checkPassword() {
    Password firstPassword;

    if (jpfFirst instanceof JPasswordQualityField) {
      char[] firstPasswordChars = ((JPasswordQualityField) jpfFirst).getPassword();

      if (firstPasswordChars == null) {
        JOptionPane.showMessageDialog(
            this,
            res.getString("MinimumPasswordQualityNotMet.message"),
            getTitle(),
            JOptionPane.WARNING_MESSAGE);
        return false;
      }

      firstPassword = new Password(firstPasswordChars);
    } else {
      firstPassword = new Password(((JPasswordField) jpfFirst).getPassword());
    }

    Password confirmPassword = new Password(jpfConfirm.getPassword());

    if (firstPassword.equals(confirmPassword)) {
      password = firstPassword;
      return true;
    }

    JOptionPane.showMessageDialog(
        this, res.getString("PasswordsNoMatch.message"), getTitle(), JOptionPane.WARNING_MESSAGE);

    return false;
  }
Exemplo n.º 26
0
 private void setAllFildsToUser() {
   if (checkPassword()) {
     _user.setLogin(jTextFieldAccountName.getText());
     _user.setRedirectUrl(jTextFieldRedirectUrl.getText());
     _user.setPassword(new String(jPasswordFieldNewPassword.getPassword()));
   }
 }
 private void showUserDialog() {
   JOptionPane.showConfirmDialog(
       null,
       new Object[] {
         this.error,
         "User:"******"Pwd:",
         passwordField,
         "Hostname:",
         hostNameField,
         "Auth URL",
         authURLField,
         "Rootservices",
         rootservicesURLField
       },
       "Specify Connection Details",
       JOptionPane.OK_CANCEL_OPTION);
   this.userName = userNameField.getText();
   this.password = passwordField.getPassword();
   this.hostname = hostNameField.getText();
   this.rootservicesURL = rootservicesURLField.getText();
   try {
     this.jazzAuthUrl = new URI(authURLField.getText());
   } catch (URISyntaxException e) {
     this.error = e.getMessage();
     e.printStackTrace();
     showUserDialog();
   }
 }
  @Override
  public Map<String, String> getChangedValues() {
    TorrentClient torrentClient = (TorrentClient) this.manager;
    Map<String, String> result = new HashMap<String, String>();
    if (!initialRpcServer.equals(getRPCFieldText())) {
      result.put(torrentClient.getServerConfigKey(), getRPCFieldText());
    }
    System.out.println(this.needsAuthCheckBox.isSelected());
    // if(this.needsAuthCheckBox.isSelected()){
    if (!userField.getText().trim().equals(initialUser)) {
      result.put(torrentClient.getUserConfigKey(), userField.getText().trim());
    }
    String password = new String(passwordField.getPassword());
    if (!password.equals(initialPassword)) {
      if (!password.isEmpty()) {
        password = Base64.encodeBytes(password.getBytes());
      }
      result.put(torrentClient.getPasswordConfigKey(), password);
    }
    /*}else{
    	result.put(torrentClient.getUserConfigKey(), "");
    	result.put(torrentClient.getPasswordConfigKey(), "");
    }*/

    return result;
  }
Exemplo n.º 29
0
  private void onOK() {
    if (!isValidInput()) {
      return;
    }
    dispose();
    String firstName = firstNameField.getText().trim();
    String lastName = lastNameField.getText().trim();
    String emailAddress = emailAddressField.getText().trim();
    SexOfPerson sexOfPerson;
    if (femaleRadioButton.isSelected()) {
      sexOfPerson = SexOfPerson.FEMALE;
    } else {
      sexOfPerson = SexOfPerson.MALE;
    }
    String country = (String) countryComboBox.getSelectedObject();
    Integer birthdayYear = (Integer) birthdayYearComboBox.getSelectedItem();
    Month birthdayMonth = (Month) birthdayMonthComboBox.getSelectedItem();
    Integer birthdayDay = (Integer) birthdayDayComboBox.getSelectedItem();
    char[] passwordArr = passwordField.getPassword();
    String password = new String(passwordArr);
    Arrays.fill(passwordArr, (char) 0);
    Image profilePicture = null;
    if (imageFromFileRadioButton.isSelected()) {
      if (fileSelector.getFilePath() != null) {
        profilePicture = new FileImage(fileSelector.getFilePath());
      }
    }
    Request request =
        new CreateUserRequest(
            communicator.getHttpClient(),
            frame,
            firstName,
            lastName,
            emailAddress,
            sexOfPerson,
            country,
            birthdayYear,
            birthdayMonth,
            birthdayDay,
            password,
            profilePicture) {

          @Override
          protected void onCreateUser(String status, Person person) {
            if (status.equals("INVALID_PROFILE_PICTURE")) {
              communicator.promptForCreateAccount("Invalid profile picture");
            } else if (status.equals("ERROR_CREATING_USER")) {
              communicator.promptForCreateAccount("Error creating user");
            } else if (status.equals("CONNECTION_ERROR")) {
              communicator.promptForCreateAccount("Error connecting to Modeling Commons");
            } else if (status.equals("SUCCESS")) {
              communicator.setPerson(person);
              communicator.promptForUpload();
            } else {
              communicator.promptForCreateAccount("Unknown server error");
            }
          }
        };
    request.execute();
  }
Exemplo n.º 30
0
 /**
  * Based on the mode that is set by constructors and depending on the type of the mode value a
  * different value is returned.
  *
  * <p>The type of mode values are <code>int</code>, <code>double</code>, <code>String</code> and
  * <code>Pass</code>
  *
  * <p>Returns <code>null</code> if mode type does not match.
  */
 public Object getValue() {
   if (mode == INT) return (int) Integer.valueOf(inputfield.getText());
   else if (mode == DOUBLE) return (double) Double.valueOf(inputfield.getText());
   else if (mode == STRING) return (String) inputfield.getText();
   else if (mode == PASS) return (char[]) passfield.getPassword();
   else return null;
 }