Beispiel #1
0
  private com.vaadin.ui.Component buildFields() {
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.addStyleName("fields");

    final TextField username = new TextField("Username");
    username.setIcon(FontAwesome.USER);
    username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final PasswordField password = new PasswordField("Password");
    password.setIcon(FontAwesome.LOCK);
    password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final Button signin = new Button("Sign In");
    signin.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signin.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    signin.focus();

    fields.addComponents(username, password, signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    signin.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(final Button.ClickEvent event) {
            DashboardEventBus.post(
                new UserLoginRequestedEvent(username.getValue(), password.getValue()));
          }
        });
    return fields;
  }
Beispiel #2
0
  public UserSelect() {
    loginInfo = new Label("");
    loginInfo.addStyleName("error-font");
    loginInfo.addStyleName("margin15");
    loginInfo.addStyleName("margin-top40");
    loginInfo.setVisible(false);
    selected = null;
    loginField = new PasswordField("");
    loginField.setWidth("200px");
    loginField.addStyleName("margin15");
    loginField.addStyleName("margin-bot40");
    loginBut = new Button("login");
    loginBut.addStyleName("margin15");
    loginBut.addClickListener(
        e -> {
          if (loginField.getValue().equals(selected.getPassword())) {
            hidePass();
            Globals.user = selected;
            Globals.root.changeScreen(Globals.user);
          } else {
            loginInfo.setVisible(true);
            loginInfo.setValue("Wrong password");
            loginField.setValue("");
          }
        });

    loginBox = new HorizontalLayout();
    loginBox.addStyleName("popup-box");
    loginBox.addComponents(loginField, loginBut, loginInfo);
    loginBox.setComponentAlignment(loginField, Alignment.MIDDLE_LEFT);
    loginBox.setComponentAlignment(loginBut, Alignment.MIDDLE_CENTER);
    loginBox.setComponentAlignment(loginField, Alignment.MIDDLE_RIGHT);
    loginBox.setVisible(false);
    userIcon = new ThemeResource("icons/user.png");
    users = Globals.control.usersData();
    vbox = new VerticalLayout();
    // vbox.setSizeUndefined();
    vbox.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    Panel p = new Panel();
    p.setSizeFull();

    p.setContent(vbox);
    // vbox.addStyleName("border-l-r");
    this.addComponent(p, "left: 25%; right: 25%; top: 15px");
    this.addComponent(loginBox, "left: 25%; right: 25%; top: 40%");

    this.addLayoutClickListener(
        e -> {
          if (!loginBox.isVisible()) return;
          System.out.println(e.getClickedComponent());
          if (e.getClickedComponent() == null || e.getClickedComponent().equals(vbox)) hidePass();
        });
  }
