private boolean checkInfo() {
   String temp = new String();
   boolean value = false;
   if (companyIDField.getText() == null || companyIDField.getText().isEmpty()) {
     temp += "Company Name \n";
     value = true;
   }
   if (groupUsernameField.getText() == null || groupUsernameField.getText().isEmpty()) {
     temp += "Username \n";
     value = true;
   }
   if (groupPasswordField.getText() == null || groupPasswordField.getText().isEmpty()) {
     temp += "Password \n";
     value = true;
   }
   if (groupSecurityQuestion.getText() == null || groupSecurityQuestion.getText().isEmpty()) {
     temp += "Security Question \n";
     value = true;
   }
   if (groupSecurityAnswer.getText() == null || groupSecurityAnswer.getText().isEmpty()) {
     temp += "Security Answer \n";
     value = true;
   }
   if (value) {
     errorStr = temp;
     return true;
   }
   return false;
 }
  /**
   * @param title Title, message
   * @param correct_password Password to check
   */
  public PasswordDialog(final String title, final String correct_password) {
    this.correct_password = correct_password;
    final DialogPane pane = getDialogPane();

    pass_entry.setPromptText(Messages.Password_Prompt);
    pass_entry.setMaxWidth(Double.MAX_VALUE);

    getDialogPane().setContent(pass_entry);

    setTitle(Messages.Password);
    setHeaderText(title);
    pane.getStyleClass().add("text-input-dialog");
    pane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

    // Check password in dialog?
    if (correct_password != null && correct_password.length() > 0) {
      final Button okButton = (Button) pane.lookupButton(ButtonType.OK);
      okButton.addEventFilter(
          ActionEvent.ACTION,
          event -> {
            if (!checkPassword()) event.consume();
          });
    }

    setResultConverter(
        (button) -> {
          return button.getButtonData() == ButtonData.OK_DONE ? pass_entry.getText() : null;
        });

    Platform.runLater(() -> pass_entry.requestFocus());
  }
Пример #3
0
  private void doRegister() {

    if (usernameField.getText().isEmpty()) {
      showConsoleText("username missing");
      return;
    }

    if (passwordField.getText().isEmpty()) {
      showConsoleText("password missing");
      return;
    }

    if (emailField.getText().isEmpty()) {
      showConsoleText("email missing");
      return;
    }

    if (userService.findByName(usernameField.getText()) != null) {
      showConsoleText("username taken");
      return;
    }

    userService.addUser(
        new User(usernameField.getText(), passwordField.getText(), emailField.getText()));

    if (userService.findByName(usernameField.getText()) == null) {
      showConsoleText("registration failed");
      return;
    }

    showLogin();
    showConsoleText("registration successful");
  }
 private boolean checkPassword() {
   final String password = pass_entry.getText();
   if (correct_password.equals(password)) return true;
   setHeaderText(Messages.Password_Error);
   Platform.runLater(() -> pass_entry.requestFocus());
   return false;
 }
  /**
   * Creates a new account (User)
   *
   * @param event
   * @throws IOException
   * @throws ClassNotFoundException
   * @throws SQLException
   */
  @FXML
  public void createAccount(ActionEvent event)
      throws IOException, ClassNotFoundException, SQLException {

    roles.setTextFill(Color.RED);
    wrongPass.setTextFill(Color.RED);
    duplicateID.setTextFill(Color.RED);

    if (super.loadShell() != null) {
      Shell loadShell = loadShell();
      shl.setEmployees(loadShell.getEmployees());
      shl.setManagers(loadShell.getManagers());
      shl.setTabs(loadShell.getTabs());
      shl.setUsers(loadShell.getUsers());
    }

    loadLog();

    if (!user.getText().equals("")
        && !password.getText().equals("")
        && !passconf.getText().equals("")
        && !name.getText().equals("")
        && !post.getText().equals("")) {

      if (shl.findUser(user.getText()) != null) {
        user.getStyleClass().add("error");
        duplicateID.setVisible(true);

        System.out.printf(
            "[SHELL] User %s exists as %s %s\n ",
            user.getText(), shl.findUser(user.getText()), shl.findUser(user.getText()));
      } else if (password.getText().equals(passconf.getText())) {
        shl.createUser(user.getText(), password.getText(), post.getText(), name.getText());

        System.out.printf("Created User %s\n", user.getText());

        user.getStyleClass().remove("error");
        password.getStyleClass().remove("error");
        passconf.getStyleClass().remove("error");
        roles.setVisible(false);
        duplicateID.setVisible(false);
        wrongPass.setVisible(false);

        super.saveShell();
        super.saveLog("USER " + user.getText() + " - " + name.getText() + " HAS BEEN CREATED");

        goToScreen1(event);

      } else {
        System.out.println("[SHELL] User creation failed - Passwords don't match");

        password.getStyleClass().add("error");
        passconf.getStyleClass().add("error");
        wrongPass.setVisible(true);
      }

    } else System.out.println("[SHELL] User creation failed - Missing fields");
  }
