Java security engineering
Map a finite outbound service
The reserved invalid domain is never contacted. This prevents arbitrary URL selection in the model, not all real SSRF risks.
Formal Syntax & Structure
java syntaxjava
destination(service)Working Example
Example Snippetjava
public class Main { static java.net.URI destination(String service) { return switch(service) { case "catalog" -> java.net.URI.create("https://catalog.example.invalid/v1/items"); case "billing" -> java.net.URI.create("https://billing.example.invalid/v1/status"); default -> throw new IllegalArgumentException("unknown destination"); }; } public static void main(String[] args) throws Exception { System.out.println(destination("catalog").getHost()); }}