我需要将自定义处理程序和APIAuthenticationHandler添加到特定的API,并且需要将其添加到
处理程序class =“ org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler” />
(请注意,APIAuthenticationHandler在这里被调用了两次,这是一个自定义要求)
如何通过编辑Velocity_template.xml以编程方式执行此操作
我正在使用API-Manager 2.00
谢谢
您可以为此使用API自定义属性。auth_mode=Inhouse
在API中添加一个自定义属性(例如),然后基于该属性,更新速度模板中的处理程序部分,如下所示。
<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
变量。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句