Beispiel #3
0
 private Button genBut(String name) {
   Button b = new Button(name);
   b.addStyleName("user-select");
   b.setIcon(userIcon);
   b.addClickListener(
       e -> {
         if (loginBox.isVisible()) {
           hidePass();
           return;
         }
         loginField.setValue("");
         String t = e.getButton().getCaption();
         if (Globals.control.hasPassword(t)) {
           selected = Globals.control.getUser(t);
           showPassField();
         } else {
           User s = Globals.control.getUser(t);
           if (s == null) {
             return;
           }
           Globals.user = s;
           Globals.root.changeScreen(Globals.user);
         }
       });
   return b;
 }
  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
    }
  }
  @FXML
  private void onLogInButtonClick(ActionEvent event) {

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

    sendRequest(username, password);
  }
 static void openDB() {
   System.out.println("Username: "******"Password: "******":");
   User u = new User(usernameSQL, passwordSQL.toCharArray());
   flags.openDatabase(u);
 }
  @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();
  }
  public LoginModule() {

    setMargin(true);
    setSpacing(true);
    grid.setSizeFull();
    grid.setSpacing(true);

    final TextField username = new TextField();
    username.setValue("username");
    username.setWidth("120px");
    username.setStyleName("small");
    grid.addComponent(username, 0, 0);

    final PasswordField password = new PasswordField();
    password.setValue("password");
    password.setWidth("120px");
    password.setStyleName("small");
    grid.addComponent(password, 0, 1);

    Button button = new Button("Login");
    button.setWidth("120px");
    button.setStyleName("small");
    button.addListener(
        new Button.ClickListener() {

          @Override
          public void buttonClick(ClickEvent event) {
            login.setUsername(username.getValue().toString());
            login.setPassword(password.getValue().toString());
            String user = login.getUsername();
            String pass = login.getPassword();
            // login.setResult(authLog.login(user, pass));
            boolean result = authLog.login(user, pass);
            if (result == true) {
              label.setCaption("Successfully Login");
            } else {
              label.setCaption("SQL Error");
            }
          }
        });
    grid.addComponent(button, 0, 2);
    panel.addComponent(grid);
    addComponent(panel);
    addComponent(label);
  }
  private void LoginBttnMouseClicked(java.awt.event.MouseEvent evt) {
    // TODO add your handling code here:
    String username = "******";
    String password = "******";
    String username1 = this.LoginField.getText();
    String password2 = this.PasswordField.getText();

    if ((username1.equals(username)) && (password2.equals(password))) {
      MainScreen w2 = new MainScreen();
      w2.setVisible(true);
      LoginField.setText("");
      PasswordField.setText("");
    } else {
      LoginField.setText("");
      PasswordField.setText("");
      JOptionPane.showMessageDialog(null, "Login Fail. Try again.");
    }

    // if login is correct, go to next screen
    // if login is incorrect, clear fields and retry
  }
  @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);
    }
  }
 private void login() {
     try {
         final Authentication authentication = vaadinSecurity.login(userName.getValue(), passwordField.getValue());
         eventBus.publish(this, new SuccessfulLoginEvent(getUI(), authentication));
     } catch (AuthenticationException ex) {
         userName.focus();
         userName.selectAll();
         passwordField.setValue("");
         loginFailedLabel.setValue(String.format("Login failed: %s", ex.getMessage()));
         loginFailedLabel.setVisible(true);
     } catch (Exception ex) {
         Notification.show("An unexpected error occurred", ex.getMessage(), Notification.Type.ERROR_MESSAGE);
         LoggerFactory.getLogger(getClass()).error("Unexpected error while logging in", ex);
     } finally {
         login.setEnabled(true);
     }
 }
Beispiel #12
0
 private void hidePass() {
   loginBox.setVisible(false);
   loginInfo.setVisible(false);
   loginField.setValue("");
   vbox.removeStyleName("fuzzy");
 }
Beispiel #13
0
  private void ConfirmButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_ConfirmButtonActionPerformed

    String username = UsernameField.getText();
    char[] password = PasswordField.getPassword();
    char[] passwordConfirm = ConfirmPasswordField.getPassword();
    String email = EmailField.getText();
    String emailConfirm = ConfirmEmailField.getText();
    String pass = new String(password);
    String pConfirm = new String(passwordConfirm);
    MD5Pwd enc = new MD5Pwd();
    String passEnc;

    xEmail.setVisible(false);
    xName.setVisible(false);
    xPassword.setVisible(false);

    passEnc = enc.encode(username, pass);

    if (ValidateMail.isValidEmailAddress(email)) {

      if (email.equals(emailConfirm)) {

        if (!"".equals(username)) {

          if (pass.equals(pConfirm) && (!"".equals(pass))) {

            try {
              ComCliente com = ComCliente.getInstance();
              com.registar(username, passEnc, email);
              this.ConfirmButton.setEnabled(false);

            } catch (Exception e) {
              System.out.println("Accept failed: 4444");
              System.exit(-1);
            }

          } else {

            this.ErrorLabel.setText(
                java.util.ResourceBundle.getBundle(Lang).getString("PasswordConfirmError"));
            this.xPassword.setVisible(true);
            this.PasswordField.setText("");
            this.ConfirmPasswordField.setText("");
          }

        } else {
          this.ErrorLabel.setText(
              java.util.ResourceBundle.getBundle(Lang).getString("InsertUsername"));
          this.xName.setVisible(true);
        }
      } else {

        this.ErrorLabel.setText(
            java.util.ResourceBundle.getBundle(Lang).getString("EmailConfirmationError"));
        this.EmailField.setText("");
        this.ConfirmEmailField.setText("");
        this.xEmail.setVisible(true);
      }
    } else {
      this.ErrorLabel.setText(java.util.ResourceBundle.getBundle(Lang).getString("InvalidEmail"));
      this.EmailField.setText("");
      this.ConfirmEmailField.setText("");
      this.xEmail.setVisible(true);
    }
  } // GEN-LAST:event_ConfirmButtonActionPerformed
