package com.hamishrickerby.http_server;

import com.hamishrickerby.http_server.responses.ResponseCoordinator;

/**
 * Created by rickerbh on 15/08/2016.
 */
public class App {
    private static String DEFAULT_PORT = "5000";

    public static void main(String[] args) {
        AppArguments arguments = new AppArguments(args);
        Integer port = Integer.parseInt(arguments.getOrDefault("-p", DEFAULT_PORT));
        String rootDirectory = arguments.get("-d");
        if (rootDirectory == null) {
            System.err.println("Must provide a root directory with a -d argument.");
            System.exit(1);
        }
        Server server = null;

        try {
            server = new AsynchronousSocketServer(port);

            Logger logger = new MemoryLogger();
            ResponseCoordinator coordinator = new HTTPResponseCoordinator(rootDirectory, logger);
            server.setResponseCoordinator(coordinator);

            server.start();

            System.out.println("Mounted " + rootDirectory + " as the directory to serve from.");
            System.out.println("Server started on port " + port);

            server.awaitTermination(Long.MAX_VALUE);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            server.stop();
        }
    }
}

@@ -76,33 +76,87 @@
 ver.
-responses.ResponseCoordin
+auth.Authenticator;%0Aimport com.hamishrickerby.http_server.auth.RequestAuthentic
 ator
@@ -835,16 +835,20 @@
         
+HTTP
 Response
@@ -925,16 +925,78 @@
 ogger);%0A
+            coordinator.setAuthenticator(getAuthenticator());%0A
         
@@ -1398,24 +1398,24 @@
 ver.stop();%0A
-
         %7D%0A  
@@ -1417,11 +1417,273 @@
  %7D%0A    %7D
+%0A%0A    public static Authenticator getAuthenticator() %7B%0A        RequestAuthenticator authenticator = new RequestAuthenticator();%0A        authenticator.addRoute(%22/logs%22);%0A        authenticator.addCredentials(%22admin%22, %22hunter2%22);%0A        return authenticator;%0A    %7D
 %0A%7D%0A

Integrate authenticator into to app