From 58027fc7be83f281939c2d36912f2e36667b9c96 Mon Sep 17 00:00:00 2001 From: Lukas Vacek Date: Wed, 25 Feb 2015 02:14:38 +0100 Subject: [PATCH] PasswordCommand: send OK/KO reply to the client --- .../java/github/luv/mockgeofix/command/PasswordCommand.java | 2 ++ .../main/java/github/luv/mockgeofix/util/ResponseWriter.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/app/src/main/java/github/luv/mockgeofix/command/PasswordCommand.java b/app/src/main/java/github/luv/mockgeofix/command/PasswordCommand.java index fe015fc..48c59c2 100644 --- a/app/src/main/java/github/luv/mockgeofix/command/PasswordCommand.java +++ b/app/src/main/java/github/luv/mockgeofix/command/PasswordCommand.java @@ -31,8 +31,10 @@ public void execute(SocketChannel client, String command) { String storedPassword = pref.getString("password",""); if (password.equals(storedPassword)) { mIsLoggedIn.put(client, Boolean.TRUE); + ResponseWriter.ok(client); } else { mIsLoggedIn.put(client, Boolean.FALSE); + ResponseWriter.writeLine(client, "KO: Incorrect password."); } } diff --git a/app/src/main/java/github/luv/mockgeofix/util/ResponseWriter.java b/app/src/main/java/github/luv/mockgeofix/util/ResponseWriter.java index 35c6053..3b55507 100644 --- a/app/src/main/java/github/luv/mockgeofix/util/ResponseWriter.java +++ b/app/src/main/java/github/luv/mockgeofix/util/ResponseWriter.java @@ -36,6 +36,10 @@ public static boolean writeLine(SocketChannel client, String response) { return write(client, response+"\r\n"); } + public static boolean ok(SocketChannel client) { + return write(client, "OK\r\n"); + } + public static boolean unknownCommand(SocketChannel client) { return write(client, "KO: unknown command, try 'help'\r\n"); }