我需要将一个自定义处理程序和APIAuthenticationHandler添加到特定的API中,它需要添加在
处理程序class="org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler"/>
(请注意,APIAuthenticationHandler在这里被调用了两次,这是一个定制的需求)
如何通过编辑velocity_template.xml以编程方式完成此操作?
我正在使用API-Manager 2.00
谢谢
发布于 2018-11-25 15:15:07
为此您可以使用API自定义属性。向API中添加一个自定义属性(例如auth_mode=Inhouse),然后在此基础上更新速度模板中的处理程序部分,如下所示。
<Handlers>
#foreach($handler in $handlers)
#if(($handler.className ==
"org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler") &&
($apiObj.additionalProperties.get('auth_mode') == "Inhouse"))
<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>
<handler class="org.wso2.apim.custom.extensions.CustomAuthHandler"/>
<Handlers>如果不能使用自定义属性,则可以使用$!apiName变量。
发布于 2018-11-29 13:26:04
如果($!apiName.toLowerCase().endsWith("basic")) #else
https://stackoverflow.com/questions/53468280
复制相似问题