Class CorsHandlerHelperImpl
- java.lang.Object
- 
- org.apache.tapestry5.http.internal.services.CorsHandlerHelperImpl
 
- 
- All Implemented Interfaces:
- CorsHandlerHelper
 
 public class CorsHandlerHelperImpl extends java.lang.Object implements CorsHandlerHelper DefaultCorsHandlerHelperimplementation.- Since:
- 5.8.2
- See Also:
- CorsHandler,- TapestryHttpSymbolConstants.CORS_ENABLED,- TapestryHttpSymbolConstants.CORS_ALLOWED_ORIGINS
 
- 
- 
Field Summary- 
Fields inherited from interface org.apache.tapestry5.http.services.CorsHandlerHelperALLOW_CREDENTIALS_HEADER, ALLOW_HEADERS_HEADER, ALLOW_METHODS_HEADER, ALLOW_ORIGIN_HEADER, EXPOSE_HEADERS_HEADER, MAX_AGE_HEADER, OPTIONS_METHOD, ORIGIN_HEADER, ORIGIN_WILDCARD, REQUEST_HEADERS_HEADER, VARY_HEADER
 
- 
 - 
Constructor SummaryConstructors Constructor Description CorsHandlerHelperImpl(java.lang.String allowedOrigins, boolean allowCredentials, java.lang.String allowMethods, java.lang.String allowedHeaders, java.lang.String exposeHeaders, java.lang.String maxAge)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigureAllowedHeaders(javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServletRequest request)Conditionally the Access-Control-Request-Headers HTTP header.voidconfigureCredentials(javax.servlet.http.HttpServletResponse response)Conditionally sets the Access-Control-Allow-Credentials HTTP header.voidconfigureExposeHeaders(javax.servlet.http.HttpServletResponse response)Conditionally sets the Access-Control-Expose-Headers HTTP header.voidconfigureMaxAge(javax.servlet.http.HttpServletResponse response)Conditionally sets the Access-Control-Max-Age HTTP header.voidconfigureMethods(javax.servlet.http.HttpServletResponse response)Conditionally sets the Access-Control-Allow-Methods HTTP header in responses to preflight CORS requests.voidconfigureOrigin(javax.servlet.http.HttpServletResponse response, java.lang.String value)Sets the Access-Control-Allow-Origin HTTP header with a given value.java.util.Optional<java.lang.String>getAllowedOrigin(javax.servlet.http.HttpServletRequest request)Returns the origin of this requests, if it's allowed.java.util.Optional<java.lang.String>getOrigin(javax.servlet.http.HttpServletRequest request)Returns the value of the Origin HTTP header.java.lang.StringgetPath(javax.servlet.http.HttpServletRequest request)Returns the requested URL path, using the same logic asRequest.getPath().booleanisPreflight(javax.servlet.http.HttpServletRequest request)Tells whether this request is a CORS preflight one (i.e.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.apache.tapestry5.http.services.CorsHandlerHelperaddValueToVaryHeader
 
- 
 
- 
- 
- 
Constructor Detail- 
CorsHandlerHelperImplpublic CorsHandlerHelperImpl(@Symbol("tapestry.cors-allowed-origins") java.lang.String allowedOrigins, @Symbol("tapestry.cors-allow-credentials") boolean allowCredentials, @Symbol("tapestry.cors-allow-methods") java.lang.String allowMethods, @Symbol("tapestry.cors-allowed-headers") java.lang.String allowedHeaders, @Symbol("tapestry.cors-expose-headers") java.lang.String exposeHeaders, @Symbol("tapestry.cors-max-age") java.lang.String maxAge) 
 
- 
 - 
Method Detail- 
getPathpublic java.lang.String getPath(javax.servlet.http.HttpServletRequest request) Description copied from interface:CorsHandlerHelperReturns the requested URL path, using the same logic asRequest.getPath().- Specified by:
- getPathin interface- CorsHandlerHelper
- Parameters:
- request- an- HttpServletRequest.
- Returns:
- a Stringwith the path.
 
 - 
getAllowedOriginpublic java.util.Optional<java.lang.String> getAllowedOrigin(javax.servlet.http.HttpServletRequest request) Description copied from interface:CorsHandlerHelperReturns the origin of this requests, if it's allowed.- Specified by:
- getAllowedOriginin interface- CorsHandlerHelper
- Parameters:
- request- an- HttpServletRequest.
- Returns:
- an Optionalwrapping the allowed origin.
- See Also:
- TapestryHttpSymbolConstants.CORS_ALLOWED_ORIGINS
 
 - 
