package org.apereo.cas.web.report;

import org.apache.commons.lang3.BooleanUtils;
import org.apereo.cas.configuration.CasConfigurationProperties;
import org.apereo.cas.configuration.model.core.monitor.MonitorProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.actuate.endpoint.mvc.AbstractNamedMvcEndpoint;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * This is {@link BaseCasMvcEndpoint}.
 *
 * @author Misagh Moayyed
 * @since 5.1.0
 */
public abstract class BaseCasMvcEndpoint extends AbstractNamedMvcEndpoint {
    /**
     * The constant LOGGER.
     */
    private static final Logger LOGGER = LoggerFactory.getLogger(BaseCasMvcEndpoint.class);


    /**
     * Instantiates a new Base cas mvc endpoint.
     * Endpoints are by default sensitive.
     *
     * @param name          the name
     * @param path          the path
     * @param endpoint      the endpoint
     * @param casProperties the cas properties
     */
    public BaseCasMvcEndpoint(final String name, final String path,
                              final MonitorProperties.BaseEndpoint endpoint,
                              final CasConfigurationProperties casProperties) {
        super(name, path, casProperties.getMonitor().getEndpoints().isSensitive());
        setSensitive(endpoint.isSensitive());

        final boolean b = casProperties.getMonitor().getEndpoints().isEnabled() || BooleanUtils.toBoolean(endpoint.isEnabled());
        setEnabled(b);
    }

    /**
     * Ensure endpoint access is authorized.
     *
     * @param request  the request
     * @param response the response
     */
    protected void ensureEndpointAccessIsAuthorized(final HttpServletRequest request,
                                                    final HttpServletResponse response) {
        if (!isEnabled()) {
            response.setStatus(HttpStatus.UNAUTHORIZED.value());
            throw new UnuauthorizedEndpointException();
        }
    }

    /**
     * The type Unuauthorized endpoint exception.
     */
    @ResponseStatus(value = HttpStatus.UNAUTHORIZED, reason = "Access Denied")
    private static class UnuauthorizedEndpointException extends RuntimeException {
        /**
         * The constant serialVersionUID.
         */
        private static final long serialVersionUID = 3192230382776656678L;
    }
}

@@ -1384,16 +1384,50 @@
 e, path,
+ true);%0A%0A        final boolean s =
  casProp
@@ -1478,57 +1478,93 @@
 ve()
-);%0A        setSensitive(endpoint.isSensitive());%0A
+ %7C%7C BooleanUtils.toBoolean(endpoint.isSensitive());%0A        setSensitive(s);%0A        
 %0A   
@@ -2078,55 +2078,68 @@
     
-response.setStatus(HttpStatus.UNAUTHORIZED.valu
+LOGGER.warn(%22Access to endpoint %5B%7B%7D%5D is not enabled%22, getNam
 e())

Allow for a single property to control all individual CAS endpoints