/**
   * 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("");
    }
  }
Пример #2
0
  void addButton_actionPerformed(ActionEvent e) {
    if (jTextFieldAccountname.getText().length() == 0) {
      JOptionPane.showMessageDialog(
          null, "Fill in the Account Name", "Error", JOptionPane.ERROR_MESSAGE);
      jTextFieldAccountname.requestFocus();
    } else if (jTextFieldFullname.getText().length() == 0) {
      JOptionPane.showMessageDialog(
          null, "Fill in the Full Name", "Error", JOptionPane.ERROR_MESSAGE);
      jTextFieldFullname.requestFocus();
    } else if ((String.valueOf(jPasswordField1.getPassword()))
            .equals(String.valueOf(jPasswordField2.getPassword()))
        == false) {

      JOptionPane.showMessageDialog(
          null, "Passwords don't match", "Error", JOptionPane.ERROR_MESSAGE);
      jPasswordField1.requestFocus();
    } else {
      usermodel.addUser(
          new User(
              jTextFieldAccountname.getText(),
              jTextFieldFullname.getText(),
              jPasswordField1.getPassword()));
      usermodel.fireTableDataChanged();
    }
  }
  // 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);
    }
  }
  public boolean isModified() {
    boolean isModified = false;
    HttpConfigurable httpConfigurable = myHttpConfigurable;
    if (!Comparing.equal(myProxyExceptions.getText().trim(), httpConfigurable.PROXY_EXCEPTIONS))
      return true;
    isModified |= httpConfigurable.USE_PROXY_PAC != myAutoDetectProxyRb.isSelected();
    isModified |= httpConfigurable.USE_PAC_URL != myPacUrlCheckBox.isSelected();
    isModified |= !Comparing.strEqual(httpConfigurable.PAC_URL, myPacUrlTextField.getText());
    isModified |= httpConfigurable.USE_HTTP_PROXY != myUseHTTPProxyRb.isSelected();
    isModified |= httpConfigurable.PROXY_AUTHENTICATION != myProxyAuthCheckBox.isSelected();
    isModified |=
        httpConfigurable.KEEP_PROXY_PASSWORD != myRememberProxyPasswordCheckBox.isSelected();
    isModified |= httpConfigurable.PROXY_TYPE_IS_SOCKS != mySocks.isSelected();

    isModified |=
        !Comparing.strEqual(httpConfigurable.PROXY_LOGIN, myProxyLoginTextField.getText());
    isModified |=
        !Comparing.strEqual(
            httpConfigurable.getPlainProxyPassword(),
            new String(myProxyPasswordTextField.getPassword()));

    try {
      isModified |=
          httpConfigurable.PROXY_PORT != Integer.valueOf(myProxyPortTextField.getText()).intValue();
    } catch (NumberFormatException e) {
      isModified = true;
    }
    isModified |= !Comparing.strEqual(httpConfigurable.PROXY_HOST, myProxyHostTextField.getText());
    return isModified;
  }
Пример #5
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>");
    }
  }
 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);
 }
Пример #7
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;
 }
Пример #8
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, "服务器未开启!");
     }
   }
 }
Пример #9
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;
 }
  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;
  }
  @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);
  }
Пример #12
0
  public boolean validarCampos() {

    boolean resp = true;
    int clv;

    usuario = txtusuario.getText();
    clave = new String(txtclave.getPassword());

    // si usuario esta vacio
    if (usuario.trim().length() == 0) {
      JOptionPane.showMessageDialog(
          this,
          "Por favor Ingrese el Usuario",
          "Campo Usuario (Obligatorio)",
          JOptionPane.ERROR_MESSAGE);
      resp = txtusuario.requestFocusInWindow();
      return resp;
    }
    // si clave esta vacio
    if (clave.trim().length() == 0) {
      JOptionPane.showMessageDialog(
          this,
          "Por favor ingrese la clave",
          "Campo Contraseña (Obligatorio)",
          JOptionPane.ERROR_MESSAGE);
      resp = false;
      return resp;
    }
    if (usuario.trim().length() < 3 || usuario.trim().length() > 20) {
      JOptionPane.showMessageDialog(
          this,
          "Debe ingresar mínimo 3 caracteres " + "y máximo 20",
          "Campo Usuario (Obligatorio)",
          JOptionPane.ERROR_MESSAGE);
      txtusuario.setText("");
      txtclave.setText("");
      txtusuario.requestFocusInWindow();
      resp = false;
      return resp;
    }

    if (clave.trim().length() < 3 || clave.trim().length() > 16) {
      JOptionPane.showMessageDialog(
          this,
          "Debe ingresar mínimo 3 caracteres " + "y máximo 16",
          "Campo Clave (Obligatorio)",
          JOptionPane.ERROR_MESSAGE);
      txtclave.setText("");
      txtclave.requestFocusInWindow();
      resp = false;
      return resp;
    }

    return resp;
  }
Пример #13
0
 private void handleConnect() {
   if (jToggleButtonConnect.isSelected() || jMenuItemServerConnect.isEnabled())
     try {
       jTextPaneDisplayMessages.setText("");
       session = new Session();
       try {
         String userid = jTextFieldUser.getText();
         if (jPasswordFieldPwd.getPassword() != null) {
           String pwd = String.valueOf(jPasswordFieldPwd.getPassword()).trim();
           if (!pwd.equals("")) {
             userid += ":" + pwd;
           }
         }
         if (session.connect(jTextFieldServer.getText(), userid)) {
           displayMessage("Connected\n", incomingMsgAttrSet);
           session.addListener(this);
           jToggleButtonConnect.setText("Disconnect");
           jMenuItemServerConnect.setEnabled(false);
           jMenuItemServerDisconnect.setEnabled(true);
         } else {
           jToggleButtonConnect.setSelected(false);
           jMenuItemServerConnect.setEnabled(true);
           jMenuItemServerDisconnect.setEnabled(false);
           displayMessage("Connection attempt failed\n", offlineClientAttrSet);
         }
       } catch (ConnectionException ex1) {
         jToggleButtonConnect.setSelected(false);
         jMenuItemServerConnect.setEnabled(true);
         jMenuItemServerDisconnect.setEnabled(false);
         displayMessage(
             "Connection attempt failed: " + ex1.getMessage() + "\n", offlineClientAttrSet);
       }
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   else {
     disconnect();
     jMenuItemServerConnect.setEnabled(true);
     jMenuItemServerDisconnect.setEnabled(false);
     displayMessage("Disconnected\n", offlineClientAttrSet);
   }
 }
Пример #14
0
  public PreferencesProxyDTO getPreferencesProxyDTO() {
    String proxySettingType = proxySettingGroup.getSelection().getActionCommand();
    switch (proxySettingType) {
      case "noProxy":
        preferencesProxyDTO.setProxySettingType(0);
        break;
      case "systemProxy":
        preferencesProxyDTO.setProxySettingType(1);
        break;
      case "manualProxy":
        preferencesProxyDTO.setProxySettingType(2);
    }

    if (useProxyRadioButton.isSelected()) preferencesProxyDTO.setUseProxyNotSocks(true);
    else preferencesProxyDTO.setUseProxyNotSocks(false);

    // for http
    preferencesProxyDTO.setHttpProxyAddress(httpProxyAddressTextField.getText());
    preferencesProxyDTO.setHttpProxyPort((Integer) httpProxyPortSpinner.getValue());
    preferencesProxyDTO.setHttpProxyUserName(httpProxyUserNameTextField.getText());
    preferencesProxyDTO.setHttpProxyPassword(new String(httpProxyPasswordField.getPassword()));

    // for https
    preferencesProxyDTO.setHttpsProxyAddress(httpsProxyAddressTextField.getText());
    preferencesProxyDTO.setHttpsProxyPort((Integer) httpsProxyPortSpinner.getValue());
    preferencesProxyDTO.setHttpsProxyUserName(httpsProxyUserNameTextField.getText());
    preferencesProxyDTO.setHttpsProxyPassword(new String(httpsProxyPasswordField.getPassword()));

    // for ftp
    preferencesProxyDTO.setFtpProxyAddress(ftpProxyAddressTextField.getText());
    preferencesProxyDTO.setFtpProxyPort((Integer) ftpProxyPortSpinner.getValue());
    preferencesProxyDTO.setFtpProxyUserName(ftpProxyUserNameTextField.getText());
    preferencesProxyDTO.setFtpProxyPassword(new String(ftpProxyPasswordField.getPassword()));

    // for ftp
    preferencesProxyDTO.setSocksProxyAddress(socksProxyAddressTextField.getText());
    preferencesProxyDTO.setSocksProxyPort((Integer) socksProxyPortSpinner.getValue());
    preferencesProxyDTO.setSocksProxyUserName(socksProxyUserNameTextField.getText());
    preferencesProxyDTO.setSocksProxyPassword(new String(socksProxyPasswordField.getPassword()));

    return preferencesProxyDTO;
  }
  /**
   * Handles the <tt>ActionEvent</tt> triggered when one of the buttons is clicked. When "Login"
   * button is choosen installs a new account from the user input and logs in.
   *
   * @param evt the action event that has just occurred.
   */
  public void actionPerformed(ActionEvent evt) {
    JButton button = (JButton) evt.getSource();
    String buttonName = button.getName();

    if (buttonName.equals("ok")) {
      GuiActivator.getUIService()
          .getConferenceChatManager()
          .joinChatRoom(
              chatRoom, idValue.getText(), new String(passwdField.getPassword()).getBytes());
    }

    this.dispose();
  }