getOriginpublic java.util.Optional<java.lang.String> getOrigin(javax.servlet.http.HttpServletRequest request) Description copied from interface:CorsHandlerHelperReturns the value of the Origin HTTP header.- Specified by:
- getOriginin interface- CorsHandlerHelper
- Parameters:
- request- an- HttpServletRequest.
- Returns:
- an Optionalwrapping the Origin HTTP header value.
 
 - 
isPreflightpublic boolean isPreflight(javax.servlet.http.HttpServletRequest request) Description copied from interface:CorsHandlerHelperTells whether this request is a CORS preflight one (i.e. HTTP method OPTION and non-empty Origin HTTP header).- Specified by:
- isPreflightin interface- CorsHandlerHelper
- Parameters:
- request- an- HttpServletRequest.
- Returns:
- trueif it's a preflight request,- falseotherwise.
 
 - 
configureOriginpublic void configureOrigin(javax.servlet.http.HttpServletResponse response, java.lang.String value) Description copied from interface:CorsHandlerHelperSets the Access-Control-Allow-Origin HTTP header with a given value.- Specified by:
- configureOriginin interface- CorsHandlerHelper
- Parameters:
- response- an- HttpServletResponseinstance.
- value- a String.
- See Also:
- CorsHandlerHelper.ALLOW_ORIGIN_HEADER
 
 - 
configureCredentialspublic void configureCredentials(javax.servlet.http.HttpServletResponse response) Description copied from interface:CorsHandlerHelperConditionally sets the Access-Control-Allow-Credentials HTTP header. Out-of-the-box, this is done based on theTapestryHttpSymbolConstants.CORS_ALLOW_CREDENTIALSsymbol.- Specified by:
- configureCredentialsin interface- CorsHandlerHelper
- Parameters:
- response- an- HttpServletResponse.
- See Also:
- TapestryHttpSymbolConstants.CORS_ALLOW_CREDENTIALS
 
 - 
configureMethodspublic void configureMethods(javax.servlet.http.HttpServletResponse response) Description copied from interface:CorsHandlerHelperConditionally sets the Access-Control-Allow-Methods HTTP header in responses to preflight CORS requests. Out-of-the-box, the value comes fromTapestryHttpSymbolConstants.CORS_ALLOW_CREDENTIALSsymbol and the header is only set if the value isn't empty.- Specified by:
- configureMethodsin interface- CorsHandlerHelper
- Parameters:
- response- an- HttpServletResponse.
- See Also:
- TapestryHttpSymbolConstants.CORS_ALLOW_CREDENTIALS
 
 - 
configureAllowedHeaderspublic void configureAllowedHeaders(javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServletRequest request) Description copied from interface:CorsHandlerHelperConditionally the Access-Control-Request-Headers HTTP header. Out-of-the-box, the value comes fromTapestryHttpSymbolConstants.CORS_ALLOWED_HEADERSsymbol if not empty. Otherwise, it comes from the value of the same HTTP header from the request, also if not empty. Otherwise, the header isn't set.- Specified by:
- configureAllowedHeadersin interface- CorsHandlerHelper
- Parameters:
- response- an- HttpServletResponse.
- request- an- HttpServletRequest.
- See Also:
- TapestryHttpSymbolConstants.CORS_ALLOWED_HEADERS
 
 - 
configureExposeHeaderspublic void configureExposeHeaders(javax.servlet.http.HttpServletResponse response) Description copied from interface:CorsHandlerHelperConditionally sets the Access-Control-Expose-Headers HTTP header. Out-of-the-box, the value comes fromTapestryHttpSymbolConstants.CORS_EXPOSE_HEADERSsymbol, if not empty. Otherwise, the header isn't set.- Specified by:
- configureExposeHeadersin interface- CorsHandlerHelper
- Parameters:
- response- an- HttpServletResponse.
- See Also:
- TapestryHttpSymbolConstants.CORS_EXPOSE_HEADERS
 
 - 
configureMaxAgepublic void configureMaxAge(javax.servlet.http.HttpServletResponse response) Description copied from interface:CorsHandlerHelperConditionally sets the Access-Control-Max-Age HTTP header. Out-of-the-box, the value comes fromTapestryHttpSymbolConstants.CORS_MAX_AGEsymbol, if not empty. Otherwise, the header isn't set.- Specified by:
- configureMaxAgein interface- CorsHandlerHelper
- Parameters:
- response- an- HttpServletResponse.
- See Also:
- TapestryHttpSymbolConstants.CORS_MAX_AGE
 
 
- 
 
-