Browse Source

full page health fixes/refactoring

jrivard@gmail.com 6 years ago
parent
commit
01042ad6ea

+ 2 - 1
server/src/main/java/password/pwm/http/JspUrl.java

@@ -99,7 +99,8 @@ public enum JspUrl
     CONFIG_MANAGER_CERTIFICATES( "configmanager-certificates.jsp" ),
     CONFIG_MANAGER_LOCALDB( "configmanager-localdb.jsp" ),
     CONFIG_MANAGER_LOGIN( "configmanager-login.jsp" ),
-    HELPDESK_SEARCH( "helpdesk.jsp" ),;
+    HELPDESK_SEARCH( "helpdesk.jsp" ),
+    FULL_PAGE_HEALTH( "fullpagehealth.jsp" ),;
 
     private String path;
     private static final String JSP_ROOT_URL = "/WEB-INF/jsp/";

+ 64 - 22
server/src/main/java/password/pwm/http/servlet/ClientApiServlet.java

@@ -47,6 +47,7 @@ import password.pwm.http.PwmURL;
 import password.pwm.i18n.Display;
 import password.pwm.svc.stats.EpsStatistic;
 import password.pwm.svc.stats.Statistic;
+import password.pwm.svc.stats.StatisticsManager;
 import password.pwm.util.i18n.LocaleHelper;
 import password.pwm.util.java.TimeDuration;
 import password.pwm.util.logging.PwmLogger;
@@ -55,6 +56,7 @@ import password.pwm.util.secure.PwmHashAlgorithm;
 import password.pwm.util.secure.SecureEngine;
 import password.pwm.ws.server.RestResultBean;
 import password.pwm.ws.server.rest.RestHealthServer;
+import password.pwm.ws.server.rest.RestStatisticsServer;
 import password.pwm.ws.server.rest.bean.HealthData;
 
 import javax.servlet.ServletException;
@@ -106,7 +108,9 @@ public class ClientApiServlet extends ControlledPwmServlet
         clientData( HttpMethod.GET ),
         strings( HttpMethod.GET ),
         health( HttpMethod.GET ),
-        ping( HttpMethod.GET ),;
+        ping( HttpMethod.GET ),
+        statistics( HttpMethod.GET ),;
+
 
         private final HttpMethod method;
 
