Thursday, February 5, 2015

How to swap the headers in a request in wso2 API Manager

File Name: /_system/governance/apimgt/customsequences/in/auth_token_swapper.xml

Content: 
<sequence xmlns="http://ws.apache.org/ns/synapse" name="AuthToken--Swapper--In">
         <property name="Backend-Authorization" expression="$trp:Backend-Authorization" scope="default" type="STRING"/>
         <property name="TPaaS-Authorization" expression="$trp:Authorization" scope="default" type="STRING"/>
    <filter xpath="fn:string-length(get-property('Backend-Authorization')) > 0">
          <then>
              <property name="TPaaS-Authorization" expression="get-property('TPaaS-Authorization')" scope="transport"/>
              <property name="Authorization" expression="get-property('Backend-Authorization')" scope="transport"/>
              <log level="custom">
                  <property name="TRACE" value="Global Mediation Extension by Guru Authorization is there."/>
              </log>
          </then>
          <else>
              <log level="custom">
                  <property name="TRACE" value="Global Mediation Extension by Guru Authorization is not there."/>
              </log>
          </else>
     </filter>
</sequence>

No comments:

Post a Comment