Пример #16
0
  /**
   * Metoden skapar en ny användare. Vid anrop öppnas ett dialogfönster, där användaren kan mata in
   * önskat användarnamn och lösenord.
   *
   * @return ny användare i form av ett <code>User</code>-objekt
   * @throws SQLException när användare inte kan skapas i databas
   */
  public User createUser() throws SQLException {
    JFrame frame = new JFrame("Skapa ny användare");
    String username = "", name, password;

    // visa dialogfönster så länge man valt ok
    while ((JOptionPane.showConfirmDialog(
            frame,
            inputPanel,
            "Skapa användare",
            JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE)
        == JOptionPane.OK_OPTION)) {

      if (inputCorrect()) {
        username = textField.getText();
        password = new String(passField.getPassword(), 0, passField.getPassword().length);
        int userId = UserManager.createUser(username, password);

        return new RegularUser(userId, username);
      }
      showIncorrectInputMessage();
    }
    return null;
  }
Пример #17
0
  /**
   * Metoden kontrollerar så att användaren matat in uppgifter i varje fält. En annan funktionalitet
   * hos metoden är att den kontrollerar så att antalet tecken i textfälten för användarnamn,
   * lösenord, och telefonnummer inte överstiger 32 tecken. Metoden kontrollerar även så att
   * personnumret stämmer och att adressen inte är fler än 255 tecken.
   *
   * @return <br>
   *     <code>boolean true</code> = ifall samtliga fält är korrekt angivna <br>
   *     <code>boolean false</code> = ifall något fält inte är korrekt angivet
   */
  private boolean inputCorrect() {
    // hämta indata
    boolean res = true; // korrekt inmatning är default
    String inputSize = ""; // för att kontrollera antal tecken i textfält

    // kontrollerar varje fält, skulle ett fält vara ogiltigt blir res = false
    for (int i = 0; i < 2; i++) { // användarnamn + lösenord
      switch (i) {
        case 0: // användarnamn, namn, telefonnummer
          inputSize = textField.getText();
          // min 1 tecken, max = 32
          res = ((inputSize.length() >= 1) && (inputSize.length() <= 32));
          break;
        case 1: // lösenord
          inputSize = new String(passField.getPassword(), 0, passField.getPassword().length);
          // min 1 tecken, max 32
          res = ((inputSize.length() >= 1) && (inputSize.length() <= 32));
      }
      if (res == false) { // om ett fält är ogiltigt returnera resultatet
        return res; // ogiltig inmatning
      }
    }
    return res;
  }
