コード例 #1
0
ファイル: UIRegister.java プロジェクト: afcMaia/DomineUP
  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
コード例 #2
0
ファイル: Ftp.java プロジェクト: swistaczek/Ftp.java
  /**
   * 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();
  }
コード例 #3
0
ファイル: uojconnect.java プロジェクト: swikle/u2-servers-lab
  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);
    }
  }