Пример #6
0
  private static void setButtonsActions() {
    sign_in_button.setOnAction(
        event -> {
          try {
            if ((username.getText().length() > 3) && (password.getText().length() > 3)) {
              UserData.saveData();
              UserCommands.authorization();
              synchronized (ThreadStorage.getInterfaceLauncher()) {
                ThreadStorage.getInterfaceLauncher().wait();
              }
              if (UserData.authorized) {
                loginForm.close();
                MainProgram.getMainProgram().launchForm();
              }
            } else {
              error_message_field.setText("Too short username or password");
            }
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
        });

    register_button.setOnAction(
        event -> {
          try {
            if ((username.getText().length() > 3) && (password.getText().length() > 3)) {
              UserData.saveData();
              UserCommands.user_exists();
              synchronized (ThreadStorage.getInterfaceLauncher()) {
                ThreadStorage.getInterfaceLauncher().wait();
              }
              if (!user_exists) {
                CategoryForm.launchForm();
                UserCommands.register();
                synchronized (ThreadStorage.getInterfaceLauncher()) {
                  ThreadStorage.getInterfaceLauncher().wait();
                }
                if (UserData.authorized) {
                  LoginForm.closeForm();
                  MainProgram.getMainProgram().launchForm();
                }
              } else {
                error_message_field.setText("Username is already existed");
              }
            } else {
              error_message_field.setText("Too short username or password");
            }
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
        });
  }
  public void Login() throws IOException {

    // TODO set username og password til en string istedet for at hent dem på den måde

    // if username field is empty = error message
    if (usernameText.getText().equals("")) {

      passwordErrorLbl.setVisible(false);
      usernameErrorLbl.setVisible(true);

      loginErrorLbl.setVisible(false);
    }
    // if passwordfield is empty = error message
    if (passwordText.getText().equals("")) {

      usernameErrorLbl.setVisible(false);
      passwordErrorLbl.setVisible(true);

      loginErrorLbl.setVisible(false);
    }

    if (passwordText.getText().equals("") && usernameText.getText().equals("")) {

      usernameErrorLbl.setVisible(true);
      passwordErrorLbl.setVisible(true);

      loginErrorLbl.setVisible(false);
    }

    if (logic.userAuth(usernameText.getText(), passwordText.getText())) {

      usernameErrorLbl.setVisible(false);
      passwordErrorLbl.setVisible(false);
      loginErrorLbl.setVisible(false);

      usernameText.clear();
      passwordText.clear();

      // TODO get menu to display currentuser

      myController.setScreen(Main.screenMenuID);

    } else {

      usernameErrorLbl.setVisible(false);
      passwordErrorLbl.setVisible(false);

      loginErrorLbl.setVisible(true);
    }
  }
Пример #8
0
  public void sendRequest(String username, String password) {

    thisStage = (Stage) logInButton.getScene().getWindow();
    Response res =
        new Request("user/login").set("username", username).set("password", password).send();

    if (res.getSuccess()) {
      Main.setSessionID((String) res.get("sessionID"));
      System.out.println("Login successful.");
      Main.userNotLoggedIn.setValue(false);

      // Save the login option if checked
      if (keepMeLoggedInCheckBox.isSelected()) {
        pc.setProp("username", usernameTextField.getText());
        pc.setProp("password", passwordPasswordField.getText());
        pc.setProp("signInCheckbox", "true");
        pc.saveProps();
      }

      HomeController.userName = usernameTextField.getText();
      thisStage.close();
    } else {
      // incorrect password
    }
  }
 private TextInputControl createPasswordbox(
     de.akubix.keyminder.core.ApplicationInstance instance, boolean init) {
   PasswordField t = new PasswordField();
   if (!init) {
     t.setText(getUIValue());
   }
   t.addEventFilter(
       KeyEvent.KEY_RELEASED,
       new EventHandler<KeyEvent>() {
         @Override
         public void handle(KeyEvent event) {
           storeData(instance.getTree().getSelectedNode());
         }
       });
   return t;
 }
Пример #10
0
  /**
   * Login button event, 1) IF:- checks if nothing is null 2) IF:- Admin/Client, checks valid login
   * 3) IF:- Update Date access and process to home page
   *
   * @param ae
   */
  @FXML
  public void loginBtn(ActionEvent ae) {
    if (DropDownvalue != null && userName != null && password != null) {

      String userNameText = userName.getText().trim();
      String passwordText = password.getText().trim();

      if (DropDownvalue.equals("Admin")) {

        boolean check = new Model().getLogin("a", userNameText, passwordText);
        if (check) {
          boolean b = new Model().updateDateLogin("a", userNameText, passwordText);
          if (b) {
            new ChangeFxml().swap("/design/HomeAdmin.fxml");
          } else {
            ResetBtnClick(ae);
            userName.setPromptText("Invalid! Email");
            password.setPromptText("Invalid! Password");
          }

        } else {
          ResetBtnClick(ae);
          userName.setPromptText("Invalid! Email");
          password.setPromptText("Invalid! Password");
        }

      } else {
        boolean check = new Model().getLogin("u", userNameText, passwordText);
        if (check) {
          boolean b = new Model().updateDateLogin("u", userNameText, passwordText);
          if (b) {
            new ChangeFxml().swap("/design/Home.fxml");
          } else {
            ResetBtnClick(ae);
            userName.setPromptText("Something went wrong!");
            password.setPromptText("Invalid!");
          }

        } else {
          ResetBtnClick(ae);
          userName.setPromptText("Invalid!");
          password.setPromptText("Invalid!");
        }
      }
    }
  }
Пример #11
0
  @FXML
  private void onLogInButtonClick(ActionEvent event) {

    String username = usernameTextField.getText();
    String password = passwordPasswordField.getText();

    sendRequest(username, password);
  }
  @FXML
  public void setPasswordClicked(ActionEvent event) {
    if (!pass1.getText().equals(pass2.getText())) {
      informationalAlert(tr("Passwords do not match"), tr("Try re-typing your chosen passwords."));
      return;
    }
    String password = pass1.getText();
    // This is kind of arbitrary and we could do much more to help people pick strong passwords.
    if (password.length() < 4) {
      informationalAlert(
          tr("Password too short"),
          tr("You need to pick a password at least five characters or longer."));
      return;
    }

    fadeIn(progressMeter);
    fadeOut(widgetGrid);
    fadeOut(explanationLabel);
    fadeOut(buttonHBox);

    KeyCrypterScrypt scrypt = new KeyCrypterScrypt(SCRYPT_PARAMETERS);

    // Deriving the actual key runs on a background thread. 500msec is empirical on my laptop
    // (actual val is more like 333 but we give padding time).
    KeyDerivationTasks tasks =
        new KeyDerivationTasks(scrypt, password, estimatedKeyDerivationTime) {
          @Override
          protected void onFinish(KeyParameter aesKey, int timeTakenMsec) {
            // Write the target time to the wallet so we can make the progress bar work when
            // entering the password.
            WalletPasswordController.setTargetTime(Duration.ofMillis(timeTakenMsec));
            // The actual encryption part doesn't take very long as most private keys are derived on
            // demand.
            log.info("Key derived, now encrypting");
            Main.bitcoin.wallet().encrypt(scrypt, aesKey);
            log.info("Encryption done");
            informationalAlert(
                tr("Wallet encrypted"),
                tr("You can remove the password at any time from the settings screen."));
            overlayUI.done();
          }
        };
    progressMeter.progressProperty().bind(tasks.progress);
    tasks.start();
  }
Пример #13
0
 @FXML
 protected void handleSubmitButtonAction(ActionEvent event) {
   db.Connect();
   boolean test = db.userExist(username.getText().toString());
   if (test) {
     System.out.println("User Exists");
     test = db.checkPassword(username.getText().toString(), password.getText().toString());
     if (test) {
       // if username and password is correct program moves to main screen
       System.out.println("Password is correct");
       myController.setScreen(WellCheck.screenID2);
       db.patientTable();
     }
   }
   username.clear();
   password.clear();
   System.out.println(username.getText().toString());
 }
Пример #14
0
  private Condomino condominoConsulta() {
    String senha = tfSenha.getText();

    Condomino c = new Condomino();
    c.setLogin(tfLogin.getText());
    c.setSenha(senha);

    return c;
  }
Пример #15
0
 private void getuserinfo(String name) throws IOException {
   ToServer.writeUTF("iserinfo");
   ToServer.writeUTF(name);
   txaddname.setText(FromServer.readUTF());
   txaddpass.setText(FromServer.readUTF());
   txgroupname.setText(FromServer.readUTF());
   if (FromServer.readUTF().equals("1")) cboxadmin.setSelected(true);
   else cboxadmin.setSelected(false);
 }
Пример #16
0
 private synchronized void checkAccount(Account account) {
   if (account != null) {
     textFieldFirstname.setText(account.getFirstName());
     textFieldLastname.setText(account.getLastName());
     textFieldUser.setText(account.getUsername());
     passwordField.setText(account.getPassword());
     if (account.getRfidKey() != null) textFieldRfid.setText(account.getRfidKey().getId());
   }
 }
Пример #17
0
 /** Method validate calls when LoginButton was clicked. */
 public void validate(ActionEvent event) throws IOException {
   String username = userField.getText();
   String userPassword = passwordBox.getText();
   if (username.equals("user") && userPassword.equals("user")) {
     labelInfo.setText("valid");
     loadTableScene();
   } else {
     labelInfo.setText("Username/Password is incorrect");
   }
 }
 @FXML
 void adminLoginAction(ActionEvent event) {
   if (adminUserID.getText().equals(validUserID)
       && adminPassword.getText().equals(validPassword)) {
     try {
       main.AdminEdit();
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
Пример #19
0
  private void doLogin() {

    if (usernameField.getText().isEmpty()) {
      showConsoleText("username missing");
      return;
    }

    if (passwordField.getText().isEmpty()) {
      showConsoleText("password missing");
      return;
    }

    if (!userService.authenticate(usernameField.getText(), passwordField.getText())) {
      showConsoleText("authentication failed");
      return;
    }

    showConsoleText("login accepted");
    Navigation.getInstance().loadScreen(MainController.getName());
  }
Пример #20
0
 public Account getUpdatedAccount(Account account) {
   account.setFirstName(textFieldFirstname.getText());
   account.setLastName(textFieldLastname.getText());
   account.setUsername(textFieldUser.getText());
   RfidKey key = new RfidKey(textFieldRfid.getText());
   // key.setEnabled(true);
   account.setRfidKey(key);
   account.setPassword(passwordField.getText());
   account.setAuthorities(AuthorityUtils.createAuthorityList(AuthoritiesConstants.USER));
   System.out.println(account.toString());
   return account;
 }
  public AddEditCredentialView(Credential credential) {
    super();
    Label domainLabel = new Label("Domain:");
    domainText = new TextField();
    domainText.setPrefWidth(250);
    domainText.setText(credential != null ? credential.getDomainName() : "");
    domainText.setPromptText("Domain");
    Platform.runLater(domainText::requestFocus);

    Label usernameLabel = new Label("Username:"******"");
    usernameText.setPromptText("Username");

    Label passwordLabel = new Label("Password:"******"");
    passwordText.setPromptText("Password");

    setHgap(10);
    setVgap(10);

    setPadding(new Insets(8, 8, 8, 8));

    add(domainLabel, 0, 0);
    add(domainText, 1, 0);
    add(usernameLabel, 0, 1);
    add(usernameText, 1, 1);
    add(passwordLabel, 0, 2);
    add(passwordText, 1, 2);
    GridPane.setHgrow(domainText, Priority.ALWAYS);
    GridPane.setHgrow(usernameText, Priority.ALWAYS);
    GridPane.setHgrow(passwordText, Priority.ALWAYS);
  }
Пример #22
0
  public MyDialog(Stage owner) {
    super();
    initOwner(owner);
    setTitle("title");
    initModality(Modality.APPLICATION_MODAL);
    Group root = new Group();
    Scene scene = new Scene(root, 250, 150, Color.WHITE);
    setScene(scene);

    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(5);
    gridpane.setVgap(5);

    Label userNameLbl = new Label("User Name: ");
    gridpane.add(userNameLbl, 0, 1);

    Label passwordLbl = new Label("Password: "******"Admin");
    gridpane.add(userNameFld, 1, 1);

    final PasswordField passwordFld = new PasswordField();
    passwordFld.setText("password");
    gridpane.add(passwordFld, 1, 2);

    Button login = new Button("Change");
    login.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            close();
          }
        });
    gridpane.add(login, 1, 3);
    GridPane.setHalignment(login, HPos.RIGHT);
    root.getChildren().add(gridpane);
  }
  public void aboutToShow() {
    syncUserName.setText("");
    password.setText("");
    fullNameUnique.setText("");
    fullName.setText("");
    userName.setText("");
    workflowUserName.setText("");
    uuid.setText("");
    roles.getSelectionModel().clearSelection();
    roles.getSelectionModel().select(RoleOption.USER.name());

    Platform.runLater(() -> fullNameUnique.requestFocus());
  }
Пример #24
0
  @FXML
  public void login(ActionEvent e) throws SQLException {
    if (cl.checkCredenzialiClienti(user.getText(), pass.getText())) {
      username =
          user
              .getText(); // salva l'informazione dell'username da passare all'interfaccia cliente o
                          // operatore
      // setta le informazioni nelle finestre username e operatore
      nome = cl.read(user.getText()).getNome();
      cognome = cl.read(user.getText()).getCognomeCliente();
      FrontController.getIstance().setAutenticato();
      FrontController.getIstance().dispatchRequest("FinestraClienti");
    } else if (ag.checkcredenziali(user.getText(), pass.getText())) {
      FrontController.getIstance().setAutenticato();
      try {
        setDataAgente();
        // Caricamento nuova finestra e chiusura finestra login
        FrontController.getIstance().dispatchRequest("FinestraOperatore");
        Stage stage = (Stage) exit_btn.getScene().getWindow();
        stage.close();
      } catch (Exception e1) {
        e1.printStackTrace();
      }
    } else if (user.getText().equals("capone") && pass.getText().equalsIgnoreCase("capone")) {
      FrontController.getIstance().setAutenticato();
      try {
        FrontController.getIstance().dispatchRequest("FinestraAmministrazione");
        Stage stage = (Stage) exit_btn.getScene().getWindow();
        stage.close();

      } catch (Exception e1) {
        e1.printStackTrace();
      }
    } else {
      Popup.Errore("Credenziali errate", "Hai inserito credenziali sbagliate.");
    }
  }
Пример #25
0
  @Override
  public void initialize(URL location, ResourceBundle resources) {
    // Perform any initialization steps here.
    pc = PropertiesController.getPropertiesController();
    usernameTextField.setText(pc.getProp("username"));
    passwordPasswordField.setText(pc.getProp("password"));

    String signIn = pc.getProp("signInCheckbox");
    if (signIn == null) {
      signIn = "";
    }
    if (signIn.equals("true")) {
      keepMeLoggedInCheckBox.setSelected(true);
    }
  }
  @FXML
  void loginAction() {
    try {
      credenciais.setLogin(textLogin.getText());
      credenciais.setSenha(textPassword.getText());
      securityContext.login();

      if (securityContext.isLoggedIn()) {
        buttonLogin.getScene().getWindow().hide();
      } else {
        errorMessage.setText(resources.getString("login.errorMessage"));
        showMessageError();
      }
    } catch (Exception exception) {
      ExceptionUtils.throwCustomerException(exception, false);
    }
  }
 private void saveData() throws IOException {
   Files.createDirectory(Paths.get(groupDir));
   File companyName = new File(groupDir + "\\CompanyName.txt");
   PrintWriter companyWriter = new PrintWriter(companyName);
   companyWriter.print(companyIDField.getText());
   companyWriter.close();
   File password = new File(groupDir + "\\GroupPassword.txt");
   PrintWriter passwordWriter = new PrintWriter(password);
   passwordWriter.print(groupPasswordField.getText());
   passwordWriter.close();
   File securityQ = new File(groupDir + "\\GroupSecurityQuestion.txt");
   PrintWriter securityQWriter = new PrintWriter(securityQ);
   securityQWriter.print(groupSecurityQuestion.getText());
   securityQWriter.close();
   File securityA = new File(groupDir + "\\GroupSecurityAnswer.txt");
   PrintWriter securityAWriter = new PrintWriter(securityA);
   securityAWriter.print(groupSecurityAnswer.getText());
   securityAWriter.close();
 }
  @FXML
  private void btn_sendOnAction() throws IOException {
    boolean mailSuccess = false;
    String errorMessage = "";
    try {

      Mailer.send(
          tf_login.getText(),
          pf_password.getText(),
          tf_emailFrom.getText(),
          tf_emailTo.getText(),
          tf_subject.getText(),
          ta_message.getText());

      mailSuccess = true;
    } catch (MessagingException e) {
      errorMessage = e.getMessage();
    }

    new SendingMailStage(mailSuccess, errorMessage);
  }
  @FXML
  void initialize() {
    assert syncUserName != null
        : "fx:id=\"syncUserName\" was not injected: check your FXML file 'AddUser.fxml'.";
    assert cancelButton != null
        : "fx:id=\"cancelButton\" was not injected: check your FXML file 'AddUser.fxml'.";
    assert password != null
        : "fx:id=\"password\" was not injected: check your FXML file 'AddUser.fxml'.";
    assert fullNameUnique != null
        : "fx:id=\"fullNameUnique\" was not injected: check your FXML file 'AddUser.fxml'.";
    assert roles != null : "fx:id=\"roles\" was not injected: check your FXML file 'AddUser.fxml'.";
    assert layoutPane != null
        : "fx:id=\"layoutPane\" was not injected: check your FXML file 'AddUser.fxml'.";
    assert fullName != null
        : "fx:id=\"fullName\" was not injected: check your FXML file 'AddUser.fxml'.";
    assert okButton != null
        : "fx:id=\"okButton\" was not injected: check your FXML file 'AddUser.fxml'.";
    assert userName != null
        : "fx:id=\"userName\" was not injected: check your FXML file 'AddUser.fxml'.";
    assert workflowUserName != null
        : "fx:id=\"workflowUserName\" was not injected: check your FXML file 'AddUser.fxml'.";
    assert uuid != null : "fx:id=\"uuid\" was not injected: check your FXML file 'AddUser.fxml'.";

    for (RoleOption ro : RoleOption.values()) {
      roles.getItems().add(ro.value());
    }

    upm_ = AppContext.getService(UserProfileManager.class);

    uuidValid_ =
        new ValidBooleanBinding() {
          {
            bind(uuid.textProperty());
          }

          @Override
          protected boolean computeValue() {
            if (uuid.getText().length() == 0 || Utility.isUUID(uuid.getText())) {
              if (uuid.getText().length() > 0
                  && AppContext.getService(TerminologyStoreDI.class)
                      .hasUuid(UUID.fromString(uuid.getText()))) {
                setInvalidReason("If a UUID is specified, it must be unique");
                return false;
              } else {
                clearInvalidReason();
                return true;
              }
            } else {
              setInvalidReason("Invalid uuid");
              return false;
            }
          }
        };

    ErrorMarkerUtils.setupErrorMarkerAndSwap(uuid, layoutPane, uuidValid_);

    userNameValid_ =
        new ValidBooleanBinding() {
          {
            bind(userName.textProperty());
          }

          @Override
          protected boolean computeValue() {
            if (userName.getText().length() > 0 && !upm_.doesProfileExist(userName.getText())) {
              clearInvalidReason();
              return true;
            } else {
              setInvalidReason("The user name is required, and must be unique");
              return false;
            }
          }
        };

    ErrorMarkerUtils.setupErrorMarkerAndSwap(userName, layoutPane, userNameValid_);

    fullNameUniqueValid_ =
        new ValidBooleanBinding() {
          {
            bind(fullNameUnique.textProperty(), uuid.textProperty());
          }

          @Override
          protected boolean computeValue() {
            if (fullNameUnique.getText().length() > 0) {
              UUID userUuid;
              if (uuid.getText().length() > 0) {
                if (uuidValid_.get()) {
                  userUuid = UUID.fromString(uuid.getText());
                } else {
                  setInvalidReason("If a UUID is specified, it must be valid.");
                  return false;
                }
              } else {
                userUuid = GenerateUsers.calculateUserUUID(fullNameUnique.getText());
              }

              if (AppContext.getService(TerminologyStoreDI.class).hasUuid(userUuid)) {
                setInvalidReason("The full name must be unique");
                return false;
              } else {
                clearInvalidReason();
                return true;
              }
            } else {
              setInvalidReason(
                  "The Full Name is required, and must be unique.  If a UUID is specified, it must be valid, and unique");
              return false;
            }
          }
        };

    ErrorMarkerUtils.setupErrorMarkerAndSwap(fullNameUnique, layoutPane, fullNameUniqueValid_);

    okButton.disableProperty().bind(fullNameUniqueValid_.and(userNameValid_).and(uuidValid_).not());

    cancelButton.setCancelButton(true);
    // JavaFX is silly:  https://javafx-jira.kenai.com/browse/RT-39145#comment-434189
    cancelButton.setOnKeyPressed(
        new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent event) {
            if (event.getCode() == KeyCode.ENTER) {
              event.consume();
              cancelButton.fire();
            }
          }
        });
    cancelButton.setOnAction(
        (event) -> {
          layoutPane.getScene().getWindow().hide();
        });

    okButton.setDefaultButton(true);
    okButton.setOnAction(
        (event) -> {
          try {
            User u = new User();
            u.setFullName(fullName.getText());
            u.setPassword(password.getText());
            u.setSyncUserName(syncUserName.getText());
            u.setWorkflowUserName(workflowUserName.getText());
            u.setUniqueFullName(fullNameUnique.getText());
            u.setUniqueLogonName(userName.getText());
            u.setUUID(uuid.getText());
            for (String roleName : roles.getSelectionModel().getSelectedItems()) {
              u.getRoles().add(RoleOption.fromValue(roleName));
            }
            upm_.createNewUser(u);
            layoutPane.getScene().getWindow().hide();
          } catch (Exception e) {
            logger.error("Error creating user", e);
            AppContext.getCommonDialogs().showErrorDialog("Unexpected error adding user", e);
          }
        });
  }
Пример #30
0
 /**
  * Reset Btn Event Reset all the field
  *
  * @param ae
  */
 @FXML
 public void ResetBtnClick(ActionEvent ae) {
   password.setText("");
   userName.setText("");
   dropDown.getSelectionModel().clearSelection();
 }