Skip to content

Commit

Permalink
Merge pull request JamzTheMan#11 from cwisniew/fix-password-error-msg
Browse files Browse the repository at this point in the history
Fix error message on incorrect password
  • Loading branch information
cwisniew authored Feb 9, 2021
2 parents 27da997 + cf395d8 commit e0ca3c5
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/main/java/net/rptools/maptool/server/Handshake.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
public class Handshake {

public interface Code {
public static final int UNKNOWN = 0;
public static final int OK = 1;
public static final int ERROR = 2;
int UNKNOWN = 0;
int OK = 1;
int ERROR = 2;
}

private static String USERNAME_FIELD = "username:";
Expand Down Expand Up @@ -154,6 +154,9 @@ public static Player receiveHandshake(MapToolServer server, Socket s)
HessianOutput output = new HessianOutput(s.getOutputStream());
output.getSerializerFactory().setAllowNonSerializable(true);
output.writeObject(response);
} else {
dos.writeInt(response.message.length());
dos.writeBytes(response.message);
}
return player;
}
Expand Down Expand Up @@ -294,7 +297,7 @@ public static Response sendHandshake(Request request, Socket s)
if (macSaltLen != macSalt.length) {
Response response = new Response();
response.code = Code.ERROR;
response.message = "";
response.message = I18N.getString("Handshake.msg.wrongPassword");
return response;
}

Expand All @@ -312,7 +315,7 @@ public static Response sendHandshake(Request request, Socket s)
if (salt.length != saltLen) {
Response response = new Response();
response.code = Code.ERROR;
response.message = "";
response.message = I18N.getString("Handshake.msg.wrongPassword");
return response;
}

Expand All @@ -321,15 +324,15 @@ public static Response sendHandshake(Request request, Socket s)
if (bytes.length != bytes.length) {
Response response = new Response();
response.code = Code.ERROR;
response.message = "";
response.message = I18N.getString("Handshake.msg.wrongPassword");
return response;
}

byte[] mac = CipherUtil.getInstance().readMac(dis);
if (!CipherUtil.getInstance().validateMac(mac, request.password)) {
Response response = new Response();
response.code = Code.ERROR;
response.message = "";
response.message = I18N.getString("Handshake.msg.wrongPassword");
return response;
}

Expand All @@ -348,7 +351,9 @@ public static Response sendHandshake(Request request, Socket s)
} else {
Response response = new Response();
response.code = code;
response.message = "";
int len = dis.readInt();
byte[] msg = dis.readNBytes(len);
response.message = new String(msg);
return response;
}

Expand Down

0 comments on commit e0ca3c5

Please sign in to comment.