Commit 1cb24255 authored by Grzegorz Pietrusza's avatar Grzegorz Pietrusza

flag authorization

parent 4fdffdc0
......@@ -38,13 +38,14 @@ public class TasksResource
}
@GET
public List<Task> getTasks(@Auth User user) {
public List<Task> getTasks() {
return tasksRepository.getAll();
}
@POST
public boolean submitSolution(String flag) throws Exception {
return flagChecker.checkFlag(flag);
public boolean submitSolution(@Auth User user,
String flag) throws Exception {
return flagChecker.checkFlag(user.getName(), flag);
}
}
......@@ -41,7 +41,8 @@ public class FlagChecker {
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return Hex.encodeHexString(md5.digest(combinedStrings.getBytes()));
String encodedHash = Hex.encodeHexString(md5.digest(combinedStrings.getBytes()));
return encodedHash;
}
private void acceptSolution(String username, Task task) {
......@@ -67,8 +68,7 @@ public class FlagChecker {
return false;
}
public boolean checkFlag(String flagValue) throws Exception {
String username = "gpietrus"; //todo
public boolean checkFlag(String username, String flagValue) throws Exception {
String hash = calculateHashValue(username, flagValue);
return compareHash(hash, username);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment