From 52f3042a5d4e19883afe39cf5734b03ad82ef673 Mon Sep 17 00:00:00 2001 From: James Albright Date: Wed, 16 Dec 2015 11:57:11 -0700 Subject: [PATCH 1/7] Added the ability to skip JSP compilation during development profile builds. --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index b27cb6230..9c5a74022 100644 --- a/pom.xml +++ b/pom.xml @@ -62,6 +62,7 @@ true true + true From 6ae71cb52cdab967ffb21e38c87b2efcbcc43ccb Mon Sep 17 00:00:00 2001 From: James Albright Date: Tue, 5 Jan 2016 16:18:34 -0700 Subject: [PATCH 2/7] Bug 938293 - [Enh] Add support for macros in password policy settings such as regex whitelist This checkin only addresses disallowed password values. I just wanted to push this out so Jason can make sure I'm accessing the MacroMaker properly. --- .../password/pwm/bean/PublicUserInfoBean.java | 8 ++++-- .../pwm/config/profile/PwmPasswordPolicy.java | 28 +++++++++++++------ .../forgottenpw/RemoteVerificationMethod.java | 4 ++- .../pwm/http/tag/PasswordRequirementsTag.java | 19 ++++++++++--- .../pwm/util/PwmPasswordRuleValidator.java | 12 ++++++-- .../pwm/util/macro/ExternalRestMacro.java | 22 +++++++++------ .../ws/client/rest/RestTokenDataClient.java | 15 ++++++---- .../pwm/ws/server/rest/RestStatusServer.java | 8 +++++- .../webapp/WEB-INF/jsp/helpdesk-detail.jsp | 4 ++- 9 files changed, 85 insertions(+), 35 deletions(-) diff --git a/src/main/java/password/pwm/bean/PublicUserInfoBean.java b/src/main/java/password/pwm/bean/PublicUserInfoBean.java index 4f9356826..51837a781 100644 --- a/src/main/java/password/pwm/bean/PublicUserInfoBean.java +++ b/src/main/java/password/pwm/bean/PublicUserInfoBean.java @@ -22,9 +22,12 @@ package password.pwm.bean; +import password.pwm.PwmConstants; import password.pwm.config.Configuration; import password.pwm.config.profile.PwmPasswordRule; +import password.pwm.http.JspUtility; import password.pwm.http.tag.PasswordRequirementsTag; +import password.pwm.util.macro.MacroMachine; import java.io.Serializable; import java.util.*; @@ -46,7 +49,7 @@ public class PublicUserInfoBean implements Serializable { public List passwordRules; public Map attributes; - public static PublicUserInfoBean fromUserInfoBean(final UserInfoBean userInfoBean, final Configuration config, final Locale locale) { + public static PublicUserInfoBean fromUserInfoBean(final UserInfoBean userInfoBean, final Configuration config, final Locale locale, final MacroMachine macroMachine) { final PublicUserInfoBean publicUserInfoBean = new PublicUserInfoBean(); publicUserInfoBean.userDN = (userInfoBean.getUserIdentity() == null) ? "" : userInfoBean.getUserIdentity().getUserDN(); publicUserInfoBean.ldapProfile = (userInfoBean.getUserIdentity() == null) ? "" : userInfoBean.getUserIdentity().getLdapProfileID(); @@ -73,7 +76,8 @@ public static PublicUserInfoBean fromUserInfoBean(final UserInfoBean userInfoBea publicUserInfoBean.passwordRules = PasswordRequirementsTag.getPasswordRequirementsStrings( userInfoBean.getPasswordPolicy(), config, - locale + locale, + macroMachine ); if (userInfoBean.getCachedAttributeValues() != null && !userInfoBean.getCachedAttributeValues().isEmpty()) { diff --git a/src/main/java/password/pwm/config/profile/PwmPasswordPolicy.java b/src/main/java/password/pwm/config/profile/PwmPasswordPolicy.java index 1f566489d..e5118f7aa 100644 --- a/src/main/java/password/pwm/config/profile/PwmPasswordPolicy.java +++ b/src/main/java/password/pwm/config/profile/PwmPasswordPolicy.java @@ -22,21 +22,31 @@ package password.pwm.config.profile; -import com.novell.ldapchai.ChaiPasswordPolicy; -import com.novell.ldapchai.ChaiPasswordRule; -import com.novell.ldapchai.util.DefaultChaiPasswordPolicy; -import com.novell.ldapchai.util.PasswordRuleHelper; -import com.novell.ldapchai.util.StringHelper; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.regex.Pattern; +import java.util.regex.PatternSyntaxException; + import password.pwm.config.UserPermission; import password.pwm.config.option.ADPolicyComplexity; import password.pwm.health.HealthMessage; import password.pwm.health.HealthRecord; import password.pwm.util.logging.PwmLogger; +import password.pwm.util.macro.MacroMachine; -import java.io.Serializable; -import java.util.*; -import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; +import com.novell.ldapchai.ChaiPasswordPolicy; +import com.novell.ldapchai.ChaiPasswordRule; +import com.novell.ldapchai.util.DefaultChaiPasswordPolicy; +import com.novell.ldapchai.util.PasswordRuleHelper; +import com.novell.ldapchai.util.StringHelper; /** diff --git a/src/main/java/password/pwm/http/servlet/forgottenpw/RemoteVerificationMethod.java b/src/main/java/password/pwm/http/servlet/forgottenpw/RemoteVerificationMethod.java index bd8867851..8b346397a 100644 --- a/src/main/java/password/pwm/http/servlet/forgottenpw/RemoteVerificationMethod.java +++ b/src/main/java/password/pwm/http/servlet/forgottenpw/RemoteVerificationMethod.java @@ -37,6 +37,7 @@ import password.pwm.http.client.PwmHttpClientResponse; import password.pwm.util.JsonUtil; import password.pwm.util.logging.PwmLogger; +import password.pwm.util.macro.MacroMachine; import password.pwm.util.secure.PwmRandom; import java.util.*; @@ -125,7 +126,8 @@ private void sendRemoteRequest(final Map userResponses) throws P RemoteVerificationRequestBean remoteVerificationRequestBean = new RemoteVerificationRequestBean(); remoteVerificationRequestBean.setResponseSessionID(this.remoteSessionID); - remoteVerificationRequestBean.setUserInfo(PublicUserInfoBean.fromUserInfoBean(userInfoBean, pwmApplication.getConfig(), locale)); + MacroMachine macroMachine = MacroMachine.forUser(pwmApplication, PwmConstants.DEFAULT_LOCALE, SessionLabel.SYSTEM_LABEL, userInfoBean.getUserIdentity()); + remoteVerificationRequestBean.setUserInfo(PublicUserInfoBean.fromUserInfoBean(userInfoBean, pwmApplication.getConfig(), locale, macroMachine)); remoteVerificationRequestBean.setUserResponses(userResponses); PwmHttpClientRequest pwmHttpClientRequest = new PwmHttpClientRequest( diff --git a/src/main/java/password/pwm/http/tag/PasswordRequirementsTag.java b/src/main/java/password/pwm/http/tag/PasswordRequirementsTag.java index d481b8364..0fc6e72f2 100644 --- a/src/main/java/password/pwm/http/tag/PasswordRequirementsTag.java +++ b/src/main/java/password/pwm/http/tag/PasswordRequirementsTag.java @@ -23,6 +23,8 @@ package password.pwm.http.tag; import password.pwm.PwmApplication; +import password.pwm.PwmConstants; +import password.pwm.bean.SessionLabel; import password.pwm.config.Configuration; import password.pwm.config.option.ADPolicyComplexity; import password.pwm.config.profile.NewUserProfile; @@ -36,11 +38,13 @@ import password.pwm.util.LocaleHelper; import password.pwm.util.StringUtil; import password.pwm.util.logging.PwmLogger; +import password.pwm.util.macro.MacroMachine; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.jsp.JspTagException; import javax.servlet.jsp.tagext.TagSupport; + import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -62,7 +66,8 @@ public class PasswordRequirementsTag extends TagSupport { public static List getPasswordRequirementsStrings( final PwmPasswordPolicy pwordPolicy, final Configuration config, - final Locale locale + final Locale locale, + final MacroMachine macroMachine ) { final List returnValues = new ArrayList<>(); final ADPolicyComplexity ADPolicyLevel = pwordPolicy.getRuleHelper().getADComplexityLevel(); @@ -213,7 +218,9 @@ public static List getPasswordRequirementsStrings( final StringBuilder fieldValue = new StringBuilder(); for (final String loopValue : setValue) { fieldValue.append(" "); - fieldValue.append(StringUtil.escapeHtml(loopValue)); + + String expandedValue = macroMachine.expandMacros(loopValue); + fieldValue.append(StringUtil.escapeHtml(expandedValue)); } returnValues.add( getLocalString(Message.Requirement_DisAllowedValues, fieldValue.toString(), locale, config)); @@ -334,12 +341,14 @@ public int doEndTag() final PwmSession pwmSession = pwmRequest.getPwmSession(); final PwmApplication pwmApplication = pwmRequest.getPwmApplication(); final Configuration config = pwmApplication.getConfig(); + final Locale locale = pwmSession.getSessionStateBean().getLocale(); + pwmSession.getSessionManager().getMacroMachine(pwmApplication); final PwmPasswordPolicy passwordPolicy; if (getForm() != null && getForm().equalsIgnoreCase("newuser")) { final NewUserProfile newUserProfile = NewUserServlet.getNewUserProfile(pwmRequest); - passwordPolicy = newUserProfile.getNewUserPasswordPolicy(pwmApplication, pwmSession.getSessionStateBean().getLocale()); + passwordPolicy = newUserProfile.getNewUserPasswordPolicy(pwmApplication, locale); } else { passwordPolicy = pwmSession.getUserInfoBean().getPasswordPolicy(); } @@ -348,9 +357,11 @@ public int doEndTag() if (configuredRuleText != null && configuredRuleText.length() > 0) { pageContext.getOut().write(configuredRuleText); } else { + MacroMachine macroMachine = pwmSession.getSessionManager().getMacroMachine(pwmApplication); + final String pre = prepend != null && prepend.length() > 0 ? prepend : ""; final String sep = separator != null && separator.length() > 0 ? separator : "
"; - final List requirementsList = getPasswordRequirementsStrings(passwordPolicy, config, pwmSession.getSessionStateBean().getLocale()); + final List requirementsList = getPasswordRequirementsStrings(passwordPolicy, config, locale, macroMachine); final StringBuilder requirementsText = new StringBuilder(); for (final String requirementStatement : requirementsList) { diff --git a/src/main/java/password/pwm/util/PwmPasswordRuleValidator.java b/src/main/java/password/pwm/util/PwmPasswordRuleValidator.java index 80304b11b..6c382f4f5 100644 --- a/src/main/java/password/pwm/util/PwmPasswordRuleValidator.java +++ b/src/main/java/password/pwm/util/PwmPasswordRuleValidator.java @@ -27,10 +27,12 @@ import com.novell.ldapchai.exception.ChaiError; import com.novell.ldapchai.exception.ChaiPasswordPolicyException; import com.novell.ldapchai.exception.ChaiUnavailableException; + import password.pwm.AppProperty; import password.pwm.PwmApplication; import password.pwm.PwmConstants; import password.pwm.bean.PublicUserInfoBean; +import password.pwm.bean.SessionLabel; import password.pwm.bean.UserInfoBean; import password.pwm.config.Configuration; import password.pwm.config.PwmSetting; @@ -38,9 +40,11 @@ import password.pwm.config.profile.PwmPasswordPolicy; import password.pwm.config.profile.PwmPasswordRule; import password.pwm.error.*; +import password.pwm.http.PwmSession; import password.pwm.svc.PwmService; import password.pwm.svc.stats.Statistic; import password.pwm.util.logging.PwmLogger; +import password.pwm.util.macro.MacroMachine; import password.pwm.util.operations.PasswordUtility; import password.pwm.ws.client.rest.RestClientHelper; @@ -211,12 +215,15 @@ public List internalPwmPolicyValidator( // check against disallowed values; if (!ruleHelper.getDisallowedValues().isEmpty()) { + MacroMachine macroMachine = MacroMachine.forUser(pwmApplication, PwmConstants.DEFAULT_LOCALE, SessionLabel.SYSTEM_LABEL, uiBean.getUserIdentity()); + final String lcasePwd = passwordString.toLowerCase(); final Set paramValues = new HashSet<>(ruleHelper.getDisallowedValues()); for (final String loopValue : paramValues) { if (loopValue != null && loopValue.length() > 0) { - final String loweredLoop = loopValue.toLowerCase(); + final String expandedValue = macroMachine.expandMacros(loopValue); + final String loweredLoop = expandedValue.toLowerCase(); if (lcasePwd.contains(loweredLoop)) { errorList.add(new ErrorInformation(PwmError.PASSWORD_USING_DISALLOWED_VALUE)); } @@ -542,7 +549,8 @@ public List invokeExternalRuleMethods( sendData.put("policy",policyData); } if (uiBean != null) { - final PublicUserInfoBean publicUserInfoBean = PublicUserInfoBean.fromUserInfoBean(uiBean, pwmApplication.getConfig(), locale); + MacroMachine macroMachine = MacroMachine.forUser(pwmApplication, PwmConstants.DEFAULT_LOCALE, SessionLabel.SYSTEM_LABEL, uiBean.getUserIdentity()); + final PublicUserInfoBean publicUserInfoBean = PublicUserInfoBean.fromUserInfoBean(uiBean, pwmApplication.getConfig(), locale, macroMachine); sendData.put("userInfo", publicUserInfoBean); } diff --git a/src/main/java/password/pwm/util/macro/ExternalRestMacro.java b/src/main/java/password/pwm/util/macro/ExternalRestMacro.java index 5f7ee78ca..9270b5b1f 100644 --- a/src/main/java/password/pwm/util/macro/ExternalRestMacro.java +++ b/src/main/java/password/pwm/util/macro/ExternalRestMacro.java @@ -22,19 +22,21 @@ package password.pwm.util.macro; -import com.google.gson.reflect.TypeToken; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Pattern; + import password.pwm.PwmApplication; import password.pwm.PwmConstants; import password.pwm.bean.PublicUserInfoBean; +import password.pwm.bean.SessionLabel; import password.pwm.bean.UserInfoBean; import password.pwm.error.PwmException; import password.pwm.util.JsonUtil; import password.pwm.util.logging.PwmLogger; import password.pwm.ws.client.rest.RestClientHelper; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Pattern; +import com.google.gson.reflect.TypeToken; /** * External macro @External1:@ where 1 is incremental configuration item. @@ -68,13 +70,15 @@ public String replaceValue( final String inputString = matchValue.substring(11,matchValue.length() -1); final Map sendData = new HashMap<>(); - if (userInfoBean != null) { - final PublicUserInfoBean publicUserInfoBean = PublicUserInfoBean.fromUserInfoBean(userInfoBean, pwmApplication.getConfig(), PwmConstants.DEFAULT_LOCALE); - sendData.put("userInfo", publicUserInfoBean); - } - sendData.put("input",inputString); try { + if (userInfoBean != null) { + MacroMachine macroMachine = MacroMachine.forUser(pwmApplication, PwmConstants.DEFAULT_LOCALE, SessionLabel.SYSTEM_LABEL, userInfoBean.getUserIdentity()); + final PublicUserInfoBean publicUserInfoBean = PublicUserInfoBean.fromUserInfoBean(userInfoBean, pwmApplication.getConfig(), PwmConstants.DEFAULT_LOCALE, macroMachine); + sendData.put("userInfo", publicUserInfoBean); + } + sendData.put("input",inputString); + final String requestBody = JsonUtil.serializeMap(sendData); final String responseBody = RestClientHelper.makeOutboundRestWSCall(pwmApplication, PwmConstants.DEFAULT_LOCALE, url, diff --git a/src/main/java/password/pwm/ws/client/rest/RestTokenDataClient.java b/src/main/java/password/pwm/ws/client/rest/RestTokenDataClient.java index 968ca65ff..f03711ef0 100644 --- a/src/main/java/password/pwm/ws/client/rest/RestTokenDataClient.java +++ b/src/main/java/password/pwm/ws/client/rest/RestTokenDataClient.java @@ -22,7 +22,11 @@ package password.pwm.ws.client.rest; -import com.novell.ldapchai.exception.ChaiUnavailableException; +import java.io.Serializable; +import java.util.LinkedHashMap; +import java.util.Locale; +import java.util.Map; + import password.pwm.PwmApplication; import password.pwm.PwmConstants; import password.pwm.bean.PublicUserInfoBean; @@ -37,11 +41,9 @@ import password.pwm.ldap.UserStatusReader; import password.pwm.util.JsonUtil; import password.pwm.util.logging.PwmLogger; +import password.pwm.util.macro.MacroMachine; -import java.io.Serializable; -import java.util.LinkedHashMap; -import java.util.Locale; -import java.util.Map; +import com.novell.ldapchai.exception.ChaiUnavailableException; public class RestTokenDataClient implements RestClient { @@ -108,7 +110,8 @@ private TokenDestinationData invoke( userIdentity ); - final PublicUserInfoBean publicUserInfoBean = PublicUserInfoBean.fromUserInfoBean(userInfoBean, pwmApplication.getConfig(), PwmConstants.DEFAULT_LOCALE); + MacroMachine macroMachine = MacroMachine.forUser(pwmApplication, PwmConstants.DEFAULT_LOCALE, SessionLabel.SYSTEM_LABEL, userInfoBean.getUserIdentity()); + final PublicUserInfoBean publicUserInfoBean = PublicUserInfoBean.fromUserInfoBean(userInfoBean, pwmApplication.getConfig(), PwmConstants.DEFAULT_LOCALE, macroMachine); sendData.put(RestClient.DATA_KEY_USERINFO, publicUserInfoBean); } diff --git a/src/main/java/password/pwm/ws/server/rest/RestStatusServer.java b/src/main/java/password/pwm/ws/server/rest/RestStatusServer.java index b9492ffef..59429aeec 100644 --- a/src/main/java/password/pwm/ws/server/rest/RestStatusServer.java +++ b/src/main/java/password/pwm/ws/server/rest/RestStatusServer.java @@ -22,7 +22,9 @@ package password.pwm.ws.server.rest; +import password.pwm.PwmConstants; import password.pwm.bean.PublicUserInfoBean; +import password.pwm.bean.SessionLabel; import password.pwm.bean.UserInfoBean; import password.pwm.error.ErrorInformation; import password.pwm.error.PwmError; @@ -35,6 +37,7 @@ import password.pwm.util.JsonUtil; import password.pwm.util.TimeDuration; import password.pwm.util.logging.PwmLogger; +import password.pwm.util.macro.MacroMachine; import password.pwm.ws.server.RestRequestBean; import password.pwm.ws.server.RestResultBean; import password.pwm.ws.server.RestServerHelper; @@ -46,6 +49,7 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; + import java.net.URISyntaxException; import java.util.Date; @@ -91,10 +95,12 @@ public Response doGetStatusData( userInfoBean = restRequestBean.getPwmSession().getUserInfoBean(); } final RestResultBean restResultBean = new RestResultBean(); + MacroMachine macroMachine = restRequestBean.getPwmSession().getSessionManager().getMacroMachine(restRequestBean.getPwmApplication()); restResultBean.setData(PublicUserInfoBean.fromUserInfoBean( userInfoBean, restRequestBean.getPwmApplication().getConfig(), - restRequestBean.getPwmSession().getSessionStateBean().getLocale() + restRequestBean.getPwmSession().getSessionStateBean().getLocale(), + macroMachine )); final StatisticsManager statsMgr = restRequestBean.getPwmApplication().getStatisticsManager(); diff --git a/src/main/webapp/WEB-INF/jsp/helpdesk-detail.jsp b/src/main/webapp/WEB-INF/jsp/helpdesk-detail.jsp index 8109f7da7..4649846a8 100644 --- a/src/main/webapp/WEB-INF/jsp/helpdesk-detail.jsp +++ b/src/main/webapp/WEB-INF/jsp/helpdesk-detail.jsp @@ -38,6 +38,7 @@ <%@ page import="password.pwm.svc.event.UserAuditRecord" %> <%@ page import="password.pwm.util.StringUtil" %> <%@ page import="password.pwm.util.TimeDuration" %> +<%@ page import="password.pwm.util.macro.MacroMachine" %> <%@ page import="java.text.DateFormat" %> <%@ page import="java.util.Date" %> <%@ page import="java.util.List" %> @@ -456,7 +457,8 @@
    <% - final List requirementLines = PasswordRequirementsTag.getPasswordRequirementsStrings(searchedUserInfo.getPasswordPolicy(), ContextManager.getPwmApplication(session).getConfig(), pwmSession.getSessionStateBean().getLocale()); %> + MacroMachine macroMachine = JspUtility.getPwmSession(pageContext).getSessionManager().getMacroMachine(ContextManager.getPwmApplication(session)); + final List requirementLines = PasswordRequirementsTag.getPasswordRequirementsStrings(searchedUserInfo.getPasswordPolicy(), ContextManager.getPwmApplication(session).getConfig(), pwmSession.getSessionStateBean().getLocale(), macroMachine); %> <% for (final String requirementLine : requirementLines) { %>
  • <%=requirementLine%>
  • From 5b13b06c248755af4ec33df8dda7b21dfe859422 Mon Sep 17 00:00:00 2001 From: James Albright Date: Wed, 6 Jan 2016 16:23:17 -0700 Subject: [PATCH 3/7] Updated to support macros in Password Change Message --- src/main/webapp/WEB-INF/jsp/changepassword.jsp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/WEB-INF/jsp/changepassword.jsp b/src/main/webapp/WEB-INF/jsp/changepassword.jsp index 2db4b98e4..3fd1086f3 100644 --- a/src/main/webapp/WEB-INF/jsp/changepassword.jsp +++ b/src/main/webapp/WEB-INF/jsp/changepassword.jsp @@ -22,6 +22,7 @@ <%@ page import="password.pwm.bean.PasswordStatus" %> +<%@ page import="password.pwm.util.macro.MacroMachine" %> <%@ page language="java" session="true" isThreadSafe="true" contentType="text/html" %> <%@ taglib uri="pwm" prefix="pwm" %> <% final PwmRequest changepassword_pwmRequest = PwmRequest.forRequest(request,response); %> @@ -43,9 +44,12 @@
- <% final String passwordPolicyChangeMessage = changepassword_pwmRequest.getPwmSession().getUserInfoBean().getPasswordPolicy().getRuleHelper().getChangeMessage(); %> + <% + final String passwordPolicyChangeMessage = changepassword_pwmRequest.getPwmSession().getUserInfoBean().getPasswordPolicy().getRuleHelper().getChangeMessage(); + MacroMachine macroMachine = JspUtility.getPwmSession(pageContext).getSessionManager().getMacroMachine(ContextManager.getPwmApplication(session)); + %> <% if (passwordPolicyChangeMessage.length() > 1) { %> -

<%= passwordPolicyChangeMessage %>

+

<%= macroMachine.expandMacros(passwordPolicyChangeMessage) %>

<% } %>
<%@ include file="fragment/message.jsp" %> From 89911108de2f71342dd5bddad68793d6ed4e0980 Mon Sep 17 00:00:00 2001 From: Jason Rivard Date: Sat, 16 Jan 2016 16:49:44 -0700 Subject: [PATCH 4/7] header username html updates --- .../java/password/pwm/http/tag/PwmIfTest.java | 52 +++++++++++++++++++ .../java/password/pwm/http/tag/PwmValue.java | 7 ++- src/main/java/password/pwm/i18n/Display.java | 1 - .../password/pwm/i18n/Display.properties | 1 - .../WEB-INF/jsp/fragment/header-body.jsp | 48 ++++++++++++----- src/main/webapp/public/resources/style.css | 2 +- 6 files changed, 92 insertions(+), 19 deletions(-) diff --git a/src/main/java/password/pwm/http/tag/PwmIfTest.java b/src/main/java/password/pwm/http/tag/PwmIfTest.java index 2f7777c93..97bd09070 100644 --- a/src/main/java/password/pwm/http/tag/PwmIfTest.java +++ b/src/main/java/password/pwm/http/tag/PwmIfTest.java @@ -7,7 +7,10 @@ import password.pwm.PwmConstants; import password.pwm.config.PwmSetting; import password.pwm.error.PwmUnrecoverableException; +import password.pwm.health.HealthMonitor; +import password.pwm.health.HealthStatus; import password.pwm.http.PwmRequest; +import password.pwm.svc.PwmService; import password.pwm.util.Helper; public enum PwmIfTest { @@ -43,6 +46,11 @@ public enum PwmIfTest { trialMode(new TrialModeTest()), configMode(new ConfigModeTest()), + healthWarningsPresent(new HealthWarningsPresentTest()), + usernameHasValue(new UsernameHasValueTest()), + + headerMenuIsVisible(new HeaderMenuIsVisibleTest()), + ; @@ -237,6 +245,50 @@ public boolean test(PwmRequest pwmRequest, Options options) throws ChaiUnavailab } } + private static class HealthWarningsPresentTest implements Test { + @Override + public boolean test(PwmRequest pwmRequest, Options options) throws ChaiUnavailableException, PwmUnrecoverableException { + final HealthMonitor healthMonitor = pwmRequest.getPwmApplication().getHealthMonitor(); + if (healthMonitor != null && healthMonitor.status() == PwmService.STATUS.OPEN) { + if (healthMonitor.getMostSevereHealthStatus() == HealthStatus.WARN) { + return true; + } + } + return false; + } + } + + private static class UsernameHasValueTest implements Test { + @Override + public boolean test(PwmRequest pwmRequest, Options options) throws ChaiUnavailableException, PwmUnrecoverableException { + final String usernameValue = PwmValue.username.getValueOutput().valueOutput(pwmRequest, null); + return usernameValue != null && !usernameValue.isEmpty(); + } + } + + + private static class HeaderMenuIsVisibleTest implements Test { + @Override + public boolean test(PwmRequest pwmRequest, Options options) throws ChaiUnavailableException, PwmUnrecoverableException { + if (PwmConstants.TRIAL_MODE) { + return true; + } + + if (pwmRequest.getPwmApplication().getApplicationMode() != PwmApplication.MODE.RUNNING) { + return true; + } + + if (pwmRequest.isAuthenticated()) { + if (pwmRequest.getPwmSession().getSessionManager().checkPermission(pwmRequest.getPwmApplication(), Permission.PWMADMIN)) { + return true; + } + } + + return false; + } + } + + static class Options { private boolean negate; private Permission permission; diff --git a/src/main/java/password/pwm/http/tag/PwmValue.java b/src/main/java/password/pwm/http/tag/PwmValue.java index af64f6bba..cb9734e14 100644 --- a/src/main/java/password/pwm/http/tag/PwmValue.java +++ b/src/main/java/password/pwm/http/tag/PwmValue.java @@ -9,7 +9,6 @@ import password.pwm.error.PwmUnrecoverableException; import password.pwm.http.PwmRequest; import password.pwm.i18n.Admin; -import password.pwm.i18n.Display; import password.pwm.util.LocaleHelper; import password.pwm.util.StringUtil; import password.pwm.util.logging.PwmLogger; @@ -29,7 +28,7 @@ public enum PwmValue { currentJspFilename(new CurrentJspFilenameOutput()), instanceID(new InstanceIDOutput()), headerMenuNotice(new HeaderMenuNoticeOutput()), - menuUsernameField(new HeaderUsernameField()) + username(new UsernameOutput()) ; @@ -159,7 +158,7 @@ public String valueOutput(PwmRequest pwmRequest, PageContext pageContext) throws } } - static class HeaderUsernameField implements ValueOutput { + static class UsernameOutput implements ValueOutput { @Override public String valueOutput(PwmRequest pwmRequest, PageContext pageContext) throws ChaiUnavailableException, PwmUnrecoverableException { if (pwmRequest.isAuthenticated()) { @@ -169,7 +168,7 @@ public String valueOutput(PwmRequest pwmRequest, PageContext pageContext) throws } } - return LocaleHelper.getLocalizedMessage(Display.Display_Menu, pwmRequest); + return ""; } } diff --git a/src/main/java/password/pwm/i18n/Display.java b/src/main/java/password/pwm/i18n/Display.java index 4abbd7971..6a92cfb1f 100644 --- a/src/main/java/password/pwm/i18n/Display.java +++ b/src/main/java/password/pwm/i18n/Display.java @@ -107,7 +107,6 @@ public enum Display implements PwmDisplayBundle { Display_Login, Display_LoginPasswordOnly, Display_Logout, - Display_Menu, Display_Minute, Display_Minutes, Display_NewUser, diff --git a/src/main/resources/password/pwm/i18n/Display.properties b/src/main/resources/password/pwm/i18n/Display.properties index f1ec873e6..2803b2150 100644 --- a/src/main/resources/password/pwm/i18n/Display.properties +++ b/src/main/resources/password/pwm/i18n/Display.properties @@ -96,7 +96,6 @@ Display_LeaveDirtyPasswordPage=If you leave this page, your password will not be Display_Login= Display_LoginPasswordOnly=Please enter your password below. Your current password is required to access this application. Display_Logout=You are now signed out.

Please close all internet browser windows before you try to sign in again. -Display_Menu=Menu Display_Minute=minute Display_Minutes=minutes Display_NAAF_PASSWORD=Please provide your NAAF authentication password. diff --git a/src/main/webapp/WEB-INF/jsp/fragment/header-body.jsp b/src/main/webapp/WEB-INF/jsp/fragment/header-body.jsp index 93fe607b9..4ab80562c 100644 --- a/src/main/webapp/WEB-INF/jsp/fragment/header-body.jsp +++ b/src/main/webapp/WEB-INF/jsp/fragment/header-body.jsp @@ -39,24 +39,48 @@

+
+
+ + +
+
+ +
+
+
+ +
+
+
+ + + +
+
+
+
+ <% if (!JspUtility.isFlag(request, PwmRequestFlag.HIDE_HEADER_BUTTONS)) { %> - - "/>" id="HomeButton"> - - - + + + "/>" id="HomeButton"> + + + + + + " id="LogoutButton"> + + + + - - " id="LogoutButton"> - - - - -
<% } %>
+ \ No newline at end of file diff --git a/src/main/webapp/public/resources/style.css b/src/main/webapp/public/resources/style.css index d4ce62bff..285f999d2 100644 --- a/src/main/webapp/public/resources/style.css +++ b/src/main/webapp/public/resources/style.css @@ -473,7 +473,7 @@ div.progress-container > div { position: relative; } -#header-username { +#header-menu-wrapper { /*temp assignment */ display:none; } From 418ad271df7d926a3c3c529b2a8bfacb8b11a0b5 Mon Sep 17 00:00:00 2001 From: Jason Rivard Date: Sat, 16 Jan 2016 18:17:29 -0700 Subject: [PATCH 5/7] configguide themability --- src/main/java/password/pwm/AppProperty.java | 1 + .../servlet/configguide/ConfigGuideServlet.java | 5 ++++- .../resources/password/pwm/AppProperty.properties | 1 + src/main/webapp/WEB-INF/jsp/configguide-app.jsp | 1 - .../webapp/WEB-INF/jsp/configguide-cr_storage.jsp | 1 - .../webapp/WEB-INF/jsp/configguide-database.jsp | 1 - src/main/webapp/WEB-INF/jsp/configguide-end.jsp | 1 - .../WEB-INF/jsp/configguide-ldap_admins.jsp | 1 - .../webapp/WEB-INF/jsp/configguide-ldap_cert.jsp | 1 - .../WEB-INF/jsp/configguide-ldap_context.jsp | 1 - .../webapp/WEB-INF/jsp/configguide-ldap_proxy.jsp | 1 - .../WEB-INF/jsp/configguide-ldap_schema.jsp | 2 -- .../WEB-INF/jsp/configguide-ldap_server.jsp | 1 - .../WEB-INF/jsp/configguide-ldap_testuser.jsp | 1 - .../webapp/WEB-INF/jsp/configguide-password.jsp | 1 - src/main/webapp/WEB-INF/jsp/configguide-start.jsp | 1 - .../webapp/WEB-INF/jsp/configguide-template.jsp | 1 - .../webapp/WEB-INF/jsp/fragment/header-body.jsp | 1 - src/main/webapp/public/resources/configStyle.css | 15 --------------- 19 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/main/java/password/pwm/AppProperty.java b/src/main/java/password/pwm/AppProperty.java index d07f1bf04..001faaa87 100644 --- a/src/main/java/password/pwm/AppProperty.java +++ b/src/main/java/password/pwm/AppProperty.java @@ -61,6 +61,7 @@ public enum AppProperty { CONFIG_EDITOR_QUERY_FILTER_TEST_LIMIT ("configEditor.queryFilter.testLimit"), CONFIG_EDITOR_IDLE_TIMEOUT ("configEditor.idleTimeoutSeconds"), CONFIG_GUIDE_IDLE_TIMEOUT ("configGuide.idleTimeoutSeconds"), + CONFIG_GUIDE_THEME ("configGuide.theme"), CONFIG_MANAGER_ZIPDEBUG_MAXLOGLINES ("configManager.zipDebug.maxLogLines"), CONFIG_MANAGER_ZIPDEBUG_MAXLOGSECONDS ("configManager.zipDebug.maxLogSeconds"), FORM_EMAIL_REGEX ("form.email.regexTest"), diff --git a/src/main/java/password/pwm/http/servlet/configguide/ConfigGuideServlet.java b/src/main/java/password/pwm/http/servlet/configguide/ConfigGuideServlet.java index 962ada72b..b1641ffbf 100644 --- a/src/main/java/password/pwm/http/servlet/configguide/ConfigGuideServlet.java +++ b/src/main/java/password/pwm/http/servlet/configguide/ConfigGuideServlet.java @@ -127,7 +127,9 @@ protected void processAction(final PwmRequest pwmRequest) if (pwmApplication.getSessionStateService().getBean(pwmRequest, ConfigGuideBean.class).getStep() == GuideStep.START) { pwmApplication.getSessionStateService().clearBean(pwmRequest, ConfigGuideBean.class); - pwmSession.getSessionStateBean().setTheme(null); + if (pwmSession.getSessionStateBean().getTheme() == null) { + pwmSession.getSessionStateBean().setTheme(pwmRequest.getConfig().readAppProperty(AppProperty.CONFIG_GUIDE_THEME)); + } } final ConfigGuideBean configGuideBean = pwmApplication.getSessionStateService().getBean(pwmRequest, ConfigGuideBean.class); @@ -479,6 +481,7 @@ private void restGotoStep(final PwmRequest pwmRequest, final ConfigGuideBean con final ContextManager contextManager = ContextManager.getContextManager(pwmRequest); try { writeConfig(contextManager, configGuideBean); + pwmRequest.getPwmSession().getSessionStateBean().setTheme(null); } catch (PwmException e) { final RestResultBean restResultBean = RestResultBean.fromError(e.getErrorInformation(), pwmRequest); pwmRequest.outputJsonResult(restResultBean); diff --git a/src/main/resources/password/pwm/AppProperty.properties b/src/main/resources/password/pwm/AppProperty.properties index 4f1110b99..a086d422a 100644 --- a/src/main/resources/password/pwm/AppProperty.properties +++ b/src/main/resources/password/pwm/AppProperty.properties @@ -53,6 +53,7 @@ config.newuser.passwordPolicyCacheMS=3600000 configEditor.queryFilter.testLimit=5000 configEditor.idleTimeoutSeconds=900 configGuide.idleTimeoutSeconds=3600 +configGuide.theme=pwm configManager.zipDebug.maxLogLines=100000 configManager.zipDebug.maxLogSeconds=30 form.email.regexTest=^[_+a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*$ diff --git a/src/main/webapp/WEB-INF/jsp/configguide-app.jsp b/src/main/webapp/WEB-INF/jsp/configguide-app.jsp index 88697c934..13642accd 100644 --- a/src/main/webapp/WEB-INF/jsp/configguide-app.jsp +++ b/src/main/webapp/WEB-INF/jsp/configguide-app.jsp @@ -23,7 +23,6 @@ --%> <% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_LOCALE); %> -<% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_THEME); %> <%@ page language="java" session="true" isThreadSafe="true" contentType="text/html" %> <% ConfigGuideBean configGuideBean = JspUtility.getSessionBean(pageContext, ConfigGuideBean.class);%> diff --git a/src/main/webapp/WEB-INF/jsp/configguide-cr_storage.jsp b/src/main/webapp/WEB-INF/jsp/configguide-cr_storage.jsp index ad65ddd9c..c79aabf54 100644 --- a/src/main/webapp/WEB-INF/jsp/configguide-cr_storage.jsp +++ b/src/main/webapp/WEB-INF/jsp/configguide-cr_storage.jsp @@ -22,7 +22,6 @@ --%> <% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_LOCALE); %> -<% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_THEME); %> <%@ page language="java" session="true" isThreadSafe="true" contentType="text/html" %> <% ConfigGuideBean configGuideBean = JspUtility.getSessionBean(pageContext, ConfigGuideBean.class);%> diff --git a/src/main/webapp/WEB-INF/jsp/configguide-database.jsp b/src/main/webapp/WEB-INF/jsp/configguide-database.jsp index a2f7e0a56..0b71ebe9d 100644 --- a/src/main/webapp/WEB-INF/jsp/configguide-database.jsp +++ b/src/main/webapp/WEB-INF/jsp/configguide-database.jsp @@ -24,7 +24,6 @@ --%> <% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_LOCALE); %> -<% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_THEME); %> <% Locale userLocale = JspUtility.locale(request); %> <% ConfigGuideBean configGuideBean = JspUtility.getSessionBean(pageContext, ConfigGuideBean.class);%> diff --git a/src/main/webapp/WEB-INF/jsp/configguide-end.jsp b/src/main/webapp/WEB-INF/jsp/configguide-end.jsp index 2ebe0a028..fa1bdbb6f 100644 --- a/src/main/webapp/WEB-INF/jsp/configguide-end.jsp +++ b/src/main/webapp/WEB-INF/jsp/configguide-end.jsp @@ -24,7 +24,6 @@ --%> <% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_LOCALE); %> -<% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_THEME); %> <%@ page language="java" session="true" isThreadSafe="true" contentType="text/html" %> <%@ taglib uri="pwm" prefix="pwm" %> diff --git a/src/main/webapp/WEB-INF/jsp/configguide-ldap_admins.jsp b/src/main/webapp/WEB-INF/jsp/configguide-ldap_admins.jsp index 848198fef..5a2fe235f 100644 --- a/src/main/webapp/WEB-INF/jsp/configguide-ldap_admins.jsp +++ b/src/main/webapp/WEB-INF/jsp/configguide-ldap_admins.jsp @@ -23,7 +23,6 @@ --%> <% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_LOCALE); %> -<% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_THEME); %> <%@ page language="java" session="true" isThreadSafe="true" contentType="text/html" %> <% ConfigGuideBean configGuideBean = JspUtility.getSessionBean(pageContext, ConfigGuideBean.class);%> diff --git a/src/main/webapp/WEB-INF/jsp/configguide-ldap_cert.jsp b/src/main/webapp/WEB-INF/jsp/configguide-ldap_cert.jsp index f97d96216..8ad3a10f2 100644 --- a/src/main/webapp/WEB-INF/jsp/configguide-ldap_cert.jsp +++ b/src/main/webapp/WEB-INF/jsp/configguide-ldap_cert.jsp @@ -29,7 +29,6 @@ --%> <% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_LOCALE); %> -<% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_THEME); %> <%@ page language="java" session="true" isThreadSafe="true" contentType="text/html" %> <% ConfigGuideBean configGuideBean = JspUtility.getSessionBean(pageContext, ConfigGuideBean.class);%> diff --git a/src/main/webapp/WEB-INF/jsp/configguide-ldap_context.jsp b/src/main/webapp/WEB-INF/jsp/configguide-ldap_context.jsp index 30eaedd66..1f6b63c28 100644 --- a/src/main/webapp/WEB-INF/jsp/configguide-ldap_context.jsp +++ b/src/main/webapp/WEB-INF/jsp/configguide-ldap_context.jsp @@ -23,7 +23,6 @@ --%> <% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_LOCALE); %> -<% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_THEME); %> <%@ page language="java" session="true" isThreadSafe="true" contentType="text/html" %> <% ConfigGuideBean configGuideBean = JspUtility.getSessionBean(pageContext, ConfigGuideBean.class);%> diff --git a/src/main/webapp/WEB-INF/jsp/configguide-ldap_proxy.jsp b/src/main/webapp/WEB-INF/jsp/configguide-ldap_proxy.jsp index 8509ea4e2..69cfb9b1b 100644 --- a/src/main/webapp/WEB-INF/jsp/configguide-ldap_proxy.jsp +++ b/src/main/webapp/WEB-INF/jsp/configguide-ldap_proxy.jsp @@ -22,7 +22,6 @@ --%> <% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_LOCALE); %> -<% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_THEME); %> <%@ page language="java" session="true" isThreadSafe="true" contentType="text/html" %> <% ConfigGuideBean configGuideBean = JspUtility.getSessionBean(pageContext, ConfigGuideBean.class);%> diff --git a/src/main/webapp/WEB-INF/jsp/configguide-ldap_schema.jsp b/src/main/webapp/WEB-INF/jsp/configguide-ldap_schema.jsp index fc345b21d..cee45d44a 100644 --- a/src/main/webapp/WEB-INF/jsp/configguide-ldap_schema.jsp +++ b/src/main/webapp/WEB-INF/jsp/configguide-ldap_schema.jsp @@ -23,11 +23,9 @@ --%> <% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_LOCALE); %> -<% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_THEME); %> <%@ page language="java" session="true" isThreadSafe="true" contentType="text/html" %> <% - final PwmRequest pwmRequest = PwmRequest.forRequest(request, response); ConfigGuideBean configGuideBean = JspUtility.getSessionBean(pageContext, ConfigGuideBean.class); boolean existingSchemaGood = false; String schemaActivityLog = ""; diff --git a/src/main/webapp/WEB-INF/jsp/configguide-ldap_server.jsp b/src/main/webapp/WEB-INF/jsp/configguide-ldap_server.jsp index ca920ff15..ffaaaa246 100644 --- a/src/main/webapp/WEB-INF/jsp/configguide-ldap_server.jsp +++ b/src/main/webapp/WEB-INF/jsp/configguide-ldap_server.jsp @@ -22,7 +22,6 @@ --%> <% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_LOCALE); %> -<% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_THEME); %> <%@ page language="java" session="true" isThreadSafe="true" contentType="text/html" %> <% ConfigGuideBean configGuideBean = JspUtility.getSessionBean(pageContext, ConfigGuideBean.class);%> diff --git a/src/main/webapp/WEB-INF/jsp/configguide-ldap_testuser.jsp b/src/main/webapp/WEB-INF/jsp/configguide-ldap_testuser.jsp index 77d8a150e..e493daf39 100644 --- a/src/main/webapp/WEB-INF/jsp/configguide-ldap_testuser.jsp +++ b/src/main/webapp/WEB-INF/jsp/configguide-ldap_testuser.jsp @@ -23,7 +23,6 @@ --%> <% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_LOCALE); %> -<% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_THEME); %> <%@ page language="java" session="true" isThreadSafe="true" contentType="text/html" %> <% ConfigGuideBean configGuideBean = JspUtility.getSessionBean(pageContext, ConfigGuideBean.class);%> diff --git a/src/main/webapp/WEB-INF/jsp/configguide-password.jsp b/src/main/webapp/WEB-INF/jsp/configguide-password.jsp index f278ced15..a02ab084d 100644 --- a/src/main/webapp/WEB-INF/jsp/configguide-password.jsp +++ b/src/main/webapp/WEB-INF/jsp/configguide-password.jsp @@ -22,7 +22,6 @@ --%> <% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_LOCALE); %> -<% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_THEME); %> <%@ page language="java" session="true" isThreadSafe="true" contentType="text/html" %> <%@ taglib uri="pwm" prefix="pwm" %> diff --git a/src/main/webapp/WEB-INF/jsp/configguide-start.jsp b/src/main/webapp/WEB-INF/jsp/configguide-start.jsp index 878a00fec..0cca27bd8 100644 --- a/src/main/webapp/WEB-INF/jsp/configguide-start.jsp +++ b/src/main/webapp/WEB-INF/jsp/configguide-start.jsp @@ -24,7 +24,6 @@ --%> <% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_LOCALE); %> -<% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_THEME); %> <% JspUtility.setFlag(pageContext, PwmRequestFlag.NO_IDLE_TIMEOUT); %> <%@ page language="java" session="true" isThreadSafe="true" contentType="text/html" %> diff --git a/src/main/webapp/WEB-INF/jsp/configguide-template.jsp b/src/main/webapp/WEB-INF/jsp/configguide-template.jsp index 72fb184ea..c5b565c65 100644 --- a/src/main/webapp/WEB-INF/jsp/configguide-template.jsp +++ b/src/main/webapp/WEB-INF/jsp/configguide-template.jsp @@ -22,7 +22,6 @@ --%> <% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_LOCALE); %> -<% JspUtility.setFlag(pageContext, PwmRequestFlag.HIDE_THEME); %> <%@ page language="java" session="true" isThreadSafe="true" contentType="text/html" %> <%@ taglib uri="pwm" prefix="pwm" %> diff --git a/src/main/webapp/WEB-INF/jsp/fragment/header-body.jsp b/src/main/webapp/WEB-INF/jsp/fragment/header-body.jsp index 4ab80562c..91565cb37 100644 --- a/src/main/webapp/WEB-INF/jsp/fragment/header-body.jsp +++ b/src/main/webapp/WEB-INF/jsp/fragment/header-body.jsp @@ -82,5 +82,4 @@ <% } %> - \ No newline at end of file diff --git a/src/main/webapp/public/resources/configStyle.css b/src/main/webapp/public/resources/configStyle.css index e825e6f5d..3233d83a4 100644 --- a/src/main/webapp/public/resources/configStyle.css +++ b/src/main/webapp/public/resources/configStyle.css @@ -163,21 +163,6 @@ body { padding-bottom: 10px; } -.btn { - font-family: Trebuchet MS, sans-serif; - padding: 2px 9px; - border-radius: 4px; - background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #3e374c), color-stop(1, #08070f) ); - background:linear-gradient(to bottom, #3e374c 5%, #08070f 100% ); -}.btn:hover { - background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #08070f), color-stop(1, #3e374c) ); - background:linear-gradient(to bottom, #08070f 5%, #3e374c 100% ); - }.btn:disabled { - color: #656565; - background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #4f485d), color-stop(1, #191820) ); - background:linear-gradient(to bottom, #4f485d 5%, #191820 100% ); - } - .menubutton.selected { box-shadow: none; font-weight: bold; From 19be593eb3b0f6534c12734fbe3e2bfcd565fa03 Mon Sep 17 00:00:00 2001 From: Jason Rivard Date: Tue, 19 Jan 2016 13:39:25 -0500 Subject: [PATCH 6/7] fixed issue with improper error handling for html clients (issue #31) --- .../pwm/http/PwmHttpRequestWrapper.java | 2 +- .../java/password/pwm/http/PwmRequest.java | 6 +++- .../java/password/pwm/http/PwmResponse.java | 32 +++++++++---------- .../pwm/http/servlet/ActivateUserServlet.java | 4 +-- src/main/java/password/pwm/util/Helper.java | 10 ++++++ 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/main/java/password/pwm/http/PwmHttpRequestWrapper.java b/src/main/java/password/pwm/http/PwmHttpRequestWrapper.java index 5b1bea3eb..a8271fc62 100644 --- a/src/main/java/password/pwm/http/PwmHttpRequestWrapper.java +++ b/src/main/java/password/pwm/http/PwmHttpRequestWrapper.java @@ -66,7 +66,7 @@ public boolean isJsonRequest() { public boolean isHtmlRequest() { final String acceptHeader = this.readHeaderValueAsString(PwmConstants.HttpHeader.Accept); - return acceptHeader.contains(PwmConstants.AcceptValue.json.getHeaderValue()); + return acceptHeader.contains(PwmConstants.AcceptValue.html.getHeaderValue()); } public String getContextPath() { diff --git a/src/main/java/password/pwm/http/PwmRequest.java b/src/main/java/password/pwm/http/PwmRequest.java index 8ff6fc8f1..d335270b5 100644 --- a/src/main/java/password/pwm/http/PwmRequest.java +++ b/src/main/java/password/pwm/http/PwmRequest.java @@ -147,7 +147,11 @@ public void respondWithError( ) throws IOException, ServletException { - getPwmResponse().respondWithError(errorInformation, forceLogout); + if (forceLogout) { + getPwmResponse().respondWithError(errorInformation, PwmResponse.Flag.ForceLogout); + } else { + getPwmResponse().respondWithError(errorInformation); + } } public void sendRedirect(final String redirectURL) diff --git a/src/main/java/password/pwm/http/PwmResponse.java b/src/main/java/password/pwm/http/PwmResponse.java index 92e8881c3..bb4b78eab 100644 --- a/src/main/java/password/pwm/http/PwmResponse.java +++ b/src/main/java/password/pwm/http/PwmResponse.java @@ -49,7 +49,8 @@ public class PwmResponse extends PwmHttpResponseWrapper { final private PwmRequest pwmRequest; public enum Flag { - AlwaysShowMessage + AlwaysShowMessage, + ForceLogout, } public PwmResponse( @@ -99,11 +100,10 @@ public void forwardToSuccessPage(final String message, final Flag... flags) if (showMessage) { LOGGER.trace(pwmSession, "skipping success page due to configuration setting."); - final StringBuilder redirectURL = new StringBuilder(); - redirectURL.append(pwmRequest.getContextPath()); - redirectURL.append(PwmServletDefinition.Command.servletUrl()); - redirectURL.append("?processAction=continue"); - sendRedirect(redirectURL.toString()); + final String redirectUrl = pwmRequest.getContextPath() + + PwmServletDefinition.Command.servletUrl() + + "?processAction=continue"; + sendRedirect(redirectUrl); return; } @@ -116,7 +116,7 @@ public void forwardToSuccessPage(final String message, final Flag... flags) public void respondWithError( final ErrorInformation errorInformation, - final boolean forceLogout + final Flag... flags ) throws IOException, ServletException { @@ -124,15 +124,8 @@ public void respondWithError( pwmRequest.setResponseError(errorInformation); - { - boolean showDetail = Helper.determineIfDetailErrorMsgShown(pwmRequest.getPwmApplication()); - final String errorStatusText = showDetail - ? errorInformation.toDebugStr() - : errorInformation.toUserStr(pwmRequest.getPwmSession(),pwmRequest.getPwmApplication()); - getHttpServletResponse().sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, errorStatusText); - } - - if (forceLogout) { + if (Helper.enumArrayContainsValue(flags, Flag.ForceLogout)) { + LOGGER.debug(pwmRequest, "forcing logout due to error " + errorInformation.toDebugStr()); pwmRequest.getPwmSession().unauthenticateUser(pwmRequest); } @@ -144,8 +137,13 @@ public void respondWithError( } catch (PwmUnrecoverableException e) { LOGGER.error("unexpected error sending user to error page: " + e.toString()); } + } else { + boolean showDetail = Helper.determineIfDetailErrorMsgShown(pwmRequest.getPwmApplication()); + final String errorStatusText = showDetail + ? errorInformation.toDebugStr() + : errorInformation.toUserStr(pwmRequest.getPwmSession(),pwmRequest.getPwmApplication()); + getHttpServletResponse().sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, errorStatusText); } - } diff --git a/src/main/java/password/pwm/http/servlet/ActivateUserServlet.java b/src/main/java/password/pwm/http/servlet/ActivateUserServlet.java index ac120d702..a238703d1 100644 --- a/src/main/java/password/pwm/http/servlet/ActivateUserServlet.java +++ b/src/main/java/password/pwm/http/servlet/ActivateUserServlet.java @@ -117,7 +117,7 @@ protected ActivateUserAction readProcessAction(final PwmRequest request) protected void processAction(final PwmRequest pwmRequest) throws ServletException, ChaiUnavailableException, IOException, PwmUnrecoverableException { - //Fetch the session state bean. + //Fetch the session state bean. final PwmSession pwmSession = pwmRequest.getPwmSession(); final PwmApplication pwmApplication = pwmRequest.getPwmApplication(); @@ -182,7 +182,7 @@ public void handleActivationRequest(final PwmRequest pwmRequest) pwmApplication.getSessionStateService().clearBean(pwmRequest, ActivateUserBean.class); final List configuredActivationForm = config.readSettingAsForm(PwmSetting.ACTIVATE_USER_FORM); - Map formValues = new HashMap(); + Map formValues = new HashMap<>(); try { //read the values from the request formValues = FormUtility.readFormValuesFromRequest(pwmRequest, configuredActivationForm, diff --git a/src/main/java/password/pwm/util/Helper.java b/src/main/java/password/pwm/util/Helper.java index 600fd89f7..7cc15c330 100644 --- a/src/main/java/password/pwm/util/Helper.java +++ b/src/main/java/password/pwm/util/Helper.java @@ -614,6 +614,12 @@ public static String throwableToString(final Throwable throwable) { return sw.toString(); } + /** + * Converts an exception to a string message. Handles cases where the message in the exception is null + * and/or there are multiple nested cause exceptions. + * @param e The exception to convert to a string + * @return A string containing any meaningful extractable cause information, suitable for debugging. + */ public static String readHostileExceptionMessage(Throwable e) { String errorMsg = e.getClass().getName(); if (e.getMessage() != null) { @@ -633,4 +639,8 @@ public static String readHostileExceptionMessage(Throwable e) { return errorMsg; } + + public static > boolean enumArrayContainsValue(final E[] enumArray, final E enumValue) { + return !(enumArray == null || enumArray.length == 0) && Arrays.asList(enumArray).contains(enumValue); + } } From fa35a746fd905689aeb9491d39e68a9534e27cfe Mon Sep 17 00:00:00 2001 From: Jason Rivard Date: Tue, 19 Jan 2016 13:44:05 -0500 Subject: [PATCH 7/7] fixed syntax error in openldap.ldif (issue #10) --- supplemental/ldif/openldap.ldif | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supplemental/ldif/openldap.ldif b/supplemental/ldif/openldap.ldif index 02a81a76d..c614f8c41 100644 --- a/supplemental/ldif/openldap.ldif +++ b/supplemental/ldif/openldap.ldif @@ -9,7 +9,7 @@ olcAttributeTypes: {2}( 1.3.6.1.4.1.35015.1.2.3 NAME 'pwmLastPwdUpda te' SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 ) olcAttributeTypes: {3}( 1.3.6.1.4.1.35015.1.2.4 NAME 'pwmGUID' SYNTA X 1.3.6.1.4.1.1466.115.121.1.15 ) -olcAttributeTypes: {1}( 1.3.6.1.4.1.35015.1.2.6 NAME 'pwmOtpSecret ' +olcAttributeTypes: {1}( 1.3.6.1.4.1.35015.1.2.6 NAME 'pwmOtpSecret' EQUALITY octetStringMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 ) olcObjectClasses: {0}( 1.3.6.1.4.1.591242.1.2010.04.16.1 NAME 'pwmUser' AUXILI ARY MAY ( pwmLastPwdUpdate $ pwmEventLog $ pwmResponseSet $ pwmOtpSecret $ pw