private String origUri(ProviderRequest providerRequest) { List<String> origUri = providerRequest.env().headers() .getOrDefault(Security.HEADER_ORIG_URI, CollectionsHelper.listOf()); if (origUri.isEmpty()) { origUri = CollectionsHelper.listOf(providerRequest.env().targetUri().getPath()); } try { return URLEncoder.encode(origUri.get(0), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new SecurityException("UTF-8 must be supported for security to work", e); } }
/** * 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.transport(); String host = env.targetUri().getHost(); String path = env.path().orElse(null); for (OutboundTarget outboundTarget : targets) { if (outboundTarget.matches(transport, host, path)) { return Optional.of(outboundTarget); } } return Optional.empty(); }
URI uri = env.targetUri();
/** * 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.transport(); String host = env.targetUri().getHost(); String path = env.path().orElse(null); for (OutboundTarget outboundTarget : targets) { if (outboundTarget.matches(transport, host, path)) { return Optional.of(outboundTarget); } } return Optional.empty(); }