private boolean canSeeDetails(SecurityContext securityContext, ShowDetails showDetails) { if (showDetails == ShowDetails.NEVER || (showDetails == ShowDetails.WHEN_AUTHORIZED && (securityContext.getPrincipal() == null || !isUserInRole(securityContext)))) { return false; } return true; }
/** * Maps the given {@code health} to a {@link WebEndpointResponse}, honouring the given * {@code showDetails} using the given {@code securityContext}. * @param health the health to map * @param securityContext the security context * @param showDetails when to show details in the response * @return the mapped response */ public WebEndpointResponse<Health> map(Health health, SecurityContext securityContext, ShowDetails showDetails) { if (showDetails == ShowDetails.NEVER || (showDetails == ShowDetails.WHEN_AUTHORIZED && (securityContext.getPrincipal() == null || !isUserInRole(securityContext)))) { health = Health.status(health.getStatus()).build(); } return createWebEndpointResponse(health); }