parent
f2648c2c28
commit
e9f2062362
@ -0,0 +1,79 @@
|
||||
<api xmlns="http://ws.apache.org/ns/synapse" name="$!apiName" context="$!apiContext" transports="$!transport">
|
||||
#foreach($resource in $resources)
|
||||
<resource xmlns="http://ws.apache.org/ns/synapse"
|
||||
#if($resource.getUriTemplate().contains("{") ||
|
||||
($resource.getUriTemplate().contains("*") && !$resource.getUriTemplate().endsWith("/*")))
|
||||
uri-template="$util.escapeXml($resource.getUriTemplate())"
|
||||
#else
|
||||
url-mapping="$resource.getUriTemplate()"
|
||||
#end
|
||||
methods="$resource.getMethodsAsString()" faultSequence="fault">
|
||||
<inSequence>
|
||||
<property name="isDefault" expression="$trp:WSO2_AM_API_DEFAULT_VERSION"/>
|
||||
<filter source="$ctx:isDefault" regex="true">
|
||||
<then>
|
||||
<log level="custom">
|
||||
<property name="STATUS" value="Faulty invoking through default API.Dropping message to avoid recursion.."/>
|
||||
</log>
|
||||
<payloadFactory media-type="xml">
|
||||
<format>
|
||||
<am:fault xmlns:am="http://wso2.org/apimanager">
|
||||
<am:code>500</am:code>
|
||||
<am:type>Status report</am:type>
|
||||
<am:message>Internal Server Error</am:message>
|
||||
<am:description>Faulty invoking through default API</am:description>
|
||||
</am:fault>
|
||||
</format>
|
||||
<args/>
|
||||
</payloadFactory>
|
||||
<property name="HTTP_SC" value="500" scope="axis2"/>
|
||||
<property name="RESPONSE" value="true"/>
|
||||
<header name="To" action="remove"/>
|
||||
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
|
||||
<property name="ContentType" scope="axis2" action="remove"/>
|
||||
<property name="Authorization" scope="transport" action="remove"/>
|
||||
<property name="Host" scope="transport" action="remove"/>
|
||||
<property name="Accept" scope="transport" action="remove"/>
|
||||
<send/>
|
||||
</then>
|
||||
<else>
|
||||
<header name="WSO2_AM_API_DEFAULT_VERSION" scope="transport" value="true"/>
|
||||
#if( $transport == "https" )
|
||||
<property name="uri.var.portnum" expression="get-property('https.nio.port')"/>
|
||||
#else
|
||||
<property name="uri.var.portnum" expression="get-property('http.nio.port')"/>
|
||||
#end
|
||||
|
||||
<send>
|
||||
<endpoint>
|
||||
#if( $transport == "https" )
|
||||
<http uri-template="https://localhost:{uri.var.portnum}/$!{fwdApiContext}">
|
||||
#else
|
||||
<http uri-template="http://localhost:{uri.var.portnum}/$!{fwdApiContext}">
|
||||
#end
|
||||
<timeout>
|
||||
<duration>60000</duration>
|
||||
<responseAction>fault</responseAction>
|
||||
</timeout>
|
||||
<suspendOnFailure>
|
||||
<progressionFactor>1.0</progressionFactor>
|
||||
</suspendOnFailure>
|
||||
<markForSuspension>
|
||||
<retriesBeforeSuspension>0</retriesBeforeSuspension>
|
||||
<retryDelay>0</retryDelay>
|
||||
</markForSuspension>
|
||||
</http>
|
||||
</endpoint>
|
||||
</send>
|
||||
</else>
|
||||
</filter>
|
||||
</inSequence>
|
||||
<outSequence>
|
||||
<send/>
|
||||
</outSequence>
|
||||
</resource>
|
||||
#end ## end of resource iterator
|
||||
<handlers>
|
||||
<handler class="org.wso2.carbon.apimgt.gateway.handlers.common.SynapsePropertiesHandler"/>
|
||||
</handlers>
|
||||
</api>
|
@ -0,0 +1,262 @@
|
||||
<!--
|
||||
~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
##################### Define the macros ######################
|
||||
|
||||
#macro ( print_if_exist $field $default)
|
||||
#if($field && "$field" !="")
|
||||
$field
|
||||
#else
|
||||
$default
|
||||
#end
|
||||
#end
|
||||
|
||||
#macro ( print_string_if_exist $field $default)
|
||||
#if($field && "$field" !="")
|
||||
"$field"
|
||||
#else
|
||||
"$default"
|
||||
#end
|
||||
#end
|
||||
|
||||
#macro ( print_if_exist_only $tagname $field)
|
||||
#if($field && "$field" !="")
|
||||
<$tagname>$field</$tagname>
|
||||
#else
|
||||
## print nothing.
|
||||
#end
|
||||
#end
|
||||
|
||||
#macro ( print_list $tagname $list)
|
||||
#if($list && "$list" !="" && $list.size() > 0)
|
||||
<$tagname>
|
||||
#foreach($item in $list)
|
||||
$item #if( $foreach.hasNext ), #end
|
||||
#end
|
||||
</$tagname>
|
||||
#else
|
||||
## print nothing.
|
||||
#end
|
||||
#end
|
||||
|
||||
#macro ( timeout $config)
|
||||
#if( $config.get("actionSelect") == "neverTimeout" )
|
||||
## print nothing.
|
||||
#elseif($config.get("actionDuration")|| $config.get("actionSelect"))
|
||||
<timeout>
|
||||
#print_if_exist_only("duration" $config.get("actionDuration"))
|
||||
#print_if_exist_only("responseAction" $config.get("actionSelect"))
|
||||
</timeout>
|
||||
#end
|
||||
<suspendOnFailure>
|
||||
#print_list( "errorCodes" $config.get("suspendErrorCode"))
|
||||
#print_if_exist_only("initialDuration" $config.get("suspendDuration"))
|
||||
#print_if_exist_only("maximumDuration" $config.get("suspendMaxDuration"))
|
||||
<progressionFactor>#print_if_exist( $config.get("factor") 1.0)</progressionFactor>
|
||||
</suspendOnFailure>
|
||||
<markForSuspension>
|
||||
#print_list("errorCodes" $config.get("retryErroCode"))
|
||||
<retriesBeforeSuspension>#print_if_exist( $config.get("retryTimeOut") 0)</retriesBeforeSuspension>
|
||||
<retryDelay>#print_if_exist( $config.get("retryDelay") 0)</retryDelay>
|
||||
</markForSuspension>
|
||||
#end
|
||||
|
||||
#macro ( http_endpoint $name $ep )
|
||||
<endpoint name="$name">
|
||||
<http uri-template="$util.escapeXml($ep.get("url"))">
|
||||
#timeout( $ep.get('config') )
|
||||
</http>
|
||||
#if($destinationBasedStatsEnabled)
|
||||
<property name="ENDPOINT_ADDRESS" value="$util.escapeXml($ep.get("url"))"/>
|
||||
#end
|
||||
</endpoint>
|
||||
#end
|
||||
|
||||
#macro ( draw_endpoint $type $endpoint_config )
|
||||
|
||||
#set( $endpointClass = $endpoint_config.get("endpoint_type") )
|
||||
#set( $endpoints = $endpoint_config.get("${type}_endpoints"))
|
||||
#set( $ep_name = "${apiName}_API${type}Endpoint_${resourceNo}")
|
||||
|
||||
## IF endpoint secured
|
||||
#if($isEndpointSecured)
|
||||
#if($isSecureVaultEnabled)
|
||||
<property xmlns="http://ws.apache.org/ns/synapse" name="password" expression="wso2:vault-lookup('$securevault_alias')"/>
|
||||
<property xmlns="http://ws.apache.org/ns/synapse" name="unpw" expression="fn:concat('$username',':',get-property('password'))"/>
|
||||
<property xmlns="http://ws.apache.org/ns/synapse" name="Authorization" expression="fn:concat('Basic ', base64Encode(get-property('unpw')))" scope="transport"/>
|
||||
#else
|
||||
<property xmlns="http://ws.apache.org/ns/synapse" name="Authorization" expression="fn:concat('Basic ', base64Encode('$username:$password'))" scope="transport" />
|
||||
#end
|
||||
#end
|
||||
<send>
|
||||
#if ($endpointClass == "http")
|
||||
#http_endpoint($ep_name $endpoints)
|
||||
#elseif ($endpointClass == "address")
|
||||
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="$ep_name">
|
||||
#set( $advance_ep = $endpoints.get("config") )
|
||||
<address uri="$util.escapeXml($endpoints.get("url"))"
|
||||
#if($advance_ep.get("format") && $advance_ep.get("format") != "" && $advance_ep.get("format") != 'leave-as-is')
|
||||
format="$advance_ep.get("format")"
|
||||
#end
|
||||
#if($advance_ep.get("optimize") && $advance_ep.get("optimize") != "" && $advance_ep.get("optimize") != 'leave-as-is')
|
||||
optimize="$advance_ep.get("optimize")"
|
||||
#end
|
||||
>
|
||||
#timeout( $endpoints.get('config') )
|
||||
</address>
|
||||
#if($destinationBasedStatsEnabled)
|
||||
<property name="ENDPOINT_ADDRESS" value="$util.escapeXml($endpoints.get("url"))"/>
|
||||
#end
|
||||
</endpoint>
|
||||
#elseif ($endpointClass == "wsdl")
|
||||
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="$ep_name">
|
||||
<wsdl uri="$util.escapeXml($endpoints.get("url"))" service="$!endpoint_config.get("wsdlendpointService")" port="$!endpoint_config.get("wsdlendpointPort")">
|
||||
#timeout()
|
||||
</wsdl>
|
||||
#if($destinationBasedStatsEnabled)
|
||||
<property name="ENDPOINT_ADDRESS" value="$util.escapeXml($endpoints.get("url"))"/>
|
||||
#end
|
||||
</endpoint>
|
||||
#elseif ($endpointClass == "failover")
|
||||
#set( $failover_endpoints = $endpoint_config.get("${type}_failovers"))
|
||||
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="$ep_name">
|
||||
<failover>
|
||||
#http_endpoint("${ep_name}_0" $endpoints)
|
||||
#set( $i = 1)
|
||||
#foreach($endpoint in $failover_endpoints)
|
||||
#http_endpoint("${ep_name}_$i" $endpoint)
|
||||
#set( $i = $i + 1)
|
||||
#end
|
||||
</failover>
|
||||
</endpoint>
|
||||
#elseif ($endpointClass == "load_balance")
|
||||
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="$ep_name">
|
||||
#if($endpoint_config.get("sessionManagement") && $endpoint_config.get("sessionManagement") != "" && $endpoint_config.get("sessionManagement") != "none")
|
||||
<session type="$endpoint_config.get("sessionManagement")">
|
||||
#if($endpoint_config.get("sessionTimeOut") && $endpoint_config.get("sessionTimeOut") != "")
|
||||
<sessionTimeout>$endpoint_config.get("sessionTimeOut")</sessionTimeout>
|
||||
#end
|
||||
</session>
|
||||
#end
|
||||
<loadbalance algorithm="$!endpoint_config.get("algoClassName")"
|
||||
#if($endpoint_config.get("failOver") && $endpoint_config.get("failOver") != "" && $endpoint_config.get("failOver") == "False")
|
||||
failover="false"
|
||||
#end>
|
||||
#set( $i = 0)
|
||||
#foreach($endpoint in $endpoints)
|
||||
#http_endpoint("${ep_name}_$i" $endpoint)
|
||||
#set( $i = $i + 1)
|
||||
#end
|
||||
</loadbalance>
|
||||
</endpoint>
|
||||
#end
|
||||
</send>
|
||||
#if($destinationBasedStatsEnabled)
|
||||
<bam>
|
||||
<serverProfile name="$!profileName">
|
||||
<streamConfig name="$!streamName" version="$!streamVersion"/>
|
||||
</serverProfile>
|
||||
</bam>
|
||||
#end
|
||||
#end
|
||||
|
||||
######################## End of Macros ######################################
|
||||
|
||||
|
||||
<api xmlns="http://ws.apache.org/ns/synapse" name="$!apiName" context="$!apiContext" version="$!apiVersion" transports="$!transport" version-type="context">
|
||||
#if($apiIsBlocked)
|
||||
## if API is blocked send the API Block message
|
||||
<resource faultSequence=#print_string_if_exist($faultSequence "fault")>
|
||||
<inSequence>
|
||||
<payloadFactory>
|
||||
<format>
|
||||
<am:fault xmlns:am="http://wso2.org/apimanager">
|
||||
<am:code>700700</am:code>
|
||||
<am:message>API blocked</am:message>
|
||||
<am:description>This API has been blocked temporarily. Please try again later or contact the system administrators.</am:description>
|
||||
</am:fault>
|
||||
</format>
|
||||
</payloadFactory>
|
||||
<property name="HTTP_SC" value="503" scope="axis2"/>
|
||||
<property name="RESPONSE" value="true"/>
|
||||
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
|
||||
<header name="To" action="remove"/>
|
||||
<send/>
|
||||
</inSequence>
|
||||
</resource>
|
||||
#else
|
||||
## api not blocked
|
||||
#set ($resourceNo = 0)
|
||||
#foreach($resource in $resources)
|
||||
<resource xmlns="http://ws.apache.org/ns/synapse"
|
||||
#if($resource.getUriTemplate().contains("{") ||
|
||||
($resource.getUriTemplate().contains("*") && !$resource.getUriTemplate().endsWith("/*")))
|
||||
uri-template="$util.escapeXml($resource.getUriTemplate())"
|
||||
#else
|
||||
url-mapping="$resource.getUriTemplate()"
|
||||
#end
|
||||
methods="$resource.getMethodsAsString()" faultSequence=#print_string_if_exist($faultSequence "fault")>
|
||||
<inSequence>
|
||||
#if(!$resource.getMediationScript().equalsIgnoreCase("null"))
|
||||
<script language="js">
|
||||
<![CDATA[
|
||||
$resource.getMediationScript()
|
||||
]]>
|
||||
</script>
|
||||
<filter source="boolean(get-property('CONTENT_TYPE'))" regex="false">
|
||||
<then>
|
||||
<property name="messageType" value="application/xml" scope="axis2"/>
|
||||
</then>
|
||||
<else>
|
||||
<property name="messageType" expression="get-property('CONTENT_TYPE')" scope="axis2"/>
|
||||
</else>
|
||||
</filter>
|
||||
#else
|
||||
<property name="HTTP_SC" value="501" scope="axis2"/>
|
||||
#end
|
||||
#if($resource.getMethodsAsString().contains("GET")||$resource.getMethodsAsString().contains("DELETE"))
|
||||
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
|
||||
#end
|
||||
<respond/>
|
||||
</inSequence>
|
||||
<outSequence>
|
||||
<send/>
|
||||
</outSequence>
|
||||
</resource>
|
||||
#set ($resourceNo = $resourceNo + 1)
|
||||
#end ## end of resource iterator
|
||||
## print the handlers
|
||||
#if($handlers.size() > 0)
|
||||
<handlers xmlns="http://ws.apache.org/ns/synapse">
|
||||
#foreach($handler in $handlers)
|
||||
<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
|
||||
</handlers>
|
||||
#end
|
||||
#if($apiStatus == 'PROTOTYPED')
|
||||
#end
|
||||
#end
|
||||
## end of apiIsBlocked check
|
||||
</api>
|
@ -0,0 +1,366 @@
|
||||
<!--
|
||||
~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
##################### Define the macros ######################
|
||||
|
||||
#macro ( print_if_exist $field $default)
|
||||
#if($field && "$field" !="")
|
||||
$field
|
||||
#else
|
||||
$default
|
||||
#end
|
||||
#end
|
||||
|
||||
#macro ( print_string_if_exist $field $default)
|
||||
#if($field && "$field" !="")
|
||||
"$field"
|
||||
#else
|
||||
"$default"
|
||||
#end
|
||||
#end
|
||||
|
||||
#macro ( print_if_exist_only $tagname $field)
|
||||
#if($field && "$field" !="")
|
||||
<$tagname>$field</$tagname>
|
||||
#else
|
||||
## print nothing.
|
||||
#end
|
||||
#end
|
||||
|
||||
#macro ( print_list $tagname $list)
|
||||
#if($list && "$list" !="" && $list.size() > 0)
|
||||
<$tagname>
|
||||
#foreach($item in $list)
|
||||
$item #if( $foreach.hasNext ), #end
|
||||
#end
|
||||
</$tagname>
|
||||
#else
|
||||
## print nothing.
|
||||
#end
|
||||
#end
|
||||
|
||||
#macro ( timeout $config)
|
||||
#if( $config.get("actionSelect") == "neverTimeout" )
|
||||
## print nothing.
|
||||
#elseif($config.get("actionDuration")|| $config.get("actionSelect"))
|
||||
<timeout>
|
||||
#print_if_exist_only("duration" $config.get("actionDuration"))
|
||||
#print_if_exist_only("responseAction" $config.get("actionSelect"))
|
||||
</timeout>
|
||||
#end
|
||||
<suspendOnFailure>
|
||||
#print_list( "errorCodes" $config.get("suspendErrorCode"))
|
||||
#print_if_exist_only("initialDuration" $config.get("suspendDuration"))
|
||||
#print_if_exist_only("maximumDuration" $config.get("suspendMaxDuration"))
|
||||
<progressionFactor>#print_if_exist( $config.get("factor") 1.0)</progressionFactor>
|
||||
</suspendOnFailure>
|
||||
<markForSuspension>
|
||||
#print_list("errorCodes" $config.get("retryErroCode"))
|
||||
<retriesBeforeSuspension>#print_if_exist( $config.get("retryTimeOut") 0)</retriesBeforeSuspension>
|
||||
<retryDelay>#print_if_exist( $config.get("retryDelay") 0)</retryDelay>
|
||||
</markForSuspension>
|
||||
#end
|
||||
|
||||
#macro ( http_endpoint $name $ep )
|
||||
<endpoint name="$name">
|
||||
<http uri-template="$util.escapeXml($ep.get("url"))">
|
||||
#timeout( $ep.get('config') )
|
||||
</http>
|
||||
#if($destinationBasedStatsEnabled)
|
||||
<property name="ENDPOINT_ADDRESS" value="$util.escapeXml($ep.get("url"))"/>
|
||||
#end
|
||||
</endpoint>
|
||||
#end
|
||||
|
||||
#macro ( draw_endpoint $type $endpoint_config )
|
||||
|
||||
#set( $endpointClass = $endpoint_config.get("endpoint_type") )
|
||||
#set( $endpoints = $endpoint_config.get("${type}_endpoints"))
|
||||
#set( $ep_name = "${apiName}_API${type}Endpoint_${resourceNo}")
|
||||
|
||||
## IF endpoint secured
|
||||
#if($isEndpointSecured)
|
||||
#if($isSecureVaultEnabled)
|
||||
<property xmlns="http://ws.apache.org/ns/synapse" name="password" expression="wso2:vault-lookup('$securevault_alias')"/>
|
||||
<property xmlns="http://ws.apache.org/ns/synapse" name="unpw" expression="fn:concat('$username',':',get-property('password'))"/>
|
||||
<property xmlns="http://ws.apache.org/ns/synapse" name="Authorization" expression="fn:concat('Basic ', base64Encode(get-property('unpw')))" scope="transport"/>
|
||||
#else
|
||||
#if($isEndpointAuthDigest)
|
||||
|
||||
<property xmlns="http://ws.apache.org/ns/synapse" name="UNAMEPASSWORD" value="$util.escapeXml($base64unpw)" type="STRING"/>
|
||||
<property name="BACKEND_URL" value="$util.escapeXml($endpoints.get("url"))"/>
|
||||
<property name="POSTFIX" expression="get-property('axis2', 'REST_URL_POSTFIX')"/>
|
||||
<property name="HTTP_METHOD" expression="get-property('axis2', 'HTTP_METHOD')"/>
|
||||
<property name="POST_TO_URI" value="true" scope="axis2"/>
|
||||
<property name="MessageType" expression="get-property('axis2', 'messageType')"/>
|
||||
|
||||
<enrich>
|
||||
<source type="body" clone="true"/>
|
||||
<target type="property" property="MessageBody"/>
|
||||
</enrich>
|
||||
|
||||
<call>
|
||||
<endpoint name="$ep_name">
|
||||
<http uri-template="$util.escapeXml($endpoints.get("url"))">
|
||||
</http>
|
||||
</endpoint>
|
||||
</call>
|
||||
|
||||
<class name="org.wso2.carbon.apimgt.gateway.mediators.DigestAuthMediator"/>
|
||||
|
||||
<property name="Authorization" expression="get-property('AuthHeader')" scope="transport"/>
|
||||
<property name="messageType" expression="get-property('MessageType')" scope="axis2"/>
|
||||
<property name="HTTP_METHOD" expression="get-property('HTTP_METHOD')" scope="axis2"/>
|
||||
<property name="REST_URL_POSTFIX" expression="$ctx:POSTFIX" scope="axis2"/>
|
||||
<property name="POST_TO_URI" value="true" scope="axis2"/>
|
||||
|
||||
<enrich>
|
||||
<source type="property" property="MessageBody" clone="true"/>
|
||||
<target type="body"/>
|
||||
</enrich>
|
||||
|
||||
#else
|
||||
<property xmlns="http://ws.apache.org/ns/synapse" name="Authorization" expression="fn:concat('Basic ', '$base64unpw')" scope="transport"/>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<send>
|
||||
|
||||
## If endpoint is http
|
||||
#if ($endpointClass == "http")
|
||||
#http_endpoint($ep_name $endpoints)
|
||||
#elseif ($endpointClass == "address")
|
||||
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="$ep_name">
|
||||
#set( $advance_ep = $endpoints.get("config") )
|
||||
<address uri="$util.escapeXml($endpoints.get("url"))"
|
||||
#if($advance_ep.get("format") && $advance_ep.get("format") != "" && $advance_ep.get("format") != 'leave-as-is')
|
||||
format="$advance_ep.get("format")"
|
||||
#end
|
||||
#if($advance_ep.get("optimize") && $advance_ep.get("optimize") != "" && $advance_ep.get("optimize") != 'leave-as-is')
|
||||
optimize="$advance_ep.get("optimize")"
|
||||
#end
|
||||
>
|
||||
#timeout( $endpoints.get('config') )
|
||||
</address>
|
||||
#if($destinationBasedStatsEnabled)
|
||||
<property name="ENDPOINT_ADDRESS" value="$util.escapeXml($endpoints.get("url"))"/>
|
||||
#end
|
||||
</endpoint>
|
||||
#elseif ($endpointClass == "wsdl")
|
||||
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="$ep_name">
|
||||
#if (${type} == "production")
|
||||
<wsdl uri="$util.escapeXml($endpoints.get("url"))" service="$!endpoint_config.get("wsdlendpointService")" port="$!endpoint_config.get("wsdlendpointPort")">
|
||||
#timeout()
|
||||
</wsdl>
|
||||
#else
|
||||
<wsdl uri="$util.escapeXml($endpoints.get("url"))" service="$!endpoint_config.get("wsdlendpointServiceSandbox")" port="$!endpoint_config.get("wsdlendpointPortSandbox")">
|
||||
#timeout()
|
||||
</wsdl>
|
||||
#end
|
||||
#if($destinationBasedStatsEnabled)
|
||||
<property name="ENDPOINT_ADDRESS" value="$util.escapeXml($endpoints.get("url"))"/>
|
||||
#end
|
||||
</endpoint>
|
||||
#elseif ($endpointClass == "failover")
|
||||
#set( $failover_endpoints = $endpoint_config.get("${type}_failovers"))
|
||||
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="$ep_name">
|
||||
<failover>
|
||||
#http_endpoint("${ep_name}_0" $endpoints)
|
||||
#set( $i = 1)
|
||||
#foreach($endpoint in $failover_endpoints)
|
||||
#http_endpoint("${ep_name}_$i" $endpoint)
|
||||
#set( $i = $i + 1)
|
||||
#end
|
||||
</failover>
|
||||
</endpoint>
|
||||
#elseif ($endpointClass == "load_balance")
|
||||
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="$ep_name">
|
||||
#if($endpoint_config.get("sessionManagement") && $endpoint_config.get("sessionManagement") != "" && $endpoint_config.get("sessionManagement") != "none")
|
||||
<session type="$endpoint_config.get("sessionManagement")">
|
||||
#if($endpoint_config.get("sessionTimeOut") && $endpoint_config.get("sessionTimeOut") != "")
|
||||
<sessionTimeout>$endpoint_config.get("sessionTimeOut")</sessionTimeout>
|
||||
#end
|
||||
</session>
|
||||
#end
|
||||
<loadbalance algorithm="$!endpoint_config.get("algoClassName")"
|
||||
#if($endpoint_config.get("failOver") && $endpoint_config.get("failOver") != "" && $endpoint_config.get("failOver") == "False")
|
||||
failover="false"
|
||||
#end>
|
||||
#set( $i = 0)
|
||||
#foreach($endpoint in $endpoints)
|
||||
#http_endpoint("${ep_name}_$i" $endpoint)
|
||||
#set( $i = $i + 1)
|
||||
#end
|
||||
</loadbalance>
|
||||
</endpoint>
|
||||
#elseif ($endpointClass == "default")
|
||||
<endpoint name="$ep_name">
|
||||
<default>
|
||||
</default>
|
||||
</endpoint>
|
||||
#end
|
||||
</send>
|
||||
#if($destinationBasedStatsEnabled)
|
||||
<filter source="get-property('isStatEnabled')" regex="true">
|
||||
<then>
|
||||
<bam>
|
||||
<serverProfile name="$!profileName">
|
||||
<streamConfig name="$!streamName" version="$!streamVersion"/>
|
||||
</serverProfile>
|
||||
</bam>
|
||||
</then>
|
||||
</filter>
|
||||
#end
|
||||
#end
|
||||
|
||||
######################## End of Macros ######################################
|
||||
|
||||
|
||||
<api xmlns="http://ws.apache.org/ns/synapse" name="$!apiName" context="$!apiContext" version="$!apiVersion" transports="$!transport" version-type="context">
|
||||
#if($apiIsBlocked)
|
||||
## if API is blocked send the API Block message
|
||||
<resource methods="GET POST PUT DELETE PATCH" url-mapping="/*" faultSequence=#print_string_if_exist($faultSequence "fault")>
|
||||
<inSequence>
|
||||
<payloadFactory>
|
||||
<format>
|
||||
<am:fault xmlns:am="http://wso2.org/apimanager">
|
||||
<am:code>700700</am:code>
|
||||
<am:message>API blocked</am:message>
|
||||
<am:description>This API has been blocked temporarily. Please try again later or contact the system administrators.</am:description>
|
||||
</am:fault>
|
||||
</format>
|
||||
</payloadFactory>
|
||||
<property name="HTTP_SC" value="503" scope="axis2"/>
|
||||
<property name="RESPONSE" value="true"/>
|
||||
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
|
||||
<header name="To" action="remove"/>
|
||||
<send/>
|
||||
</inSequence>
|
||||
</resource>
|
||||
#else
|
||||
## api not blocked
|
||||
#set ($resourceNo = 0)
|
||||
#foreach($resource in $resources)
|
||||
|
||||
<resource xmlns="http://ws.apache.org/ns/synapse"
|
||||
#if($resource.getUriTemplate().contains("{") ||
|
||||
($resource.getUriTemplate().contains("*") && !$resource.getUriTemplate().endsWith("/*")))
|
||||
uri-template="$util.escapeXml($resource.getUriTemplate())"
|
||||
#else
|
||||
url-mapping="$resource.getUriTemplate()"
|
||||
#end
|
||||
methods="$resource.getMethodsAsString()" faultSequence=#print_string_if_exist($faultSequence "fault")>
|
||||
<inSequence>
|
||||
## check and set jwt
|
||||
#if($jwtIsEnabled && ($apiStatus != 'PROTOTYPED'))
|
||||
<class name="org.wso2.carbon.apimgt.gateway.mediators.TokenPasser"/>
|
||||
#end
|
||||
## check and set response caching
|
||||
#if($responseCacheEnabled)
|
||||
<cache scope="per-host" collector="false" hashGenerator="org.wso2.caching.digest.REQUESTHASHGenerator" timeout="$!responseCacheTimeOut">
|
||||
<implementation type="memory" maxSize="500"/>
|
||||
</cache>
|
||||
#end
|
||||
|
||||
############## define the filter based on environment type production only, sandbox only , hybrid ############
|
||||
|
||||
#if(($environmentType == 'sandbox') || ($environmentType =='hybrid' && !$endpoint_config.get("production_endpoints") ))
|
||||
#set( $filterRegex = "SANDBOX" )
|
||||
#else
|
||||
#set( $filterRegex = "PRODUCTION" )
|
||||
#end
|
||||
#if($apiStatus != 'PROTOTYPED')
|
||||
<filter source="$ctx:AM_KEY_TYPE" regex="$filterRegex">
|
||||
<then>
|
||||
#end
|
||||
<property name="api.ut.backendRequestTime" expression="get-property('SYSTEM_TIME')"/>
|
||||
#if(($environmentType == 'sandbox') || ($environmentType =='hybrid' && ! $endpoint_config.get("production_endpoints") ))
|
||||
#draw_endpoint( "sandbox" $endpoint_config )
|
||||
#else
|
||||
#draw_endpoint( "production" $endpoint_config )
|
||||
#end
|
||||
#if($apiStatus != 'PROTOTYPED')
|
||||
</then>
|
||||
<else>
|
||||
#if($environmentType !='hybrid')
|
||||
<payloadFactory>
|
||||
<format>
|
||||
<error xmlns="">
|
||||
#if($environmentType == 'production')
|
||||
<message>Sandbox Key Provided for Production Gateway</message>
|
||||
#elseif($environmentType == 'sandbox')
|
||||
<message>Production Key Provided for Sandbox Gateway</message>
|
||||
#end
|
||||
</error>
|
||||
</format>
|
||||
</payloadFactory>
|
||||
<property name="ContentType" value="application/xml" scope="axis2"/>
|
||||
<property name="RESPONSE" value="true"/>
|
||||
<header name="To" action="remove"/>
|
||||
<property name="HTTP_SC" value="401" scope="axis2"/>
|
||||
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
|
||||
<send/>
|
||||
#else
|
||||
#if($endpoint_config.get("production_endpoints") && $endpoint_config.get("sandbox_endpoints"))
|
||||
#draw_endpoint( "sandbox" $endpoint_config )
|
||||
#elseif($endpoint_config.get("production_endpoints"))
|
||||
<sequence key="_sandbox_key_error_"/>
|
||||
#elseif($endpoint_config.get("sandbox_endpoints"))
|
||||
<sequence key="_production_key_error_"/>
|
||||
#end
|
||||
#end
|
||||
</else>
|
||||
</filter>
|
||||
#end
|
||||
</inSequence>
|
||||
<outSequence>
|
||||
<class name="org.wso2.carbon.apimgt.usage.publisher.APIMgtResponseHandler"/>
|
||||
## check and set response caching
|
||||
#if($responseCacheEnabled)
|
||||
<cache scope="per-host" collector="true"/>
|
||||
#end
|
||||
<send/>
|
||||
</outSequence>
|
||||
</resource>
|
||||
#set ($resourceNo = $resourceNo + 1)
|
||||
#end ## end of resource iterator
|
||||
## print the handlers
|
||||
#if($handlers.size() > 0)
|
||||
<handlers xmlns="http://ws.apache.org/ns/synapse">
|
||||
#foreach($handler in $handlers)
|
||||
<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
|
||||
</handlers>
|
||||
#end
|
||||
#end
|
||||
#if($apiStatus == 'PROTOTYPED')
|
||||
#end
|
||||
## end of apiIsBlocked check
|
||||
<handlers>
|
||||
<handler class="org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler">
|
||||
<property name="inline" value="INLINE"/>
|
||||
</handler>
|
||||
</handlers>
|
||||
</api>
|
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<Server xmlns="http://wso2.org/projects/carbon/carbon.xml">
|
||||
|
||||
|
||||
<JDBCPersistenceManager>
|
||||
<DataSource>
|
||||
<!-- Include a data source name (jndiConfigName) from the set of data sources defined in master-datasources.xml -->
|
||||
<Name>jdbc/WSO2AM_DB</Name>
|
||||
</DataSource>
|
||||
<!-- If the identity database is created from another place and if it is required to skip schema initialization during the server start up, set the following
|
||||
property to "true". -->
|
||||
<!--<SkipDBSchemaCreation>true</SkipDBSchemaCreation>-->
|
||||
</JDBCPersistenceManager>
|
||||
|
||||
<ThriftSessionDAO>org.wso2.carbon.identity.thrift.authentication.dao.DBThriftSessionDAO</ThriftSessionDAO>
|
||||
<!--<ThriftSessionDAO>org.wso2.carbon.identity.thrift.authentication.dao.InMemoryThriftSessionDAO</ThriftSessionDAO>-->
|
||||
|
||||
<ClientTimeout>30000</ClientTimeout>
|
||||
|
||||
<!--<Hostname>localhost</Hostname>-->
|
||||
<Port>10711</Port>
|
||||
|
||||
<!--30 min-->
|
||||
<ThriftSessionTimeout>1800000</ThriftSessionTimeout>
|
||||
|
||||
</Server>
|
Loading…
Reference in new issue