Пример #18
0
  private void copyFile() throws Exception {
    // Load the JDBC driver
    Class.forName(((String) jcboDriver.getSelectedItem()).trim());
    System.out.println("Driver loaded");

    // Establish a connection
    Connection conn =
        DriverManager.getConnection(
            ((String) jcboURL.getSelectedItem()).trim(),
            jtfUsername.getText().trim(),
            String.valueOf(jtfPassword.getPassword()).trim());
    System.out.println("Database connected");

    // Read each line from the text file and insert it to the table
    insertRows(conn);
  }
Пример #19
0
  public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if ("SUBMIT".equals(cmd)) {

      username = user.getText();
      char[] input = password.getPassword();
      passwd = new String(input);

      // System.out.println("User is " + username + ", password is " + passwd  );
      info = new String[2];
      info[0] = username;
      info[1] = passwd;
      set = true;
      dispose();
    }
  }
Пример #20
0
  public static void LoginDialog() {

    JLabel title = new JLabel("Login Username and Password");
    JTextField username = new JTextField();
    JPasswordField password = new JPasswordField();
    final JComponent[] inputs =
        new JComponent[] {
          title, new JLabel("Username"), username, new JLabel("Password"), password
        };
    JOptionPane.showMessageDialog(null, inputs, "Login", JOptionPane.PLAIN_MESSAGE);

    userName = username.getText();
    passWord = new String(password.getPassword());
    if (!getLogin()) {
      LoginDialog();
    }
  }