Beispiel #14
0
  /**
   * Main method which is in charge of parsing and interpreting user input and interacting with the
   * FTP client.
   *
   * @param args Command line arguments; should only contain the server
   */
  public static void main(String args[]) {
    boolean eof = false;
    String input = null;
    Scanner in = new Scanner(System.in);

    if (args.length != 1) {
      System.err.println("Usage: java Ftp <server>");
      System.exit(1);
    }

    /* Create a new FTP client */
    Ftp client = new Ftp(args[0]);

    do {
      try {
        System.out.print(prompt);
        input = in.nextLine();
      } catch (NoSuchElementException e) {
        eof = true;
      }

      /* Keep going if we have not hit end of file */
      if (!eof && input.length() > 0) {
        int cmd = -1;
        String argv[] = input.split("\\s+");

        for (int i = 0; i < commands.length && cmd == -1; i++)
          if (commands[i].equalsIgnoreCase(argv[0])) cmd = i;

        /* Execute the command */
        switch (cmd) {
          case ASCII:
            client.ascii();
            break;
          case BINARY:
            client.binary();
            break;
          case CD:
            client.cd(argv[1]);
            break;
          case CDUP:
            client.cdup();
            break;
          case DEBUG:
            client.toggleDebug();
            break;
          case DIR:
            client.dir();
            break;
          case GET:
            client.get(argv[1]);
            break;
          case HELP:
            for (int i = 0; i < HELP_MESSAGE.length; i++) System.out.println(HELP_MESSAGE[i]);
            break;
          case PASSIVE:
            client.pasv();
            break;
          case PWD:
            client.pwd();
            break;
          case QUIT:
            eof = true;
            break;
          case USER:
            client.user(argv[1]);
            String password = PasswordField.getPassword("Password:  "******"Invalid command");
        }
      }
    } while (!eof);

    /* Clean up */
    client.close();
  }
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">
  private void initComponents() {

    jPanel1 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jPanel3 = new javax.swing.JPanel();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    LoginField = new javax.swing.JTextField();
    LoginBttn = new javax.swing.JButton();
    PasswordField = new javax.swing.JPasswordField();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setBackground(new java.awt.Color(255, 204, 204));
    setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

    jLabel1.setFont(new java.awt.Font("Marker Felt", 0, 24)); // NOI18N
    jLabel1.setForeground(new java.awt.Color(255, 102, 153));
    jLabel1.setText("Welcome to Groovy Smoothie");
    jLabel1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                jPanel1Layout
                    .createSequentialGroup()
                    .addContainerGap(68, Short.MAX_VALUE)
                    .addComponent(jLabel1)
                    .addContainerGap()));
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                jPanel1Layout
                    .createSequentialGroup()
                    .addContainerGap(37, Short.MAX_VALUE)
                    .addComponent(jLabel1)
                    .addGap(17, 17, 17)));

    jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Login"));

    jLabel2.setText("Username");

    jLabel3.setText("Password");

    LoginField.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            LoginFieldActionPerformed(evt);
          }
        });

    LoginBttn.setText("Login");
    LoginBttn.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            LoginBttnMouseClicked(evt);
          }
        });
    LoginBttn.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            LoginBttnActionPerformed(evt);
          }
        });

    PasswordField.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            PasswordFieldActionPerformed(evt);
          }
        });

    javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
    jPanel3.setLayout(jPanel3Layout);
    jPanel3Layout.setHorizontalGroup(
        jPanel3Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel3Layout
                    .createSequentialGroup()
                    .addGap(22, 22, 22)
                    .addGroup(
                        jPanel3Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                jPanel3Layout
                                    .createSequentialGroup()
                                    .addComponent(jLabel2)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(
                                jPanel3Layout
                                    .createSequentialGroup()
                                    .addComponent(jLabel3)
                                    .addGap(9, 9, 9)))
                    .addGroup(
                        jPanel3Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(PasswordField)
                            .addComponent(
                                LoginField,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                84,
                                Short.MAX_VALUE))
                    .addContainerGap(53, Short.MAX_VALUE))
            .addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                jPanel3Layout
                    .createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(LoginBttn)
                    .addGap(27, 27, 27)));
    jPanel3Layout.setVerticalGroup(
        jPanel3Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel3Layout
                    .createSequentialGroup()
                    .addGap(17, 17, 17)
                    .addGroup(
                        jPanel3Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(
                                LoginField,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(
                        jPanel3Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(
                                PasswordField,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addComponent(LoginBttn)
                    .addContainerGap(26, Short.MAX_VALUE)));

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addGap(39, 39, 39)
                                    .addComponent(
                                        jPanel1,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addGap(20, 20, 20)
                                    .addComponent(
                                        jPanel3,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap(90, Short.MAX_VALUE)));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        jPanel1,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(
                        jPanel3,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    pack();
  } // </editor-fold>
Beispiel #16
0
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    ConfirmButton = new javax.swing.JButton();
    CancelButton = new javax.swing.JButton();
    RegisterUserLabel = new javax.swing.JLabel();
    jPanel1 = new javax.swing.JPanel();
    UsernameField = new javax.swing.JTextField();
    PasswordField = new javax.swing.JPasswordField();
    ConfirmPasswordField = new javax.swing.JPasswordField();
    EmailField = new javax.swing.JTextField();
    ConfirmEmailField = new javax.swing.JTextField();
    ConfirmEmailLabel = new javax.swing.JLabel();
    EmailLabel = new javax.swing.JLabel();
    ConfimPasswordLabel = new javax.swing.JLabel();
    UsernameLabel = new javax.swing.JLabel();
    PasswordLabel = new javax.swing.JLabel();
    xEmail = new javax.swing.JLabel();
    xPassword = new javax.swing.JLabel();
    xName = new javax.swing.JLabel();
    ErrorLabel = new javax.swing.JLabel();
    jLabel1 = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    java.util.ResourceBundle bundle =
        java.util.ResourceBundle.getBundle("resources/Portugues_pt_PT_EURO"); // NOI18N
    setTitle(bundle.getString("AppTitle")); // NOI18N
    setResizable(false);
    getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

    ConfirmButton.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    ConfirmButton.setText(bundle.getString("ConfirmButton")); // NOI18N
    ConfirmButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            ConfirmButtonActionPerformed(evt);
          }
        });
    getContentPane()
        .add(ConfirmButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(246, 444, 171, 55));

    CancelButton.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    CancelButton.setText(bundle.getString("CancelButton")); // NOI18N
    CancelButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            CancelButtonActionPerformed(evt);
          }
        });
    getContentPane()
        .add(CancelButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(454, 444, 165, 55));

    RegisterUserLabel.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
    RegisterUserLabel.setText(bundle.getString("RegisterUserLabel")); // NOI18N
    getContentPane()
        .add(RegisterUserLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(318, 60, -1, -1));

    UsernameField.setAlignmentY(0.0F);
    UsernameField.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

    PasswordField.setAlignmentY(0.0F);
    PasswordField.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    PasswordField.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            PasswordFieldActionPerformed(evt);
          }
        });

    ConfirmPasswordField.setAlignmentY(0.0F);
    ConfirmPasswordField.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

    EmailField.setAlignmentY(0.0F);
    EmailField.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

    ConfirmEmailField.setAlignmentY(0.0F);
    ConfirmEmailField.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

    ConfirmEmailLabel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    ConfirmEmailLabel.setText(bundle.getString("ConfirmEmailLabel")); // NOI18N
    ConfirmEmailLabel.setAlignmentY(0.0F);

    EmailLabel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    EmailLabel.setText("E-Mail:");
    EmailLabel.setAlignmentY(0.0F);

    ConfimPasswordLabel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    ConfimPasswordLabel.setText(bundle.getString("ConfirmPasswordLabel")); // NOI18N
    ConfimPasswordLabel.setAlignmentY(0.0F);

    UsernameLabel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    UsernameLabel.setText(bundle.getString("UsernameLabel")); // NOI18N
    UsernameLabel.setAlignmentY(0.0F);
    UsernameLabel.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseEntered(java.awt.event.MouseEvent evt) {
            UsernameLabelMouseEntered(evt);
          }
        });

    PasswordLabel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    PasswordLabel.setText("Password:"******"/resources/redcross.png"))); // NOI18N

    xPassword.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/resources/redcross.png"))); // NOI18N

    xName.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/resources/redcross.png"))); // NOI18N

    ErrorLabel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
    ErrorLabel.setText("ERROR TEXT FIELD HERE...");

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                jPanel1Layout
                    .createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                jPanel1Layout
                                    .createSequentialGroup()
                                    .addGroup(
                                        jPanel1Layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(ConfirmEmailLabel)
                                            .addComponent(EmailLabel)
                                            .addComponent(ConfimPasswordLabel))
                                    .addGap(17, 17, 17))
                            .addGroup(
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                jPanel1Layout
                                    .createSequentialGroup()
                                    .addGroup(
                                        jPanel1Layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(
                                                UsernameLabel,
                                                javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(
                                                PasswordLabel,
                                                javax.swing.GroupLayout.Alignment.TRAILING))
                                    .addGap(18, 18, 18)))
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                jPanel1Layout
                                    .createSequentialGroup()
                                    .addComponent(
                                        PasswordField,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        335,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(xPassword))
                            .addGroup(
                                jPanel1Layout
                                    .createSequentialGroup()
                                    .addComponent(
                                        UsernameField,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        335,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(xName))
                            .addComponent(
                                ConfirmPasswordField,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                335,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(
                                jPanel1Layout
                                    .createSequentialGroup()
                                    .addComponent(
                                        EmailField,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        335,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(xEmail))
                            .addGroup(
                                jPanel1Layout
                                    .createParallelGroup(
                                        javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(
                                        ErrorLabel,
                                        javax.swing.GroupLayout.Alignment.LEADING,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                    .addComponent(
                                        ConfirmEmailField,
                                        javax.swing.GroupLayout.Alignment.LEADING,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        335,
                                        Short.MAX_VALUE)))));
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                jPanel1Layout
                    .createSequentialGroup()
                    .addGap(32, 32, 32)
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(
                                jPanel1Layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(
                                        UsernameField,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        32,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(UsernameLabel))
                            .addComponent(
                                xName,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                32,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(
                                jPanel1Layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(
                                        PasswordField,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        31,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(PasswordLabel))
                            .addComponent(xPassword))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(
                                ConfirmPasswordField,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                31,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ConfimPasswordLabel))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(
                                jPanel1Layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(
                                        EmailField,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        34,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(EmailLabel))
                            .addComponent(
                                xEmail,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                34,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        jPanel1Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(
                                ConfirmEmailField,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                34,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ConfirmEmailLabel))
                    .addPreferredGap(
                        javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
                    .addComponent(ErrorLabel)
                    .addContainerGap()));

    getContentPane()
        .add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(114, 122, -1, -1));

    jLabel1.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/resources/background.jpg"))); // NOI18N
    getContentPane()
        .add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 860, 550));

    pack();
  } // </editor-fold>//GEN-END:initComponents
