diff --git a/src/main/java/fr/inrae/agroclim/devcas/LoginServlet.java b/src/main/java/fr/inrae/agroclim/devcas/LoginServlet.java index 8c10811eb84b7a1e6fd10dd1abc40d3ca12dc77f..646d9422248a8bb3bc49125052828152ad844566 100644 --- a/src/main/java/fr/inrae/agroclim/devcas/LoginServlet.java +++ b/src/main/java/fr/inrae/agroclim/devcas/LoginServlet.java @@ -31,7 +31,6 @@ import jakarta.servlet.annotation.WebServlet; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; - import lombok.extern.log4j.Log4j2; /** @@ -98,8 +97,9 @@ public final class LoginServlet extends HttpServlet { final Object sessionUsername = request.getSession().getAttribute("username"); if (sessionUsername != null) { if (service.trim().isEmpty()) { - final String msg = String.format("No service provided, authentified as %s", sessionUsername); - response.getWriter().write(msg); + // session OK, but no service + request.setAttribute("username", sessionUsername); + getServletContext().getRequestDispatcher("/WEB-INF/loggedin.jsp").forward(request, response); return; } // if session ok, redirect with ticket @@ -120,8 +120,9 @@ public final class LoginServlet extends HttpServlet { final String username = request.getParameter("username"); request.getSession().setAttribute("username", username); if (service == null || service.trim().isEmpty()) { - final String msg = String.format("No service provided, authentified as %s", username); - response.getWriter().write(msg); + // session OK, but no service + request.setAttribute("username", username); + getServletContext().getRequestDispatcher("/WEB-INF/loggedin.jsp").forward(request, response); return; } redirectWithTicket(response, service, username); diff --git a/src/main/java/fr/inrae/agroclim/devcas/Version.java b/src/main/java/fr/inrae/agroclim/devcas/Version.java index ff12bd616863d0608780be14539302e8ac47ca0c..bd5a284cd95ca2d88d528d4dcd60f62bd2a3ae2c 100644 --- a/src/main/java/fr/inrae/agroclim/devcas/Version.java +++ b/src/main/java/fr/inrae/agroclim/devcas/Version.java @@ -1,7 +1,34 @@ package fr.inrae.agroclim.devcas; +/*- + * #%L + * Fake CAS + * %% + * Copyright (C) 2022 Agroclim + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + import java.util.ResourceBundle; +/** + * Application version. + * + * @author Olivier Maury + */ public final class Version { /** * Resources from .properties file. diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml index 03d78466a81f576431bbdd5ceed1a25bbca2d38c..a14ae8272a49dc62fa2b5435a3c87fedd931b14b 100644 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml @@ -24,7 +24,7 @@ <!DOCTYPE Configuration> <Configuration status="info"> <Properties> - <Property name="logsdir">${sys:catalina.base}/logs</Property> + <Property name="logsdir">$${sys:catalina.base}/logs</Property> </Properties> <Appenders> <Console name="console" target="SYSTEM_OUT"> diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index 19e2299eacc280f3de16807d10043624f0125fa9..6ada686d3716579c0704f7bf8ced9a9a027fac76 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -6,6 +6,11 @@ index.description.logout = destroy CAS session (logout) index.description.validate = service ticket validation and response as text index.description.serviceValidate = service ticket validation and response as XML +loggedin.h1 = Identification succeeded +loggedin.text = No service provided, identified as <strong>{0}</strong>. +loggedin.title = dev-cas - Identification +loggedin.logout = Log out + login.description = Log in dev-cas login.h1 = Login login.title = dev-cas - Log in diff --git a/src/main/resources/messages_fr.properties b/src/main/resources/messages_fr.properties index 35c07af353eef39b8ab2c2e368f971d9daa0a661..356be0c1ebc9b080c31646dbc7fbe0b924d51d05 100644 --- a/src/main/resources/messages_fr.properties +++ b/src/main/resources/messages_fr.properties @@ -6,9 +6,14 @@ index.description.logout = destruction de la session CAS (d index.description.validate = validation du ticket de service et réponse au format texte index.description.serviceValidate = validation du ticket de service et réponse au format XML -login.description = Se connecter à dev-cas -login.h1 = Connectez-vous -login.title = dev-cas - Connectez-vous +loggedin.h1 = Identification réussie +loggedin.text = Aucun service fourni, identifié comme <strong>{0}</strong>. +loggedin.title = dev-cas - Identification +loggedin.logout = Déconnectez-vous + +login.description = S'identifier à dev-cas +login.h1 = Identifiez-vous +login.title = dev-cas - Identifiez-vous login.continue = et continuer vers <i>{0}</i> login.label.username = Identifiant : login.label.previouslogins = Précédents identifiants : @@ -18,4 +23,4 @@ logout.description = D logout.h1 = Déconnexion de <strong>dev-cas</strong> logout.title = dev-cas - Déconnexion logout.loggedout = Déconnexion réussie. -logout.loginagain = Vous pouvez vous connecter à nouveau. \ No newline at end of file +logout.loginagain = Vous pouvez vous authentifier à nouveau. \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/loggedin.jsp b/src/main/webapp/WEB-INF/loggedin.jsp new file mode 100644 index 0000000000000000000000000000000000000000..68ddb2b13a0b1f0e16eddd9be0ca4dc13dfd25aa --- /dev/null +++ b/src/main/webapp/WEB-INF/loggedin.jsp @@ -0,0 +1,45 @@ +<%-- + #%L + Fake CAS + %% + Copyright (C) 2022 Agroclim + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --%> +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<fmt:setLocale value="${param.lang}" /> +<fmt:setBundle basename="messages" /> +<fmt:requestEncoding value="UTF-8" /> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="t" tagdir="/WEB-INF/tags"%> +<t:page> + <jsp:attribute name="description"> + <fmt:message key="logout.description" /> + </jsp:attribute> + <jsp:attribute name="h1"> + <fmt:message key="loggedin.h1" /> + </jsp:attribute> + <jsp:attribute name="title"> + <fmt:message key="loggedin.title" /> + </jsp:attribute> + <jsp:body> + <p><fmt:message key="loggedin.text"> + <fmt:param value="${username}" /> + </fmt:message></p> + <p><a href="logout"><fmt:message key="loggedin.logout" /></a></p> + </jsp:body> +</t:page>