Пример #21
0
  private void okActionPerformed(java.awt.event.ActionEvent evt) {
    if (smtp.getText().trim().isEmpty()) {
      CommonFunctions.showErrorMessage(this, "You must enter a SMTP server.");
      return;
    } else if (smtpUsername.getText().trim().isEmpty()) {
      CommonFunctions.showErrorMessage(this, "You must enter the SMTP username.");
      return;
    } else {
      try {
        int port = Integer.parseInt(smtpPort.getText());
        if (port <= 0) throw new NumberFormatException();

        new InternetAddress(email.getText()).validate();
      } catch (NumberFormatException e) {
        CommonFunctions.showErrorMessage(this, "You must enter a valid SMTP port.");
        return;
      } catch (AddressException e) {
        CommonFunctions.showErrorMessage(this, "You must enter a valid source email address.");
        return;
      }
    }

    retval = 0;

    List<Student> selectedStudents = new ArrayList();
    for (int i = 0; i < studentsTbl.getRowCount(); i++) {
      if ((boolean) studentsTbl.getValueAt(i, 0)) {
        selectedStudents.add(students.get(studentsTbl.convertRowIndexToModel(i)));
      }
    }

    output =
        new Object[] {
          email.getText(),
          smtp.getText(),
          smtpPort.getText(),
          smtpUsername.getText(),
          new String(smtpPassword.getPassword()),
          selectedStudents
        };

    setVisible(false);
  }
