use of password.pwm.http.PwmRequest in project pwm by pwm-project.
the class PwmScriptRefTag method doEndTag.
public int doEndTag() throws javax.servlet.jsp.JspTagException {
try {
final PwmRequest pwmRequest = JspUtility.getPwmRequest(pageContext);
final String cspNonce = pwmRequest.getCspNonce();
String url = getUrl();
url = PwmUrlTag.convertUrl(url);
url = PwmUrlTag.insertContext(pageContext, url);
url = PwmUrlTag.insertResourceNonce(pwmRequest.getPwmApplication(), url);
final String output = "<script type=\"text/javascript\" nonce=\"" + cspNonce + "\" src=\"" + url + "\"></script><noscript></noscript>";
pageContext.getOut().write(output);
} catch (Exception e) {
LOGGER.error("error during scriptRef output of pwmFormID: " + e.getMessage());
}
return EVAL_PAGE;
}
use of password.pwm.http.PwmRequest in project pwm by pwm-project.
the class JspThrowableHandlerTag method jspOutput.
private String jspOutput(final String errorReference) {
Locale userLocale = PwmConstants.DEFAULT_LOCALE;
Configuration configuration = null;
try {
final PwmRequest pwmRequest = PwmRequest.forRequest((HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse());
userLocale = pwmRequest.getLocale();
configuration = pwmRequest.getConfig();
} catch (Exception e) {
LOGGER.error("error during pwmFormIDTag output of pwmFormID: " + e.getMessage());
}
final String[] strArgs = new String[] { errorReference };
return LocaleHelper.getLocalizedMessage(userLocale, Display.Display_ErrorReference, configuration, strArgs);
}
use of password.pwm.http.PwmRequest in project pwm by pwm-project.
the class PwmMacroTag method doEndTag.
public int doEndTag() throws JspTagException {
try {
final PwmRequest pwmRequest = PwmRequest.forRequest((HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse());
final MacroMachine macroMachine = pwmRequest.getPwmSession().getSessionManager().getMacroMachine(pwmRequest.getPwmApplication());
final String outputValue = macroMachine.expandMacros(value);
pageContext.getOut().write(outputValue);
} catch (PwmUnrecoverableException e) {
LOGGER.error("error while processing PwmMacroTag: " + e.getMessage());
} catch (Exception e) {
throw new JspTagException(e.getMessage(), e);
}
return EVAL_PAGE;
}
use of password.pwm.http.PwmRequest in project pwm by pwm-project.
the class UserInfoTag method doEndTag.
public int doEndTag() throws JspTagException {
try {
final PwmRequest pwmRequest = JspUtility.getPwmRequest(pageContext);
final PwmSession pwmSession = pwmRequest.getPwmSession();
if (pwmSession.isAuthenticated()) {
final String ldapValue = pwmSession.getUserInfo().readStringAttribute(attribute);
pageContext.getOut().write(StringUtil.escapeHtml(ldapValue == null ? "" : ldapValue));
}
} catch (Exception e) {
throw new JspTagException(e.getMessage());
}
return EVAL_PAGE;
}
use of password.pwm.http.PwmRequest in project pwm by pwm-project.
the class ErrorMessageTag method doEndTag.
public int doEndTag() throws javax.servlet.jsp.JspTagException {
try {
final PwmRequest pwmRequest = PwmRequest.forRequest((HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse());
PwmApplication pwmApplication = null;
try {
pwmApplication = ContextManager.getPwmApplication(pageContext.getSession());
} catch (PwmException e) {
/* noop */
}
if (pwmRequest == null || pwmApplication == null) {
return EVAL_PAGE;
}
final ErrorInformation error = (ErrorInformation) pwmRequest.getAttribute(PwmRequestAttribute.PwmErrorInfo);
if (error != null) {
final boolean allowHtml = Boolean.parseBoolean(pwmRequest.getConfig().readAppProperty(AppProperty.HTTP_ERRORS_ALLOW_HTML));
final boolean showErrorDetail = pwmApplication.determineIfDetailErrorMsgShown();
String outputMsg = error.toUserStr(pwmRequest.getPwmSession(), pwmApplication);
if (!allowHtml) {
outputMsg = StringUtil.escapeHtml(outputMsg);
}
if (showErrorDetail) {
final String errorDetail = error.toDebugStr() == null ? "" : " { " + error.toDebugStr() + " }";
// detail should always be escaped - it may contain untrusted data
outputMsg += "<span class='errorDetail'>" + StringUtil.escapeHtml(errorDetail) + "</span>";
}
outputMsg = outputMsg.replace("\n", "<br/>");
final MacroMachine macroMachine = pwmRequest.getPwmSession().getSessionManager().getMacroMachine(pwmApplication);
outputMsg = macroMachine.expandMacros(outputMsg);
pageContext.getOut().write(outputMsg);
}
} catch (PwmUnrecoverableException e) {
/* app not running */
} catch (Exception e) {
LOGGER.error("error executing error message tag: " + e.getMessage(), e);
throw new JspTagException(e.getMessage());
}
return EVAL_PAGE;
}
Aggregations