Skip to content

Commit

Permalink
Fixes minor code-cleanup and -format issues
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelmay committed May 28, 2024
1 parent 033ee3a commit df592ca
Show file tree
Hide file tree
Showing 25 changed files with 91 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ public interface GreenMailOperations {
* <ul>
* <li>
* Expected structure in provided path, containing EML (rfc0822) mail files
* <p>Pattern: <pre>&lt;EMAIL&gt; / &lt;FOLDER*&gt; / &lt;*.eml&gt;</pre></p>
* <p>Example:</p>
* <p>Pattern: <pre>&lt;EMAIL&gt; / &lt;FOLDER*&gt; / &lt;*.eml&gt;</pre>
* <p>Example:
* <pre>
* ├── bar@localhost (directory)
* │ └── INBOX (directory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public String nstring(ImapRequestLineReader request) throws ProtocolException {
* Reads a "mailbox" argument from the request. Not implemented *exactly* as per spec,
* since a quoted or literal "inbox" still yeilds "INBOX"
* (ie still case-insensitive if quoted or literal). I think this makes sense.
* <p/>
* <p>
* mailbox ::= "INBOX" / astring
* ;; INBOX is case-insensitive. All case variants of
* ;; INBOX (e.g. "iNbOx") MUST be interpreted as INBOX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class CommandTemplate
}

/**
* By default, valid in any state (unless overridden by subclass.
* By default, valid in any state (unless overridden by subclass).
*
* @see com.icegreen.greenmail.imap.commands.ImapCommand#validForState
*/
Expand Down Expand Up @@ -95,7 +95,7 @@ protected String getExpectedMessage() {
syntax.append(getName());

String args = getArgSyntax();
if (args != null && args.length() > 0) {
if (args != null && !args.isEmpty()) {
syntax.append(' ');
syntax.append(args);
}
Expand All @@ -106,7 +106,7 @@ protected String getExpectedMessage() {
/**
* Provides the syntax for the command arguments if any. This value is used
* to provide user feedback in the case of a malformed request.
* <p/>
* <p>
* For commands which do not allow any arguments, <code>null</code> should
* be returned.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* Represents a range of UID values.
* <p>
* From https://tools.ietf.org/html/rfc3501 :
* From <a href="https://tools.ietf.org/html/rfc3501">rfc3501</a> :
* <p>
* seq-number = nz-number / "*"
* ; message sequence number (COPY, FETCH, STORE
Expand Down Expand Up @@ -92,7 +92,7 @@ public boolean includes(long uid) {
/**
* Parses an uid sequence, a comma separated list of uid ranges.
* Note that the wildcard '*' denotes the largest number in use.
* <p/>
* <p>
* Example: 1,2:5,8:*
*
* @param idRangeSequence the sequence
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/**
* Represents a processor for a particular Imap command. Implementations of this
* interface should encpasulate all command specific processing.
* interface should encapsulate all commands specific processing.
*
* @author Darrell DeBoer <darrell@apache.org>
* @version $Revision: 109034 $
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@

/**
* Implements IMAP Quota Extension.
* <p/>
* See <a href="https://datatracker.ietf.org/doc/html/rfc2087#section-4-1">rfc2087</a>
*
* <p>
* Supports MESSAGES and STORAGE.
* @author mm
* <p>
* See <a href="https://datatracker.ietf.org/doc/html/rfc2087#section-4-1">rfc2087</a>
*/
public class QuotaRootCommand extends QuotaCommand {
public static final String NAME = "GETQUOTAROOT";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/**
* Implements IMAP Quota Extension.
* <p/>
* <p>
* See <a href="https://datatracker.ietf.org/doc/html/rfc2087#section-4-1">rfc2087</a>
*
* @author mm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@
import java.io.IOException;
import java.util.Arrays;


/**
* AUTH command.
* <p/>
* <p>
* <pre>
* Supported: PLAIN, LOGIN
* AUTH mechanism [initial-response]
* or
* AUTH LOGIN [initial-response]
* </pre>
* <a href="https://tools.ietf.org/html/rfc4954">RFC4954</a>
* <a href="https://tools.ietf.org/html/rfc2554">RFC2554</a>
* <a href="http://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml">SASL mechanisms</a></a>
* <a href="http://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml">SASL mechanisms</a>
* <a href="https://datatracker.ietf.org/doc/draft-murchison-sasl-login/">SASL LOGIN</a>
*/
public class AuthCommand extends SmtpCommand {
Expand Down Expand Up @@ -83,7 +84,7 @@ private void authPlain(SmtpConnection conn, SmtpState state, SmtpManager manager
} else {
initialResponse = commandParts[2];
}

SaslMessage saslMessage = parseInitialResponse(initialResponse);
AuthenticationState authenticationContext = new PlainAuthenticationState(saslMessage);
state.getMessage().setAuthenticationState(authenticationContext);
Expand Down Expand Up @@ -124,7 +125,7 @@ private void authLogin(SmtpConnection conn, SmtpState state, SmtpManager manager
private boolean authenticate(UserManager userManager, SaslMessage saslMessage) {
return userManager.test(saslMessage.getAuthcid(), saslMessage.getPasswd());
}

private SaslMessage parseInitialResponse(String initialReponse) {
String value = EncodingUtil.decodeBase64(initialReponse);
// authorization-id\0authentication-id\0passwd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@

/**
* DATA command.
* <p/>
* The spec is at <a
* href="https://tools.ietf.org/html/rfc2821.html#section-4.1.1.4">
* <p>
* <a href="https://tools.ietf.org/html/rfc2821.html#section-4.1.1.4">
* https://tools.ietf.org/html/rfc2821.html#section-4.1.1.4</a>.
* </p>
*/
public class DataCommand extends SmtpCommand {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

/**
* EHLO/HELO command.
* <p/>
* <p>
* TODO: What does HELO do if it's already been called before?
* <p/>
* <a https://tools.ietf.org/html/rfc2821#section-4.1.1.1">RFC2821</a>
* <p>
* <a href="https://tools.ietf.org/html/rfc2821#section-4.1.1.1">RFC2821</a>
* <a href="https://tools.ietf.org/html/rfc4954">RFC4954</a>
* <a href="https://tools.ietf.org/html/rfc2554">RFC2554</a>
*/
Expand All @@ -42,4 +42,4 @@ private void extractHeloName(SmtpConnection conn,

conn.setHeloName(heloName);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,20 @@
*/
package com.icegreen.greenmail.smtp.commands;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.icegreen.greenmail.mail.MailAddress;
import com.icegreen.greenmail.smtp.SmtpConnection;
import com.icegreen.greenmail.smtp.SmtpManager;
import com.icegreen.greenmail.smtp.SmtpState;

import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
* MAIL command.
* <p/>
* <p/>
* The spec is at <a
* href="https://tools.ietf.org/html/rfc2821.html#section-4.1.1.2">
* <p>
* <a href="https://tools.ietf.org/html/rfc2821.html#section-4.1.1.2">
* https://tools.ietf.org/html/rfc2821.html#section-4.1.1.2</a>
* </p>
*/
public class MailCommand
extends SmtpCommand {
Expand Down Expand Up @@ -58,4 +55,4 @@ public void execute(SmtpConnection conn, SmtpState state,
conn.send("501 Required syntax: 'MAIL FROM:<email@host>'");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@
import com.icegreen.greenmail.smtp.SmtpManager;
import com.icegreen.greenmail.smtp.SmtpState;


/**
* NOOP command.
* <p/>
* <p/>
* The spec is at <a
* href="https://tools.ietf.org/html/rfc2821.html#section-4.1.1.9">
* https://tools.ietf.org/html/rfc2821.html#section-4.1.1.9</a>.
* </p>
* <p>"NOOP" [ SP String ] CRLF</p>
* <p>
* <a href="https://tools.ietf.org/html/rfc2821.html#section-4.1.1.9">
* https://tools.ietf.org/html/rfc2821.html#section-4.1.1.9</a>
* <pre>"NOOP" [ SP String ] CRLF</pre>
*/
public class NoopCommand
extends SmtpCommand {
Expand All @@ -28,4 +24,4 @@ public void execute(SmtpConnection conn, SmtpState state,
SmtpManager manager, String commandLine) {
conn.send("250 Is that all?");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@
import com.icegreen.greenmail.smtp.SmtpManager;
import com.icegreen.greenmail.smtp.SmtpState;


/**
* QUIT command.
* <p/>
* <p/>
* The spec is at <a
* https://tools.ietf.org/html/rfc2821.html#section-4.1.1.10">
* https://tools.ietf.org/html/rfc2821.html#section-4.1.1.10</a>.
* </p>
* <p>"QUIT" CRLF</p>
* <p>
* <a href="https://tools.ietf.org/html/rfc2821.html#section-4.1.1.10">
* https://tools.ietf.org/html/rfc2821.html#section-4.1.1.10</a>
* <pre>"QUIT" CRLF</pre>
*/
public class QuitCommand
extends SmtpCommand {
Expand All @@ -31,4 +27,4 @@ public void execute(SmtpConnection conn, SmtpState state,
" Service closing transmission channel");
conn.quit();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,23 @@
*/
package com.icegreen.greenmail.smtp.commands;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.icegreen.greenmail.mail.MailAddress;
import com.icegreen.greenmail.smtp.SmtpConnection;
import com.icegreen.greenmail.smtp.SmtpManager;
import com.icegreen.greenmail.smtp.SmtpState;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* RCPT command.
* <p/>
* <p/>
* The spec is at <a
* href="https://tools.ietf.org/html/rfc2821.html#section-4.1.1.3">
* https://tools.ietf.org/html/rfc2821.html#section-4.1.1.3</a>.
* </p>
* <p>
* <a href="https://tools.ietf.org/html/rfc2821.html#section-4.1.1.3">
* https://tools.ietf.org/html/rfc2821.html#section-4.1.1.3</a>
* <pre>
* "RCPT TO:" ("<Postmaster@" domain ">" / "<Postmaster>" / Forward-Path)
* [SP Rcpt-parameters] CRLF
* </p>
* </pre>
*/
public class RcptCommand
extends SmtpCommand {
Expand Down Expand Up @@ -60,4 +56,4 @@ public void execute(SmtpConnection conn, SmtpState state,
conn.send("501 Required syntax: 'RCPT TO:<email@host>'");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@
import com.icegreen.greenmail.smtp.SmtpManager;
import com.icegreen.greenmail.smtp.SmtpState;


/**
* RSET command.
* <p/>
* <p/>
* The spec is at <a
* href="https://tools.ietf.org/html/rfc2821.html#section-4.1.1.5">
* https://tools.ietf.org/html/rfc2821.html#section-4.1.1.5</a>.
* </p>
* <p>
* <a href="https://tools.ietf.org/html/rfc2821.html#section-4.1.1.5">
* https://tools.ietf.org/html/rfc2821.html#section-4.1.1.5</a>
*/
public class RsetCommand
extends SmtpCommand {
Expand All @@ -28,4 +24,4 @@ public void execute(SmtpConnection conn, SmtpState state,
state.clearMessage();
conn.send("250 OK");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.HashMap;
import java.util.Map;


public class SmtpCommandRegistry {
private static final Map<String, SmtpCommand> commands = new HashMap<>();

Expand All @@ -29,4 +28,4 @@ public class SmtpCommandRegistry {
public SmtpCommand getCommand(String name) {
return commands.get(name);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@
import com.icegreen.greenmail.smtp.SmtpManager;
import com.icegreen.greenmail.smtp.SmtpState;


/**
* VRFY command.
* <p/>
* <p/>
* The spec is at <a
* href="http://asg.web.cmu.edu/rfc/rfc2821.html#sec-4.1.1.6">
* <p>
* <a href="http://asg.web.cmu.edu/rfc/rfc2821.html#sec-4.1.1.6">
* http://asg.web.cmu.edu/rfc/rfc2821.html#sec-4.1.1.6</a>.
* </p>
*/
public class VrfyCommand
extends SmtpCommand {
Expand All @@ -27,4 +23,4 @@ public void execute(SmtpConnection conn, SmtpState state,
SmtpManager manager, String commandLine) {
conn.send("252 Cannot VRFY user, but will accept message and attempt delivery");
}
}
}
Loading

0 comments on commit df592ca

Please sign in to comment.