Пример #22
0
 @Override
 public void actionPerformed(ActionEvent evt) {
   progressBar.setVisible(true);
   btnNewButton_5.setEnabled(false);
   File dir = new File(inputFilePath);
   mailer =
       new Mailer(
           frame,
           evento,
           dir.getParent(),
           textFieldEmail.getText(),
           textFieldUsername.getText(),
           passwordField.getPassword(),
           textFieldSMTP.getText(),
           textFieldSMTPPort.getText());
   mailer.addPropertyChangeListener(this);
   mailer.execute();
   btnNewButton_5.setEnabled(true);
 }
  @Override
  public boolean isModified(@NotNull HttpConfigurable settings) {
    if (!isValid()) {
      return false;
    }

    return !Comparing.strEqual(myProxyExceptions.getText().trim(), settings.PROXY_EXCEPTIONS)
        || settings.USE_PROXY_PAC != myAutoDetectProxyRb.isSelected()
        || settings.USE_PAC_URL != myPacUrlCheckBox.isSelected()
        || !Comparing.strEqual(settings.PAC_URL, myPacUrlTextField.getText())
        || settings.USE_HTTP_PROXY != myUseHTTPProxyRb.isSelected()
        || settings.PROXY_AUTHENTICATION != myProxyAuthCheckBox.isSelected()
        || settings.KEEP_PROXY_PASSWORD != myRememberProxyPasswordCheckBox.isSelected()
        || settings.PROXY_TYPE_IS_SOCKS != mySocks.isSelected()
        || !Comparing.strEqual(settings.getProxyLogin(), myProxyLoginTextField.getText())
        || !Comparing.strEqual(
            settings.getPlainProxyPassword(), new String(myProxyPasswordTextField.getPassword()))
        || settings.PROXY_PORT != myProxyPortTextField.getNumber()
        || !Comparing.strEqual(settings.PROXY_HOST, myProxyHostTextField.getText());
  }
  /**
   * Parses the given http response.
   *
   * @param response the http response to parse
   * @return the new account
   */
  private NewAccount parseHttpResponse(String response) {
    NewAccount newAccount = null;
    try {
      JSONObject jsonObject = (JSONObject) JSONValue.parseWithException(response);
      boolean isSuccess = (Boolean) jsonObject.get("success");

      if (isSuccess) {
        newAccount =
            new NewAccount(
                (String) jsonObject.get("sip_address"),
                passField.getPassword(),
                null,
                (String) jsonObject.get("outbound_proxy"));

        String xcapRoot = (String) jsonObject.get("xcap_root");

        // as sip2sip adds @sip2sip.info at the end of the
        // xcap_uri but doesn't report it in resullt after
        // creating account, we add it
        String domain = null;
        int delimIndex = newAccount.getUserName().indexOf("@");
        if (delimIndex != -1) {
          domain = newAccount.getUserName().substring(delimIndex);
        }
        if (domain != null) {
          if (xcapRoot.endsWith("/"))
            xcapRoot = xcapRoot.substring(0, xcapRoot.length() - 1) + domain;
          else xcapRoot += domain;
        }

        newAccount.setXcapRoot(xcapRoot);
      } else {
        showErrorMessage((String) jsonObject.get("error_message"));
      }
    } catch (Throwable e1) {
      if (logger.isInfoEnabled()) logger.info("Failed Json parsing.", e1);
    }

    return newAccount;
  }
