Search in sources :

Example 1 with HttpHeader

use of password.pwm.http.HttpHeader in project pwm by pwm-project.

the class RequestInitializationFilter method makeHeaderDebugStr.

private static String makeHeaderDebugStr(final PwmRequest pwmRequest) {
    final Map<String, String> values = new LinkedHashMap<>();
    for (final HttpHeader header : new HttpHeader[] { HttpHeader.Referer, HttpHeader.Origin }) {
        values.put(header.getHttpName(), pwmRequest.readHeaderValueAsString(header));
    }
    values.put("target", pwmRequest.getHttpServletRequest().getRequestURL().toString());
    values.put("siteUrl", pwmRequest.getPwmApplication().getConfig().readSettingAsString(PwmSetting.PWM_SITE_URL));
    return StringUtil.mapToString(values);
}
Also used : HttpHeader(password.pwm.http.HttpHeader) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with HttpHeader

use of password.pwm.http.HttpHeader in project pwm by pwm-project.

the class PwmHttpClient method entityToDebugString.

String entityToDebugString(final String topLine, final Map<String, String> headers, final String body) {
    final StringBuilder msg = new StringBuilder();
    msg.append(topLine);
    if (StringUtil.isEmpty(body)) {
        msg.append(" (no body)");
    }
    msg.append("\n");
    for (final Map.Entry<String, String> headerEntry : headers.entrySet()) {
        final HttpHeader httpHeader = HttpHeader.forHttpHeader(headerEntry.getKey());
        if (httpHeader != null) {
            final boolean sensitive = httpHeader.isSensitive();
            msg.append("  header: ").append(httpHeader.getHttpName()).append("=");
            if (sensitive) {
                msg.append(PwmConstants.LOG_REMOVED_VALUE_REPLACEMENT);
            } else {
                msg.append(headerEntry.getValue());
            }
        } else {
            // We encountered a header name that doesn't have a corresponding enum in HttpHeader,
            // so we can't check the sensitive flag.
            msg.append("  header: ").append(headerEntry.getKey()).append("=").append(headerEntry.getValue());
        }
        msg.append("\n");
    }
    if (!StringUtil.isEmpty(body)) {
        msg.append("  body: ");
        final boolean alwaysOutput = Boolean.parseBoolean(pwmApplication.getConfig().readAppProperty(AppProperty.HTTP_CLIENT_ALWAYS_LOG_ENTITIES));
        if (alwaysOutput || !pwmHttpClientConfiguration.isMaskBodyDebugOutput()) {
            msg.append(body);
        } else {
            msg.append(PwmConstants.LOG_REMOVED_VALUE_REPLACEMENT);
        }
    }
    return msg.toString();
}
Also used : HttpHeader(password.pwm.http.HttpHeader) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)2 HttpHeader (password.pwm.http.HttpHeader)2 Map (java.util.Map)1