Class CorsUtil
- java.lang.Object
-
- org.jboss.as.domain.http.server.cors.CorsUtil
-
public class CorsUtil extends Object
Utility class for CORS handling.- Author:
- Emmanuel Hugonnet (c) 2014 Red Hat, inc.
-
-
Constructor Summary
Constructors Constructor Description CorsUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringdefaultOrigin(io.undertow.server.HttpServerExchange exchange)Determine the default origin, to allow for local access.static booleanisCoreRequest(io.undertow.util.HeaderMap headers)static booleanisPreflightedRequest(io.undertow.server.HttpServerExchange exchange)static StringmatchOrigin(io.undertow.server.HttpServerExchange exchange, Collection<String> allowedOrigins)Match the Origin header with the allowed origins.static StringsanitizeDefaultPort(String url)Removes the port from a URL if this port is the default one for the URL's scheme.
-
-
-
Method Detail
-
isCoreRequest
public static boolean isCoreRequest(io.undertow.util.HeaderMap headers)
-
matchOrigin
public static String matchOrigin(io.undertow.server.HttpServerExchange exchange, Collection<String> allowedOrigins) throws Exception
Match the Origin header with the allowed origins. If it doesn't match then a 403 response code is set on the response and it returns null.- Parameters:
exchange- the current HttpExchange.allowedOrigins- list of sanitized allowed origins.- Returns:
- the first matching origin, null otherwise.
- Throws:
Exception
-
defaultOrigin
public static String defaultOrigin(io.undertow.server.HttpServerExchange exchange)
Determine the default origin, to allow for local access.- Parameters:
exchange- the current HttpExchange.- Returns:
- the default origin (aka current server).
-
sanitizeDefaultPort
public static String sanitizeDefaultPort(String url)
Removes the port from a URL if this port is the default one for the URL's scheme.- Parameters:
url- the url to be sanitized.- Returns:
- the sanitized url.
-
isPreflightedRequest
public static boolean isPreflightedRequest(io.undertow.server.HttpServerExchange exchange)
-
-