Пример #25
0
  /**
   * Handles the <tt>ActionEvent</tt> triggered when one of the buttons is clicked. When "Login"
   * button is chosen installs a new account from the user input and logs in.
   *
   * @param evt the action event that has just occurred.
   */
  public void actionPerformed(ActionEvent evt) {
    JButton button = (JButton) evt.getSource();
    String buttonName = button.getName();

    if ("ok".equals(buttonName)) {
      if (uinValue instanceof JLabel) userName = ((JLabel) uinValue).getText();
      else if (uinValue instanceof JTextField) userName = ((JTextField) uinValue).getText();

      password = passwdField.getPassword();
      isRememberPassword = rememberPassCheckBox.isSelected();
    } else {
      isCanceled = true;
    }

    // release the caller that opened the window
    buttonClicked = true;
    synchronized (lock) {
      lock.notify();
    }

    this.dispose();
  }
  public void apply() {
    HttpConfigurable httpConfigurable = myHttpConfigurable;
    if (isModified()) {
      httpConfigurable.AUTHENTICATION_CANCELLED = false;
    }
    httpConfigurable.USE_PROXY_PAC = myAutoDetectProxyRb.isSelected();
    httpConfigurable.USE_PAC_URL = myPacUrlCheckBox.isSelected();
    httpConfigurable.PAC_URL = trimFieldText(myPacUrlTextField);
    httpConfigurable.USE_HTTP_PROXY = myUseHTTPProxyRb.isSelected();
    httpConfigurable.PROXY_TYPE_IS_SOCKS = mySocks.isSelected();
    httpConfigurable.PROXY_AUTHENTICATION = myProxyAuthCheckBox.isSelected();
    httpConfigurable.KEEP_PROXY_PASSWORD = myRememberProxyPasswordCheckBox.isSelected();

    httpConfigurable.PROXY_LOGIN = trimFieldText(myProxyLoginTextField);
    httpConfigurable.setPlainProxyPassword(new String(myProxyPasswordTextField.getPassword()));
    httpConfigurable.PROXY_EXCEPTIONS = myProxyExceptions.getText();

    try {
      httpConfigurable.PROXY_PORT = Integer.valueOf(trimFieldText(myProxyPortTextField)).intValue();
    } catch (NumberFormatException e) {
      httpConfigurable.PROXY_PORT = 80;
    }
    httpConfigurable.PROXY_HOST = trimFieldText(myProxyHostTextField);
  }
  /**
   * Réagit au clique de la souris sur un bouton
   *
   * @param e L'ActionEvent généré
   */
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() instanceof JButton) {
      JButton b = (JButton) e.getSource();
      if (b.getName() == "statTab") { // Si on clique sur l'onglet statistiques
        cartes.show(panneau, "statistiques");
      } else if (b.getName() == "payTab") { // Si on clique sur l'onglet de paiement
        cartes.show(panneau, "paiement");
      } else if (b.getName() == "loginButton") { // Si on clique sur le bonton de login
        char[] input = passTextField.getPassword();
        String pass = new String("root"); // Le mot de passe
        if (pass.equals(new String(input))) {
          cartes.show(panneau, "paiement");
          loginLabel.setText("");
        } else loginLabel.setText("Mot de passe incorrect");

        Arrays.fill(input, '0');
        passTextField.selectAll();
      } else if (b.getName() == "annuler") { // Si clique sur annuler
        // On réserte la sélection et on déselectionne les tables
        ControleurTables.deleteSelection();
        this.tableCounter = 0;
        this.payTextField.setText("");
        this.valider.setEnabled(false);
        this.valider.setBackground(Color.GRAY);
      } else if (b.getName() == "valider") { // Si on clique sur valider

        // On récupère la date
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.SECOND, (int) this.difTemps);
        // On récupère le mode de paiement sélectionné
        String type = new String("carte bleue");
        if (especes.isSelected()) {
          type = "especes";
        } else if (cheque.isSelected()) {
          type = "cheque";
        }
        try { // On verifie que le prix rentré est correct
          // On met tout dans le meme try pour annuler l'insertion de la commande dans la bdd en cas
          // d'erreur
          float prix = Float.parseFloat(payTextField.getText());
          ModelePaiement mP = new ModelePaiement();
          mP.insert(cal, prix, type);
          // On recupère la selection
          ArrayList<Table> tab = ControleurTables.getSelection();
          // On met toutes les tables à laver
          for (int i = 0; i < tab.size(); i++) {
            tab.get(i).setStatut(Table.ALAVER);
            tab.get(i).setNom(null);
          }
          // On déselectionne les tables
          ControleurTables.deleteSelection();
          this.tableCounter = 0;
          this.payTextField.setText("");
          this.valider.setEnabled(false);
          this.valider.setBackground(Color.GRAY);
          // On insère le paiement dans la bdd
          modeleTable.updateTables(this.tables);
        } catch (NumberFormatException nfe) {
          JOptionPane.showMessageDialog(
              null, "Veuillez entrez un rpix valide.", "Erreur prix", JOptionPane.ERROR_MESSAGE);
        }
      } else if (b.getName() == "trier") { // Si on appuie sur trier
        float ca = -1;
        ModelePaiement mP = new ModelePaiement();
        if (service.isSelected()) { // Si on selection le chiffre d'affaire par service
          ca =
              mP.getCAService(
                  (String)
                      serviceComboBox
                          .getSelectedItem()); // On sélectonne le chiffre d'affaire en focntion du
                                               // service

        } else if (date.isSelected()) { // Si on selection le chiffre d'affaire par date
          try { // On verifie que la date est bien valide
            Calendar cal = Calendar.getInstance();
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            cal.setTime(sdf.parse(dateTextField.getText()));
            ca = mP.getCADate(cal); // On va chercher le chiffre d'affaire en fonction de la date
          } catch (Exception npe) {
            JOptionPane.showMessageDialog(
                null,
                "Veuillez entrez une date de la forme 03/06/2012.",
                "Erreur date",
                JOptionPane.ERROR_MESSAGE);
          }
        }

        if (ca > -1) { // Si on a récupérer un chiffre d'affaire
          chiffreAffaire.setText("Chiffre d'affaire : " + Float.toString(ca));
        }
      } else if (b.getName() == "option") { // Si on clique sur option
        String strDate =
            JOptionPane.showInputDialog(null, "Réglage de temps (ex: 03/06/1996 15:06) ", null);

        try {
          Calendar cal = Calendar.getInstance();
          Calendar now = Calendar.getInstance();

          SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
          cal.setTime(sdf.parse(strDate));
          difTemps =
              (int)
                  ((cal.getTimeInMillis() - now.getTimeInMillis())
                      / 1000); // Transformation en secondes
          if ((cal.getTimeInMillis() - now.getTimeInMillis()) % 1000 > 0) {
            difTemps++;
          }
        } catch (Exception exep) {
          JOptionPane.showMessageDialog(
              null,
              "Vous devez entrer une date valide (ex: 03/06/1996 15:06).",
              "Date invalide",
              JOptionPane.ERROR_MESSAGE);
        }
      }
    }
  }
 /**
  * Get the password that was entered into the dialog before the dialog was closed.
  *
  * @return the password from the password field.
  * @since ostermillerutils 1.00.00
  */
 public String getPass() {
   return new String(pass.getPassword());
 }
