Package org.subethamail.smtp

Examples of org.subethamail.smtp.RejectException


          addedListener = true;
        }
      }

      if (!addedListener)
        throw new RejectException(553, "<" + recipient + "> address unknown.");
    }
View Full Code Here


      if (token.trim().equalsIgnoreCase("AUTH"))
      {
        if (!stk.nextToken().trim().equalsIgnoreCase("LOGIN"))
        {
          // Mechanism mismatch
          throw new RejectException(504, "AUTH mechanism mismatch");
        }

        if (stk.hasMoreTokens())
        {
          // The client submitted an initial response, which should be
          // the username.
          // .Net's built in System.Net.Mail.SmtpClient sends its
          // authentication this way (and this way only).
          username = TextUtils.getStringUtf8(Base64.decode(stk
              .nextToken()));

          return "334 "
              + Base64.encodeToString(
                  TextUtils.getAsciiBytes("Password:"),
                  false);
        } else {
          return "334 "
              + Base64.encodeToString(
                  TextUtils.getAsciiBytes("Username:"), false);
        }
      }

      if (this.username == null)
      {
        byte[] decoded = Base64.decode(clientInput);
        if (decoded == null)
        {
          throw new RejectException();
        }

        this.username = TextUtils.getStringUtf8(decoded);

        return "334 "
            + Base64.encodeToString(
                TextUtils.getAsciiBytes("Password:"), false);
      }

      byte[] decoded = Base64.decode(clientInput);
      if (decoded == null)
      {
        throw new RejectException();
      }

      this.password = TextUtils.getStringUtf8(decoded);
      try
      {
        LoginAuthenticationHandlerFactory.this.helper.login(this.username, this.password);
      }
      catch (LoginFailedException lfe)
      {
        throw new RejectException();
      }

      return null;
    }
View Full Code Here

        // Let's read the RFC2554 "initial-response" parameter
        // The line could be in the form of "AUTH PLAIN <base64Secret>"
        if (!stk.nextToken().trim().equalsIgnoreCase("PLAIN"))
        {
          // Mechanism mismatch
          throw new RejectException(504, "AUTH mechanism mismatch");
        }

        if (stk.hasMoreTokens())
        {
          // the client submitted an initial response
          secret = stk.nextToken();
        }
        else
        {
          // the client did not submit an initial response, we'll get it in the next pass
          return "334 Ok";
        }
      }

      byte[] decodedSecret = Base64.decode(secret);
      if (decodedSecret == null)
        throw new RejectException();

      /*
       * RFC4616: The client presents the authorization identity (identity
       * to act as), followed by a NUL (U+0000) character, followed by the
       * authentication identity (identity whose password will be used),
       * followed by a NUL (U+0000) character, followed by the clear-text
       * password.
       */

      int i, j;
      for (i = 0; i < decodedSecret.length && decodedSecret[i] != 0; i++)
        ;
      if (i >= decodedSecret.length)
      {
        throw new RejectException();
      }

      for (j = i + 1; j < decodedSecret.length && decodedSecret[j] != 0; j++)
        ;
      if (j >= decodedSecret.length)
      {
        throw new RejectException();
      }

      @SuppressWarnings("unused")
      String authorizationId = new String(decodedSecret, 0, i);
      String authenticationId = new String(decodedSecret, i + 1, j - i - 1);
      String passwd = new String(decodedSecret, j + 1, decodedSecret.length - j - 1);

      // might be nice to do something with authorizationId, but for
      // purposes of the UsernamePasswordValidator, we just want to use
      // authenticationId

      this.username = authenticationId;
      this.password = passwd;
      try
      {
        PlainAuthenticationHandlerFactory.this.helper.login(this.username.toString(), this.password);
      }
      catch (LoginFailedException lfe)
      {
        throw new RejectException();
      }

      return null;
    }
View Full Code Here

    @Override
    public void data(MailData data) throws RejectException,
            TooMuchDataException, IOException {
        try {
            if (receivedHeaderCount(data) > maxReceivedHeaders)
                throw new RejectException(554, "Routing loop detected");
        } catch (MimeException e) {
            logger.debug("Cannot determine Received header count", e);
            throw new RejectException(554, "Invalid message content");
        } catch (MaxLineLimitException e) {
            logger.debug(
                    "Line too long, cannot determine Received header count", e);
            throw new RejectException(554, "Line too long");
        }
    }
View Full Code Here

        RemotePart remotePart = recipient.getMailbox().getRemotePart();
        for (RemotePartSpecification remotePartSpecification : localDomainSpecifications) {
            if (remotePartSpecification.isSatisfiedBy(remotePart))
                return FilterReply.NEUTRAL;
        }
        throw new RejectException(550,
                "Relaying prohibited, user is not local (" + recipient + ")");

    }
View Full Code Here

                String statusText;
                if (spfResult.getExplanation().isEmpty())
                    statusText = "Blocked by SPF";
                else
                    statusText = "Blocked - see: " + spfResult.getExplanation();
                throw new RejectException(550, statusText);
            } else if (spfResult.equals(SPFErrorConstants.TEMP_ERROR_CONV)) {
                throw new RejectException(451,
                        "Temporarily rejected: Problem on SPF lookup");
            } else if (rejectOnPermanentError
                    && spfResultCode.equals(SPFErrorConstants.PERM_ERROR_CONV)) {
                throw new RejectException(550, "Blocked - invalid SPF record");
            }

            return chain.verifyRecipient(recipientContext);
        }
View Full Code Here

            wrapped.from(from);
        } catch (RejectException e) {
            throw e;
        } catch (ConfigurationException e) {
            logger.error("Wrong configuration.", e);
            throw new RejectException(554, "Mail server configuration is wrong");
        } catch (RuntimeException e) {
            logger.error("Unexpected exception.", e);
            throw new RejectException(550, "Internal error");
        }
    }
View Full Code Here

            wrapped.recipient(recipient);
        } catch (RejectException e) {
            throw e;
        } catch (ConfigurationException e) {
            logger.error("Wrong configuration.", e);
            throw new RejectException(554, "Mail server configuration is wrong");
        } catch (RuntimeException e) {
            logger.error("Unexpected exception.", e);
            throw new RejectException(550, "Internal error");
        }
    }
View Full Code Here

            wrapped.data(data);
        } catch (RejectException e) {
            throw e;
        } catch (ConfigurationException e) {
            logger.error("Wrong configuration.", e);
            throw new RejectException(554, "Mail server configuration is wrong");
        } catch (RuntimeException e) {
            logger.error("Unexpected exception.", e);
            throw new RejectException(550, "Internal error");
        }
    }
View Full Code Here

            throws RejectException {
        try {
            return new MailAddressFactory().createReversePath(reversePath);
        } catch (ParseException e) {
            logger.debug("Syntax error in reverse path " + reversePath, e);
            throw new RejectException(553, "Syntax error in reverse path "
                    + reversePath);
        }
    }
View Full Code Here

TOP

Related Classes of org.subethamail.smtp.RejectException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.