@@ -211,27 +215,7 @@ public class ClientApiServlet extends ControlledPwmServlet
     public ProcessStatus restHealthProcessor( final PwmRequest pwmRequest )
             throws IOException, ServletException, PwmUnrecoverableException
     {
-        if ( pwmRequest.getPwmApplication().getApplicationMode() == PwmApplicationMode.RUNNING )
-        {
-            if ( !pwmRequest.getConfig().readSettingAsBoolean( PwmSetting.PUBLIC_HEALTH_STATS_WEBSERVICES ) )
-            {
-                if ( !pwmRequest.isAuthenticated() )
-                {
-                    final ErrorInformation errorInformation = new ErrorInformation( PwmError.ERROR_AUTHENTICATION_REQUIRED );
-                    LOGGER.debug( pwmRequest, errorInformation );
-                    pwmRequest.respondWithError( errorInformation );
-                    return ProcessStatus.Halt;
-                }
-
-                if ( !pwmRequest.getPwmSession().getSessionManager().checkPermission( pwmRequest.getPwmApplication(), Permission.PWMADMIN ) )
-                {
-                    final ErrorInformation errorInformation = new ErrorInformation( PwmError.ERROR_UNAUTHORIZED, "admin privileges required" );
-                    LOGGER.debug( pwmRequest, errorInformation );
-                    pwmRequest.respondWithError( errorInformation );
-                    return ProcessStatus.Halt;
-                }
-            }
-        }
+        precheckPublicHealthAndStats( pwmRequest );
 
         try
         {
@@ -470,4 +454,62 @@ public class ClientApiServlet extends ControlledPwmServlet
         return displayStrings;
     }
 
+
+    @ActionHandler( action = "statistics" )
+    private ProcessStatus restStatisticsHandler( final PwmRequest pwmRequest )
+            throws ChaiUnavailableException, PwmUnrecoverableException, IOException
+    {
+        precheckPublicHealthAndStats( pwmRequest );
+
+        final String statKey = pwmRequest.readParameterAsString( "statKey" );
+        final String statName = pwmRequest.readParameterAsString( "statName" );
+        final String days = pwmRequest.readParameterAsString( "days" );
+
+        final StatisticsManager statisticsManager = pwmRequest.getPwmApplication().getStatisticsManager();
+        final RestStatisticsServer.OutputVersion1.JsonOutput jsonOutput = new RestStatisticsServer.OutputVersion1.JsonOutput();
+        jsonOutput.EPS = RestStatisticsServer.OutputVersion1.addEpsStats( statisticsManager );
+
+        if ( statName != null && statName.length() > 0 )
+        {
+            jsonOutput.nameData = RestStatisticsServer.OutputVersion1.doNameStat( statisticsManager, statName, days );
+        }
+        else
+        {
+            jsonOutput.keyData = RestStatisticsServer.OutputVersion1.doKeyStat( statisticsManager, statKey );
+        }
+
+        final RestResultBean restResultBean = RestResultBean.withData( jsonOutput );
+        pwmRequest.outputJsonResult( restResultBean );
+        return ProcessStatus.Halt;
+
+    }
+
+    private void precheckPublicHealthAndStats( final PwmRequest pwmRequest )
+            throws PwmUnrecoverableException
+    {
+        if (
+                pwmRequest.getPwmApplication().getApplicationMode() != PwmApplicationMode.RUNNING
+                        && pwmRequest.getPwmApplication().getApplicationMode() != PwmApplicationMode.CONFIGURATION
+        )
+        {
+            final ErrorInformation errorInformation = new ErrorInformation( PwmError.ERROR_SERVICE_NOT_AVAILABLE );
+            throw new PwmUnrecoverableException( errorInformation );
+        }
+
+        if ( !pwmRequest.getConfig().readSettingAsBoolean( PwmSetting.PUBLIC_HEALTH_STATS_WEBSERVICES ) )
+        {
+            if ( !pwmRequest.isAuthenticated() )
+            {
+                final ErrorInformation errorInformation = new ErrorInformation( PwmError.ERROR_AUTHENTICATION_REQUIRED );
+                throw new PwmUnrecoverableException( errorInformation );
+            }
+
+            if ( !pwmRequest.getPwmSession().getSessionManager().checkPermission( pwmRequest.getPwmApplication(), Permission.PWMADMIN ) )
+            {
+                final ErrorInformation errorInformation = new ErrorInformation( PwmError.ERROR_UNAUTHORIZED, "admin privileges required" );
+                throw new PwmUnrecoverableException( errorInformation );
+            }
+        }
+    }
 }
+

+ 123 - 0
server/src/main/java/password/pwm/http/servlet/FullPageHealthServlet.java