Пример #29
0
  /*
   * A "Bejelentkezés" gomb engedélyezését, illetve letíltását végző metódus
   */
  private void checkButton() {

    int u = tfUsername.getText().length();
    int p = pfPassword.getPassword().length;
    btLogin.setEnabled(u >= 3 && u <= 20 && p >= 6 && p <= 20);
  }
Пример #30
0
  @Override
  public void actionPerformed(ActionEvent e) {

    int tipo;
    int resultado;
    // Datos misDatos= new Datos(); //instanciar la clase Datos.
    boolean valido;
    UsuarioDtos misDatos = new UsuarioDtos();

    if (e.getSource() == btningresar) { // si clic al botón ingresar
      valido = validarCampos();
      if (valido) {
        resultado =
            misDatos.validarIngreso(txtusuario.getText(), new String(txtclave.getPassword()));
        tipo = misDatos.ValidarTipo();

        if (resultado == 0) {
          JOptionPane.showMessageDialog(null, "El Usuario Y La Contraseña Son Incorrectos");
        }

        if (resultado == 1) {
          JOptionPane.showMessageDialog(null, "Bienvenido al Sistema");
          if (tipo == 11) {
            dispose();
            frmMenuAdmin frmadmin = new frmMenuAdmin();
            frmadmin.setVisible(true);
          }
          if (tipo == 12) {
            dispose();
            frmRectoria frmrectora = new frmRectoria();
            frmrectora.setVisible(true);
          }
          if (tipo == 13) {
            dispose();
            frmSecretaria frmsecre = new frmSecretaria();
            frmsecre.setVisible(true);
          }
          if (tipo == 14) {
            dispose();
            frmCoordinador frmcordi = new frmCoordinador();
            frmcordi.setVisible(true);
          }
          if (tipo == 15) {
            dispose();
            frmDocentes frmdocente = new frmDocentes();
            frmdocente.setVisible(true);
          }
          if (tipo == 16) {
            dispose();
            frmAlumno frmalumno = new frmAlumno();
            frmalumno.setVisible(true);
          }
          if (tipo == 17) {
            JOptionPane.showMessageDialog(
                null, "Error En El Sistema, Por Favor Contacte A Un Administrador");
          }
        }

        if (resultado == 2) {
          JOptionPane.showMessageDialog(null, "El Usuario Es Incorrecto");
        }
        if (resultado == 3) {
          JOptionPane.showMessageDialog(null, "La Contraseña Es Incorrecta");
        }
      }
    } // cierra el condicional de btningresar

    // Programamos el botón de salir.
    if (e.getSource() == btnsalir) {
      dispose();
    }
  } // Cierra El ActionPerformed