/** * Find target for current security request. * Example of implementation * of {@link OutboundSecurityProvider#isOutboundSupported(ProviderRequest, SecurityEnvironment, EndpointConfig)}: * {@code * return (null != outboundTargets) && outboundTargets.findTarget(request).isPresent(); * } * * @param env request we are processing * @return TargetConfig wrapped in {@link Optional} valid for the request */ public Optional<OutboundTarget> findTarget(SecurityEnvironment env) { String transport = env.getTransport(); String host = env.getTargetUri().getHost(); String path = env.getPath().orElse(null); for (OutboundTarget outboundTarget : targets) { if (outboundTarget.matches(transport, host, path)) { return Optional.of(outboundTarget); } } return Optional.empty(); }