APIAuthenticationHandler:Validates the OAuth2 bearer token used to invoke the API. It also determines whether the token is of type
MessageContextvariables as appropriate.
APIThrottleHandler:Throttles requests based on the throttling policy specified by the
policyKeyproperty. Throttling is applied both at the application level as well as subscription level.
APIMgtUsageHandler:Publishes events to BAM for collection and analysis of statistics. This handler only comes to effect if . See Publishing API Runtime Statistics for more information.
APIMgtGoogleAnalyticsTrackingHandler:Publishes events to Google Analytics. This handler only comes into effect if Google analytics tracking is enabled. See for more information.
APIManagerExtensionHandler: Triggers extension sequences. By default, the extension handler is listed at last in the handler chain, and therefore is executed last. You cannot change the order in which the handlers are executed, except the extension handler. To configure the API Gateway to execute extension handler first, uncomment the <ExtensionHandlerPosition> section in the <APIMthe
<ExtensionHandlerPosition>section in the
<APIM_HOME>/repository/conf/api-manager.xml file and
xmlfile and provide the value topvalue
top. This is useful when you want to execute your own extensions before our default handlers in situations like doing additional security checks such as signature verification on access tokens before executing the default security handler.
See Adding Mediation Extensions.
Engaging the custom handler
You can engage the a custom handler per API or to all APIs at once . To or only to selected APIs.
To engage to all APIs, the recommended approach is to add it to the
<APIM_HOME>/repository/resources/api_templates/velocity_template.xml file. For example, the following code segment adds the custom authentication handler that you wrote earlier to the
velocity_template.xml file while making sure that it skips the default
<handler class="org.wso2.carbon.apimgt.custom.authentication.handler.CustomAPIAuthenticationHandler" /> #foreach($handler in $handlers) #if(!($handler.className == "org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler")) <handler xmlns="http://ws.apache.org/ns/synapse" class="$handler.className"> #if($handler.hasProperties()) #set ($map = $handler.getProperties() ) #foreach($property in $map.entrySet()) <property name="$!property.key" value="$!property.value"/> #end #end </handler> #end #end </handlers>
Given below is how to engage handlers to a single API, by editing its source view.