public EndpointRequestMatcher excluding(String... endpoints) { List<Object> excludes = new ArrayList<>(this.excludes); excludes.addAll(Arrays.asList((Object[]) endpoints)); return new EndpointRequestMatcher(this.includes, excludes, this.includeLinks); }
@Override protected RequestMatcher createDelegate(WebApplicationContext context, RequestMatcherFactory requestMatcherFactory) { PathMappedEndpoints pathMappedEndpoints = context .getBean(PathMappedEndpoints.class); RequestMatcherProvider matcherProvider = getRequestMatcherProvider(context); Set<String> paths = new LinkedHashSet<>(); if (this.includes.isEmpty()) { paths.addAll(pathMappedEndpoints.getAllPaths()); } streamPaths(this.includes, pathMappedEndpoints).forEach(paths::add); streamPaths(this.excludes, pathMappedEndpoints).forEach(paths::remove); List<RequestMatcher> delegateMatchers = getDelegateMatchers( requestMatcherFactory, matcherProvider, paths); String basePath = pathMappedEndpoints.getBasePath(); if (this.includeLinks && StringUtils.hasText(basePath)) { delegateMatchers.addAll(getLinksMatchers(requestMatcherFactory, matcherProvider, basePath)); } return new OrRequestMatcher(delegateMatchers); }
private EndpointId getEndpointId(Object source) { if (source instanceof EndpointId) { return (EndpointId) source; } if (source instanceof String) { return (EndpointId.of((String) source)); } if (source instanceof Class) { return getEndpointId((Class<?>) source); } throw new IllegalStateException("Unsupported source " + source); }
/** * Configure endpoint access to deny undefined. * * @param http the http * @param requests the requests */ protected void configureEndpointAccessToDenyUndefined(final HttpSecurity http, final ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry requests) { val endpoints = casProperties.getMonitor().getEndpoints().getEndpoint().keySet(); val configuredEndpoints = endpoints.toArray(ArrayUtils.EMPTY_STRING_ARRAY); val endpointDefaults = casProperties.getMonitor().getEndpoints().getDefaultEndpointProperties(); endpointDefaults.getAccess().forEach(Unchecked.consumer(access -> configureEndpointAccess(http, requests, access, endpointDefaults, EndpointRequest.toAnyEndpoint().excluding(configuredEndpoints).excludingLinks()))); }
public EndpointRequestMatcher excludingLinks() { return new EndpointRequestMatcher(this.includes, this.excludes, false); }
public EndpointRequestMatcher excluding(Class<?>... endpoints) { List<Object> excludes = new ArrayList<>(this.excludes); excludes.addAll(Arrays.asList((Object[]) endpoints)); return new EndpointRequestMatcher(this.includes, excludes, this.includeLinks); }
/** * Returns a matcher that includes the specified {@link Endpoint actuator endpoints}. * For example: <pre class="code"> * EndpointRequest.to("shutdown", "health") * </pre> * @param endpoints the endpoints to include * @return the configured {@link RequestMatcher} */ public static EndpointRequestMatcher to(String... endpoints) { return new EndpointRequestMatcher(endpoints, false); }
/** * Returns a matcher that includes the specified {@link Endpoint actuator endpoints}. * For example: <pre class="code"> * EndpointRequest.to(ShutdownEndpoint.class, HealthEndpoint.class) * </pre> * @param endpoints the endpoints to include * @return the configured {@link RequestMatcher} */ public static EndpointRequestMatcher to(Class<?>... endpoints) { return new EndpointRequestMatcher(endpoints, false); }
/** * Returns a matcher that includes all {@link Endpoint actuator endpoints}. It also * includes the links endpoint which is present at the base path of the actuator * endpoints. The {@link EndpointRequestMatcher#excluding(Class...) excluding} method * can be used to further remove specific endpoints if required. For example: * <pre class="code"> * EndpointRequest.toAnyEndpoint().excluding(ShutdownEndpoint.class) * </pre> * @return the configured {@link RequestMatcher} */ public static EndpointRequestMatcher toAnyEndpoint() { return new EndpointRequestMatcher(true); }