Beispiel #17
0
 @Test
 public void testPasswordField() {
   PasswordField field = new PasswordField("pwd");
   field.setValue("1234");
   assertOut(field, "<input type='password' name='pwd' value=''>");
 }
Beispiel #18
0
  public static void main(String args[]) {
    UniJava uJava = new UniJava();
    System.out.println("Version number = " + uJava.getVersionNumber());
    System.out.println("Max # Sessions = " + uJava.getMaxSessions());

    try {
      UniSession uSession = uJava.openSession();
      System.out.println("openSession is successful");

      try {
        xTmp = inputStringCheck("Choose DataSourceType: 1) UniData (Default) 2) UniVerse: ");
        // vTmp = getInt("Choose DataSourceType: 1) UniData (Default) 2) UniVerse: ");

      } catch (java.io.IOException e) {
        printMsg("DataBaseType Error !");
      }

      if (xTmp.length() == 0) {
        vTmp = 1;
      } else {
        vTmp = Integer.parseInt(xTmp);
      }

      if (vTmp == 2) {
        xDataSourceType = "UNIVERSE";
        xServiceName = "uvcs";
        xHostName = "Localhost";
        xAccount = "HS.SALES";
        xFile = "STATES";
        xRecordID = "CO";
      } else {
        xDataSourceType = "UNIDATA";
        xServiceName = "udcs";
        xHostName = "Localhost";
        xAccount = "demo";
        xFile = "STATES";
        xRecordID = "CO";
      }

      try {
        uSession.setDataSourceType(xDataSourceType);
      } catch (UniConnectionException e) {
        printMsg("setDataSourceType to UNIDATA/UNIVERSE failed");
      }

      try {
        xTmp =
            inputString(
                "Please input the UniObject Service Name (Default " + xServiceName + ") : ");
      } catch (java.io.IOException e) {
        printMsg("UniObject Service Name Error !");
      }

      if (xTmp.length() != 0) {
        xServiceName = xTmp;
      }

      try {
        xTmp = inputString("Please input the HostName (Default " + xHostName + ") : ");
      } catch (java.io.IOException e) {
        printMsg("HostName Error !");
      }

      if (xTmp.length() != 0) {
        xHostName = xTmp;
      }

      try {
        xUserName = inputString("Please input the UserName: "******"UserName Error !");
      }

      char pwdx[];
      try {
        // xPassword = getParameter("Password");
        // xPassword = inputString("Please input the Password: "******"Please input the password: "******"Password Error !");
      }

      try {
        printMsg("Default account " + xAccount + " !");
        xTmp = inputString("Please input the Account: ");
      } catch (java.io.IOException e) {
        printMsg("Account Name Error !");
      }

      if (xTmp.length() != 0) {
        xAccount = xTmp;
      }

      uSession.setConnectionString(xServiceName);
      uSession.setHostName(xHostName);
      uSession.setUserName(xUserName);
      uSession.setPassword(xPassword);
      uSession.setAccountPath(xAccount);

      printMsg("Server Name =" + xHostName);
      uSession.connect();

      try {
        printMsg("Default file (" + xFile + ") !");
        xTmp = inputString("Please input the File Name: ");
      } catch (java.io.IOException e) {
        printMsg("File Name Error !");
      }

      if (xTmp.length() != 0) {
        xFile = xTmp;
      }

      UniFile uojFile = uSession.open(xFile);
      System.out.println("\nThe " + xFile + " file was opened successfully");

      // Read entire CO record
      try {
        printMsg("Default Record ID (" + xRecordID + ") !");
        xTmp = inputString("Please input the Record ID: ");
      } catch (java.io.IOException e) {
        printMsg("Record ID Error !");
      }
      if (xTmp.length() != 0) {
        xRecordID = xTmp;
      }

      // Extract record value based on the record ID
      try {
        UniString custRec = uojFile.read(xRecordID);
        UniDynArray custArray = new UniDynArray(custRec);
        System.out.println("custArray Object: " + custArray.toString());
      } catch (UniFileException e) {
        System.out.println("error: " + e);
      }

      // catch ( UniStringException e ){
      //	System.out.println("error: "+e+" CODE = "+e.getErrorCode());
      // }

      // close UniSession & UniJava
      uojFile.close();
      uSession.disconnect();
      uJava.closeSession(uSession);
      System.out.println("\n\t*--- End of Test ---*\n");
    } catch (UniSessionException e) {
      System.out.println("error: " + e + " CODE = " + e.getErrorCode());
    } catch (UniFileException e) {
      System.out.println("Error CODE = " + e.getErrorCode() + " error: " + e);
    }
  }