- @Override
- public synchronized boolean submit(PrintWriter out, HttpServletRequest req) {
- update(req);
- boolean failed = false;
- out.println("<div class='formError'>");
- if (buildup.getFname().equals("") || buildup.getLname().equals("")) {
- outputError(out, req, "First and/or last names were blank.");
- failed = true;
- }
- if (!myDoB.isValid()) {
- outputError(out, req, "Invalid date of birth");
- failed = true;
- }
- if (!"1".equals(req.getParameter("cca_agree"))) {
- outputError(out, req, "You have to agree to the CAcert Community agreement.");
- failed = true;
- }
- if (buildup.getEmail().equals("")) {
- outputError(out, req, "Email Address was blank");
- failed = true;
- }
- String pw1 = req.getParameter("pword1");
- String pw2 = req.getParameter("pword2");
- if (pw1 == null || pw1.equals("")) {
- outputError(out, req, "Pass Phrases were blank");
- failed = true;
- } else if (!pw1.equals(pw2)) {
- outputError(out, req, "Pass Phrases don't match");
- failed = true;
- }
- int pwpoints = PasswordStrengthChecker.checkpw(pw1, buildup);
- if (pwpoints < 3) {
- outputError(out, req, "The Pass Phrase you submitted failed to contain enough"
- + " differing characters and/or contained words from" + " your name and/or email address.");
- failed = true;
- }
- if (failed) {
- out.println("</div>");
- return false;
- }
- try {
- PreparedStatement q1 = DatabaseConnection.getInstance().prepare(
- "select * from `email` where `email`=? and `deleted`=0");
- PreparedStatement q2 = DatabaseConnection.getInstance().prepare(
- "select * from `users` where `email`=? and `deleted`=0");
- q1.setString(1, buildup.getEmail());
- q2.setString(1, buildup.getEmail());
- ResultSet r1 = q1.executeQuery();
- ResultSet r2 = q2.executeQuery();
- if (r1.next() || r2.next()) {
- outputError(out, req, "This email address is currently valid in the system.");
- failed = true;
- }
- r1.close();
- r2.close();
- PreparedStatement q3 = DatabaseConnection.getInstance().prepare(
- "select `domain` from `baddomains` where `domain`=RIGHT(?, LENGTH(`domain`))");
- q3.setString(1, buildup.getEmail());
+ ResultSet r3 = q3.executeQuery();
+ if (r3.next()) {
+ String domain = r3.getString(1);
+ outputError(out, req, "We don't allow signups from people using email addresses from %s", domain);
+ }
+ r3.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ outputError(out, req, "an internal error happened");
+ }
+ String mailResult = EmailProvider.FAIL;
+ try {
+ mailResult = EmailProvider.getInstance().checkEmailServer(0, buildup.getEmail());
+ } catch (IOException e) {
+ }
+ if ( !mailResult.equals(EmailProvider.OK)) {
+ if (mailResult.startsWith("4")) {
+ outputError(out, req, "The mail server responsible for your domain indicated" + " a temporary failure. This may be due to anti-SPAM measures, such" + " as greylisting. Please try again in a few minutes.");
+ } else {
+ outputError(out, req, "Email Address given was invalid, or a test connection" + " couldn't be made to your server, or the server" + " rejected the email address as invalid");
+ }
+ if (mailResult.equals(EmailProvider.FAIL)) {
+ outputError(out, req, "Failed to make a connection to the mail server");
+ } else {
+ outputErrorPlain(out, mailResult);
+ }
+ }