import com.prueba.core.http.sessions.Sessions;
import com.prueba.model.dao.AccountDao;
import com.prueba.view.LoginFormImpl;
+import com.prueba.view.UnAuthenticated;
import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpExchange;
Sessions.getInstance().refreshSession(uuid, username);
this.doRedirect(httpExchange);
} else {
- httpExchange.sendResponseHeaders(401, 0);
+
+ final UnAuthenticated view = new UnAuthenticated();
+ String html = view.doAuthenticated();
+ httpExchange.sendResponseHeaders(401, html.length());
+ try (final OutputStream os = httpExchange.getResponseBody()) {
+ os.write(html.getBytes());
+ }
}
}
} else {
--- /dev/null
+package com.prueba.view;
+
+import java.io.IOException;
+
+import org.rendersnake.HtmlCanvas;
+
+public class UnAuthenticated {
+
+ public String doAuthenticated() throws IOException {
+ final HtmlCanvas html = new HtmlCanvas();
+ return html
+ .html()
+ .body()
+ .h1().content("401 ERROR: YOU ARE NOT AUTHENTICATED")
+ ._body()
+ ._html()
+ .toHtml();
+ }
+}