首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >向特定的API wso2 API-Manager添加自定义处理程序。

向特定的API wso2 API-Manager添加自定义处理程序。
EN

Stack Overflow用户
提问于 2018-11-25 14:04:03
回答 2查看 683关注 0票数 3

我需要将一个自定义处理程序和APIAuthenticationHandler添加到特定的API中,它需要添加在

处理程序class="org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler"/>

(请注意,APIAuthenticationHandler在这里被调用了两次,这是一个定制的需求)

如何通过编辑velocity_template.xml以编程方式完成此操作?

我正在使用API-Manager 2.00

谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-11-25 15:15:07

为此您可以使用API自定义属性。向API中添加一个自定义属性(例如auth_mode=Inhouse),然后在此基础上更新速度模板中的处理程序部分,如下所示。

代码语言:javascript
复制
<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变量。

票数 3
EN

Stack Overflow用户

发布于 2018-11-29 13:26:04

如果($!apiName.toLowerCase().endsWith("basic")) #else

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53468280

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档