-
Notifications
You must be signed in to change notification settings - Fork 9
Added Imap Authenticate Command, more SMTP Auth Methods & Some Bugfixes #10
Conversation
DeeJayBro
commented
Apr 11, 2017
- Fixed some NullPointers with Config creation
- Worked on Imap ToDo: Imap protocol #4
- Worked on SMTP ToDo: Smtp protocol #2
@@ -20,7 +20,7 @@ | |||
ARGUMENT_ERROR(501, "Synatx error in parameters or arguments"), | |||
COMMAND_NOT_IMPLEMENTED(502, "SmtpCommand not implemented"), | |||
BAD_SEQUENCE(503, "Bad sequence of commands"), | |||
ARGUMENT_NOT_IMPLEMENTED(504, "SmtpCommand parameter not implemented"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't change this response according to the RFC 5321
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Status Codes, 504 is for invalid command arguments, so i will change it to that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But these are the enhanced status codes, not the one that were originally defined in the SMTP protocol and the goal of the SMTP part of this project is to fully implement the SMTP protocol.
boolean breakCB = session.getCallback().callback(cache); | ||
if (breakCB) session.setCallback(null); | ||
cache = ""; | ||
continue; | ||
} */ | ||
String[] split = cache.split(" ", 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to split the string only once, because we want to separate the tag from the string. And if the string was split once there are two different strings in this array, that's why it worked before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you set limit to 1, the split Function returns an ArrayList with 1 String (Split-Function). So my change is right to make it work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry, you're right.
@@ -65,16 +65,16 @@ public void run() { | |||
} | |||
cache += (char) read; | |||
if (!(cache.endsWith("\n\r") || cache.endsWith("\n"))) continue; | |||
/* if (session.getCallback() != null) { | |||
if (session.getCallback() != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we have to create a abstract class for both handlers, because this code is twice, but it isn't your problem. I will do this in the future. :)
} else { | ||
authenticateUser(session, arguments[1]); | ||
session.send(SmtpResponse.AUTH_NOT_IMPLEMENTED.create()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See SmtpResponse.java
@@ -14,7 +14,7 @@ | |||
} | |||
|
|||
public String create(String tag, String description) { | |||
return tag + " " + text + " " + description; | |||
return tag + " " + text + " " + description + "\r\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would override the send method of the Sessions within the ImapSession class, but you don't have to do this. Just update your fork and use the new method.
} else if (arguments[0].equalsIgnoreCase("LOGIN")) { | ||
if (arguments.length == 1) { | ||
//Username: | ||
session.send("+ VXNlcm5hbWU6\r\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No line brakes needed. See ImapResponse.java
session.send("+ VXNlcm5hbWU6\r\n"); | ||
session.setCallback(username -> { | ||
//Password: | ||
session.send("+ UGFzc3dvcmQ6\r\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No line brakes needed. See ImapResponse.java
|
||
if (arguments[0].equalsIgnoreCase("PLAIN")) { | ||
if (arguments.length == 1) { | ||
session.send("+ \r\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No line brakes needed. See ImapResponse.java
Override the default send method of the Session to add line brakes
Thank you for your work and time! 👍 |
* Implemented the IMAP Authenticate Command * Added more SMTP Authentication Methods * Fixed Null Pointer Errors within the generation of the configuration file