@@ -0,0 +1,123 @@
+/*
+ * Password Management Servlets (PWM)
+ * http://www.pwm-project.org
+ *
+ * Copyright (c) 2006-2009 Novell, Inc.
+ * Copyright (c) 2009-2018 The PWM Project
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+package password.pwm.http.servlet;
+
+import com.novell.ldapchai.exception.ChaiUnavailableException;
+import password.pwm.PwmConstants;
+import password.pwm.config.PwmSetting;
+import password.pwm.error.ErrorInformation;
+import password.pwm.error.PwmError;
+import password.pwm.error.PwmUnrecoverableException;
+import password.pwm.http.HttpMethod;
+import password.pwm.http.JspUrl;
+import password.pwm.http.ProcessStatus;
+import password.pwm.http.PwmRequest;
+import password.pwm.util.logging.PwmLogger;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Locale;
+
+@WebServlet(
+        name = "FullPageHealthServlet",
+        urlPatterns = {
+                PwmConstants.URL_PREFIX_PUBLIC + "/health",
+        }
+)
+public class FullPageHealthServlet extends ControlledPwmServlet
+{
+    private static final PwmLogger LOGGER = PwmLogger.forClass( FullPageHealthServlet.class );
+
+    public enum FullPageHealthAction implements AbstractPwmServlet.ProcessAction
+    {
+        value( HttpMethod.GET ),;
+
+        private final HttpMethod method;
+
+        FullPageHealthAction( final HttpMethod method )
+        {
+            this.method = method;
+        }
+
+        public Collection<HttpMethod> permittedMethods( )
+        {
+            return Collections.singletonList( method );
+        }
+    }
+
+    @Override
+    public Class<? extends ProcessAction> getProcessActionsClass( )
+    {
+        return FullPageHealthAction.class;
+    }
+
+    @Override
+    protected void processAction( final PwmRequest pwmRequest )
+            throws ServletException, IOException, ChaiUnavailableException, PwmUnrecoverableException
+    {
+        super.processAction( pwmRequest );
+    }
+
+    @Override
+    protected void nextStep( final PwmRequest pwmRequest )
+            throws PwmUnrecoverableException, IOException, ServletException
+    {
+        forwardToJSP( pwmRequest );
+        pwmRequest.getPwmSession().unauthenticateUser( pwmRequest );
+    }
+
+    @Override
+    public ProcessStatus preProcessCheck( final PwmRequest pwmRequest )
+            throws PwmUnrecoverableException, IOException, ServletException
+    {
+        if ( !pwmRequest.getConfig().readSettingAsBoolean( PwmSetting.PUBLIC_HEALTH_STATS_WEBSERVICES ) )
+        {
+            final Locale locale = pwmRequest.getLocale();
+            final String errorMsg = "configuration setting "
+                    + PwmSetting.PUBLIC_HEALTH_STATS_WEBSERVICES.toMenuLocationDebug( null, locale )
+                    + " must be enabled for this page to function.";
+            final ErrorInformation errorInformation = new ErrorInformation( PwmError.ERROR_SERVICE_NOT_AVAILABLE, errorMsg );
+            throw new PwmUnrecoverableException( errorInformation );
+        }
+
+        return ProcessStatus.Continue;
+    }
+
+    private void forwardToJSP(
+            final PwmRequest pwmRequest
+    )
+            throws IOException, ServletException, PwmUnrecoverableException
+    {
+        pwmRequest.forwardToJsp( JspUrl.FULL_PAGE_HEALTH );
+    }
+
+    @ActionHandler( action = "value" )
+    private ProcessStatus bogusValueHandler( final PwmRequest pwmRequest )
+    {
+        // bogus method to satisfy test case
+        return ProcessStatus.Continue;
+    }
+}

+ 1 - 0
server/src/main/java/password/pwm/http/servlet/PwmServletDefinition.java

@@ -95,6 +95,7 @@ public enum PwmServletDefinition
     ConfigManager_Wordlists( ConfigManagerWordlistServlet.class, ConfigManagerBean.class ),
     ConfigManager_LocalDB( ConfigManagerLocalDBServlet.class, ConfigManagerBean.class ),
     ConfigManager_Certificates( ConfigManagerCertificatesServlet.class, ConfigManagerBean.class ),
+    FullPageHealth( FullPageHealthServlet.class, null ),
 
     NewUser( NewUserServlet.class, NewUserBean.class ),
     ActivateUser( ActivateUserServlet.class, ActivateUserBean.class ),

+ 1 - 29
server/src/main/java/password/pwm/http/servlet/admin/AdminServlet.java

@@ -61,8 +61,8 @@ import password.pwm.svc.report.ReportCsvUtility;
 import password.pwm.svc.report.ReportService;
 import password.pwm.svc.report.UserCacheRecord;
 import password.pwm.svc.stats.StatisticsManager;
-import password.pwm.util.i18n.LocaleHelper;
 import password.pwm.util.db.DatabaseException;
+import password.pwm.util.i18n.LocaleHelper;
 import password.pwm.util.java.ClosableIterator;
 import password.pwm.util.java.JavaHelper;
 import password.pwm.util.java.JsonUtil;
@@ -75,7 +75,6 @@ import password.pwm.util.logging.PwmLogEvent;
 import password.pwm.util.logging.PwmLogLevel;
 import password.pwm.util.logging.PwmLogger;
 import password.pwm.ws.server.RestResultBean;
-import password.pwm.ws.server.rest.RestStatisticsServer;
 
 import javax.servlet.ServletException;
 import javax.servlet.annotation.WebServlet;
@@ -132,7 +131,6 @@ public class AdminServlet extends ControlledPwmServlet
         auditData( HttpMethod.GET ),
         sessionData( HttpMethod.GET ),
         intruderData( HttpMethod.GET ),
-        statistics( HttpMethod.GET ),
         startPwNotifyJob( HttpMethod.POST ),
         readPwNotifyStatus( HttpMethod.POST ),
         readPwNotifyLog( HttpMethod.POST ),
@@ -545,32 +543,6 @@ public class AdminServlet extends ControlledPwmServlet
         return ProcessStatus.Halt;
     }
 
-    @ActionHandler( action = "statistics" )
-    private ProcessStatus restStatisticsHandler( final PwmRequest pwmRequest )
-            throws ChaiUnavailableException, PwmUnrecoverableException, IOException
-    {
-        final String statKey = pwmRequest.readParameterAsString( "statKey" );
-        final String statName = pwmRequest.readParameterAsString( "statName" );
-        final String days = pwmRequest.readParameterAsString( "days" );
-
-        final StatisticsManager statisticsManager = pwmRequest.getPwmApplication().getStatisticsManager();
-        final RestStatisticsServer.OutputVersion1.JsonOutput jsonOutput = new RestStatisticsServer.OutputVersion1.JsonOutput();
-        jsonOutput.EPS = RestStatisticsServer.OutputVersion1.addEpsStats( statisticsManager );
-
-        if ( statName != null && statName.length() > 0 )
-        {
-            jsonOutput.nameData = RestStatisticsServer.OutputVersion1.doNameStat( statisticsManager, statName, days );
-        }
-        else
-        {
-            jsonOutput.keyData = RestStatisticsServer.OutputVersion1.doKeyStat( statisticsManager, statKey );
-        }
-
-        final RestResultBean restResultBean = RestResultBean.withData( jsonOutput );
-        pwmRequest.outputJsonResult( restResultBean );
-        return ProcessStatus.Halt;
-    }
-
     private void processDebugUserSearch( final PwmRequest pwmRequest )
             throws PwmUnrecoverableException
     {

+ 211 - 0
webapp/src/main/webapp/WEB-INF/jsp/fullpagehealth.jsp

@@ -0,0 +1,211 @@
+<%--
+ ~ Password Management Servlets (PWM)
+ ~ http://www.pwm-project.org
+ ~
+ ~ Copyright (c) 2006-2009 Novell, Inc.
+ ~ Copyright (c) 2009-2018 The PWM Project
+ ~
+ ~ 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 2 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, write to the Free Software
+ ~ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+--%>
+
+<%@ page import="password.pwm.error.ErrorInformation" %>
+<%@ page import="password.pwm.error.PwmError" %>
+<%@ page import="password.pwm.http.JspUtility" %>
+<%@ page import="password.pwm.http.PwmSessionWrapper" %>
+<%@ page import="password.pwm.svc.stats.Statistic" %>
+<%@ page import="java.util.Locale" %>
+
+<!DOCTYPE html>
+<% JspUtility.setFlag(pageContext, PwmRequestFlag.NO_IDLE_TIMEOUT);%>
+<% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_FOOTER_TEXT); %>
+<% JspUtility.setFlag(pageContext, PwmRequestFlag.INCLUDE_CONFIG_CSS);%>
+<%@ page language="java" session="true" isThreadSafe="true"
+         contentType="text/html" %>
+<%@ taglib uri="pwm" prefix="pwm" %>
+<html lang="<pwm:value name="<%=PwmValue.localeCode%>"/>" dir="<pwm:value name="<%=PwmValue.localeDir%>"/>">
+<%@ include file="/WEB-INF/jsp/fragment/header.jsp" %>
+<body id="body" class="nihilo" style="background-color: black">
+<div id="centerbody" style="margin-top: 0">
+    <div id style="z-index: 3; position: relative; background: white; opacity: 0.9">
+        <table id="form">
+            <tr>
+                <td class="title" colspan="10">
+                    <pwm:display key="Title_Application"/> Health
+                </td>
+            </tr>
+            <tr>
+                <td colspan="10"  style="margin:0; padding:0">
+                    <div id="healthBody" class="noborder nomargin nopadding">
+                        <div class="WaitDialogBlank"></div>
+                    </div>
+                </td>
+            </tr>
+            <tr>
+                <td colspan="10" style="margin:0; padding:0">
+                    <div style="max-width: 600px; text-align: center">
+                        <div id="EPS-GAUGE-AUTHENTICATION_MINUTE" style="float: left; width: 33%">Authentications</div>
+                        <div id="EPS-GAUGE-PASSWORD_CHANGES_MINUTE" style="float: left; width: 33%">Password Changes</div>
+                        <div id="EPS-GAUGE-INTRUDER_ATTEMPTS_MINUTE" style="float: left; width: 33%">Intruder Attempts</div>
+                    </div>
+                    <div style="width: 100%; font-size: smaller; font-style: italic; text-align: center">Events Per Minute</div>
+                </td>
+            </tr>
+        </table>
+    </div>
+</div>
+<div id="floatparent">
+</div>
+<pwm:script>
+    <script type="text/javascript">
+        var H_RANGE = 20;
+        var V_RANGE = 20;
+        var MAX_NODES = 50;
+
+        var splatCount = 0;
+        var errorColor = '#d20734';
+        var posV = 0;
+        var posH = 0;
+        var deltaV = Math.floor((Math.random() * V_RANGE * 2)) - V_RANGE;
+        var deltaH = Math.floor((Math.random() * H_RANGE * 2)) - H_RANGE;
+
+        function drawNextSprite() {
+            require(["dojo","dojo/window"],function(dojo){
+                var floatParent = PWM_MAIN.getObject("floatparent");
+                var vs = dojo.window.getBox();
+
+                posV += deltaV;
+                posH += deltaH;
+
+                var styleText = "position: absolute; ";
+                styleText += "top: " + posV + "px; ";
+                styleText += "left: " + posH +"px; ";
+                styleText += "padding: 4px; z-index:2;";
+                styleText += "filter:alpha(opacity=30); opacity: 0.8; ";
+                styleText += "width:15px; height:15px";
+
+
+                splatCount++;
+                var divId = "randomPwDiv" + splatCount % MAX_NODES;
+                { // remove old node
+                    var existingDiv = PWM_MAIN.getObject(divId);
+                    if (existingDiv != null) {
+                        floatParent.removeChild(existingDiv);
+                    }
+                }
+
+                var div = document.createElement('div');
+                //div.innerHTML = '&nbsp;';
+                div.id = divId;
+                div.setAttribute("class",'health-' + PWM_GLOBAL['pwm-health']);
+
+                div.setAttribute("style",styleText);
+                floatParent.appendChild(div);
+
+                var change = false;
+                if (posV < 0) {
+                    posV += deltaV * -1;
+                    deltaV = Math.floor((Math.random() * V_RANGE));
+                    change = true;
+                } else if (posV + div.offsetHeight > vs.h) {
+                    posV += deltaV * -1;
+                    deltaV = Math.floor((Math.random() * V_RANGE)) * -1;
+                    change = true;
+                }
+                if (posH < 0) {
+                    posH += deltaH * -1;
+                    deltaH = Math.floor((Math.random() * H_RANGE));
+                    change = true;
+                } else if (posH + div.offsetWidth > vs.w) {
+                    posH += deltaH * -1;
+                    deltaH = Math.floor((Math.random() * H_RANGE)) * -1;
+                    change = true;
+                }
+                if (change) {
+                    div.setAttribute('style','display:none');
+                    //splatCount--;
+                    //deltaV = deltaV == 0 ? 1 : deltaV;
+                    //deltaH = deltaH == 0 ? 1 : deltaH;
+                    //drawNextSprite();
+                    //return;
+                }
+                var timeOutTime = 1000 - (PWM_GLOBAL['epsActivityCount'] != null ? Math.floor(PWM_GLOBAL['epsActivityCount']) : 0);
+                timeOutTime = timeOutTime < 100 ? 100 : timeOutTime;
+                setTimeout(function(){
+                    drawNextSprite();
+                },timeOutTime);
+            });
+        }
+
+        function handleWarnFlash() {
+            if (PWM_GLOBAL['pwm-health'] === "WARN") {
+                PWM_MAIN.flashDomElement(errorColor,'body',3000);
+            }
+        }
+
+        function verticalCenter(divName) {
+            require(["dojo","dojo/window"],function(dojo){
+                var vs = dojo.window.getBox();
+                if (document.getElementById) {
+                    var windowHeight = vs.h;
+                    if (windowHeight > 0) {
+                        var contentElement = document.getElementById(divName);
+                        var contentHeight = contentElement.offsetHeight;
+                        if (windowHeight - contentHeight > 0) {
+                            contentElement.style.position = 'relative';
+                            contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
+                        }
+                        else {
+                            contentElement.style.position = 'static';
+                        }
+                    }
+                }
+            });
+        }
+
+        function startupHealthPage() {
+            PWM_GLOBAL['pwm-health'] = 'GOOD';
+            require(["dojo","dojo/domReady!","dojo/window"],function(dojo){
+                PWM_MAIN.flashDomElement('white','body',9000);
+
+                var vs = dojo.window.getBox();
+                posH = Math.floor((Math.random() * (vs.w - 30)));
+                posV = Math.floor((Math.random() * (vs.h - 100)));
+
+                setInterval(function(){
+                    handleWarnFlash();
+                },30 * 1000);
+
+                drawNextSprite();
+
+                PWM_ADMIN.showAppHealth('healthBody', {showTimestamp:true});
+                PWM_ADMIN.showStatChart('<%=Statistic.PASSWORD_CHANGES%>',1,'statsChart',{refreshTime:31*1000});
+
+                verticalCenter('centerbody');
+                setInterval(function(){
+                    verticalCenter('centerbody');
+                }, 1000);
+
+            });
+        }
+
+        PWM_GLOBAL['startupFunctions'].push(function(){
+            startupHealthPage();
+        });
+    </script>
+</pwm:script>
+<pwm:script-ref url="/public/resources/js/admin.js"/>
+<%@ include file="/WEB-INF/jsp/fragment/footer.jsp" %>
+</body>
+</html>

+ 16 - 186
webapp/src/main/webapp/public/health.jsp

@@ -20,201 +20,31 @@
  ~ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 --%>
 
-<%@ page import="password.pwm.error.ErrorInformation" %>
-<%@ page import="password.pwm.error.PwmError" %>
 <%@ page import="password.pwm.http.JspUtility" %>
-<%@ page import="password.pwm.http.PwmSessionWrapper" %>
-<%@ page import="password.pwm.svc.stats.Statistic" %>
-<%@ page import="java.util.Locale" %>
+<%@ page import="password.pwm.i18n.Config" %>
 
 <!DOCTYPE html>
-<% JspUtility.setFlag(pageContext, PwmRequestFlag.NO_IDLE_TIMEOUT);%>
-<% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_FOOTER_TEXT); %>
-<% JspUtility.setFlag(pageContext, PwmRequestFlag.INCLUDE_CONFIG_CSS);%>
 <%@ page language="java" session="true" isThreadSafe="true"
          contentType="text/html" %>
 <%@ taglib uri="pwm" prefix="pwm" %>
 <html lang="<pwm:value name="<%=PwmValue.localeCode%>"/>" dir="<pwm:value name="<%=PwmValue.localeDir%>"/>">
-<%@ include file="/WEB-INF/jsp/fragment/header.jsp" %>
-<% try { JspUtility.getPwmSession(pageContext).unauthenticateUser(JspUtility.getPwmRequest(pageContext)); } catch (Exception e) { }%>
-<%
-    if (!ContextManager.getPwmApplication(request).getConfig().readSettingAsBoolean(PwmSetting.ENABLE_EXTERNAL_WEBSERVICES)) {
-        final Locale locale = PwmSessionWrapper.readPwmSession(request).getSessionStateBean().getLocale();
-        final ErrorInformation errorInformation = new ErrorInformation(PwmError.ERROR_SERVICE_NOT_AVAILABLE,
-                "Configuration setting " + PwmSetting.ENABLE_EXTERNAL_WEBSERVICES.toMenuLocationDebug(null,locale) + " must be enabled for this page to function.");
-        PwmRequest.forRequest(request,response).respondWithError(errorInformation);
-    }
-%>
-<body id="body" class="nihilo" style="background-color: black">
-<div id="centerbody" style="margin-top: 0">
-    <div id style="z-index: 3; position: relative; background: white; opacity: 0.9">
-        <table id="form">
-            <tr>
-                <td class="title" colspan="10">
-                    <pwm:display key="Title_Application"/> Health
-                </td>
-            </tr>
-            <tr>
-                <td colspan="10"  style="margin:0; padding:0">
-                    <div id="healthBody" class="noborder nomargin nopadding">
-                        <div class="WaitDialogBlank"></div>
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <td colspan="10" style="margin:0; padding:0">
-                    <div style="max-width: 600px; text-align: center">
-                        <div id="EPS-GAUGE-AUTHENTICATION_MINUTE" style="float: left; width: 33%">Authentications</div>
-                        <div id="EPS-GAUGE-PASSWORD_CHANGES_MINUTE" style="float: left; width: 33%">Password Changes</div>
-                        <div id="EPS-GAUGE-INTRUDER_ATTEMPTS_MINUTE" style="float: left; width: 33%">Intruder Attempts</div>
-                    </div>
-                    <div style="width: 100%; font-size: smaller; font-style: italic; text-align: center">Events Per Minute</div>
-                </td>
-            </tr>
-        </table>
+<jsp:include page="/WEB-INF/jsp/fragment/header.jsp"/>
+<body>
+<meta http-equiv="refresh" content="0;url=<pwm:context/><pwm:url url="/public/health"/>"/>
+<div id="wrapper">
+    <% final String PageName = JspUtility.localizedString(pageContext,"Redirect",Config.class);%>
+    <jsp:include page="/WEB-INF/jsp/fragment/header-body.jsp">
+        <jsp:param name="pwm.PageName" value="<%=PageName%>"/>
+    </jsp:include>
+    <div id="content">
+        <div id="centerbody">
+            <h1 id="page-content-title">Redirect</h1>
+            <pwm:display key="Display_PleaseWait"/> <a href="<pwm:context/><pwm:url url="/public/health"/>"><pwm:display bundle="Admin" key="MenuItem_ConfigManager"/></a>
+        </div>
     </div>
+    <br class="clear"/>
 </div>
-<div id="floatparent">
-</div>
-<pwm:script>
-    <script type="text/javascript">
-        var H_RANGE = 20;
-        var V_RANGE = 20;
-        var MAX_NODES = 50;
-
-        var splatCount = 0;
-        var errorColor = '#d20734';
-        var posV = 0;
-        var posH = 0;
-        var deltaV = Math.floor((Math.random() * V_RANGE * 2)) - V_RANGE;
-        var deltaH = Math.floor((Math.random() * H_RANGE * 2)) - H_RANGE;
-
-        function drawNextSprite() {
-            require(["dojo","dojo/window"],function(dojo){
-                var floatParent = PWM_MAIN.getObject("floatparent");
-                var vs = dojo.window.getBox();
-
-                posV += deltaV;
-                posH += deltaH;
-
-                var styleText = "position: absolute; ";
-                styleText += "top: " + posV + "px; ";
-                styleText += "left: " + posH +"px; ";
-                styleText += "padding: 4px; z-index:2;";
-                styleText += "filter:alpha(opacity=30); opacity: 0.8; ";
-                styleText += "width:15px; height:15px";
-
-
-                splatCount++;
-                var divId = "randomPwDiv" + splatCount % MAX_NODES;
-                { // remove old node
-                    var existingDiv = PWM_MAIN.getObject(divId);
-                    if (existingDiv != null) {
-                        floatParent.removeChild(existingDiv);
-                    }
-                }
-
-                var div = document.createElement('div');
-                //div.innerHTML = '&nbsp;';
-                div.id = divId;
-                div.setAttribute("class",'health-' + PWM_GLOBAL['pwm-health']);
-
-                div.setAttribute("style",styleText);
-                floatParent.appendChild(div);
-
-                var change = false;
-                if (posV < 0) {
-                    posV += deltaV * -1;
-                    deltaV = Math.floor((Math.random() * V_RANGE));
-                    change = true;
-                } else if (posV + div.offsetHeight > vs.h) {
-                    posV += deltaV * -1;
-                    deltaV = Math.floor((Math.random() * V_RANGE)) * -1;
-                    change = true;
-                }
-                if (posH < 0) {
-                    posH += deltaH * -1;
-                    deltaH = Math.floor((Math.random() * H_RANGE));
-                    change = true;
-                } else if (posH + div.offsetWidth > vs.w) {
-                    posH += deltaH * -1;
-                    deltaH = Math.floor((Math.random() * H_RANGE)) * -1;
-                    change = true;
-                }
-                if (change) {
-                    div.setAttribute('style','display:none');
-                    //splatCount--;
-                    //deltaV = deltaV == 0 ? 1 : deltaV;
-                    //deltaH = deltaH == 0 ? 1 : deltaH;
-                    //drawNextSprite();
-                    //return;
-                }
-                var timeOutTime = 1000 - (PWM_GLOBAL['epsActivityCount'] != null ? Math.floor(PWM_GLOBAL['epsActivityCount']) : 0);
-                timeOutTime = timeOutTime < 100 ? 100 : timeOutTime;
-                setTimeout(function(){
-                    drawNextSprite();
-                },timeOutTime);
-            });
-        }
-
-        function handleWarnFlash() {
-            if (PWM_GLOBAL['pwm-health'] === "WARN") {
-                PWM_MAIN.flashDomElement(errorColor,'body',3000);
-            }
-        }
-
-        function verticalCenter(divName) {
-            require(["dojo","dojo/window"],function(dojo){
-                var vs = dojo.window.getBox();
-                if (document.getElementById) {
-                    var windowHeight = vs.h;
-                    if (windowHeight > 0) {
-                        var contentElement = document.getElementById(divName);
-                        var contentHeight = contentElement.offsetHeight;
-                        if (windowHeight - contentHeight > 0) {
-                            contentElement.style.position = 'relative';
-                            contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
-                        }
-                        else {
-                            contentElement.style.position = 'static';
-                        }
-                    }
-                }
-            });
-        }
-
-        function startupHealthPage() {
-            PWM_GLOBAL['pwm-health'] = 'GOOD';
-            require(["dojo","dojo/domReady!","dojo/window"],function(dojo){
-                PWM_MAIN.flashDomElement('white','body',9000);
-
-                var vs = dojo.window.getBox();
-                posH = Math.floor((Math.random() * (vs.w - 30)));
-                posV = Math.floor((Math.random() * (vs.h - 100)));
-
-                setInterval(function(){
-                    handleWarnFlash();
-                },30 * 1000);
-
-                drawNextSprite();
-
-                PWM_ADMIN.showAppHealth('healthBody', {showTimestamp:true});
-                PWM_ADMIN.showStatChart('<%=Statistic.PASSWORD_CHANGES%>',1,'statsChart',{refreshTime:31*1000});
-
-                verticalCenter('centerbody');
-                setInterval(function(){
-                    verticalCenter('centerbody');
-                }, 1000);
-
-            });
-        }
-
-        PWM_GLOBAL['startupFunctions'].push(function(){
-            startupHealthPage();
-        });
-    </script>
-</pwm:script>
-<pwm:script-ref url="/public/resources/js/admin.js"/>
 <%@ include file="/WEB-INF/jsp/fragment/footer.jsp" %>
 </body>
 </html>
+

+ 2 - 2
webapp/src/main/webapp/public/resources/js/admin.js

@@ -63,7 +63,7 @@ PWM_ADMIN.initAdminNavMenu = function() {
                     label: 'Full Page Health Status',
                     id: 'fullPageHealthStatus_dropitem',
                     onClick: function() {
-                        PWM_MAIN.gotoUrl(PWM_GLOBAL['url-context'] + '/public/health.jsp');
+                        PWM_MAIN.gotoUrl(PWM_GLOBAL['url-context'] + '/public/health');
                     }
                 }));
                 pMenu.addChild(new MenuSeparator());
@@ -618,6 +618,7 @@ PWM_ADMIN.showStatChart = function(statName,days,divName,options) {
     var doRefresh = options['refreshTime']
         ? function(){setTimeout(function(){PWM_ADMIN.showStatChart(statName,days,divName,options);},options['refreshTime']);}
         : function(){};
+    var statsGetUrl = PWM_MAIN.addParamToUrl( PWM_GLOBAL['url-context'] + '/public/api',"processAction","statistics");
     var epsTypes = PWM_GLOBAL['epsTypes'];
     var epsDurations = PWM_GLOBAL['epsDurations'];
     require(["dojo",
@@ -631,7 +632,6 @@ PWM_ADMIN.showStatChart = function(statName,days,divName,options) {
             "dojox/gauges/GlossyCircularGauge",
             "dojo/domReady!"],
         function(dojo,dijit,registry){
-            var statsGetUrl = PWM_MAIN.addParamToUrl(window.location.href,"processAction","statistics");
             statsGetUrl = PWM_MAIN.addParamToUrl(statsGetUrl, "statName", statName);
             statsGetUrl = PWM_MAIN.addParamToUrl(statsGetUrl, "days", days);