From e9f2062362e7f0bc31e23fcf2f55ce84fb361b5e Mon Sep 17 00:00:00 2001 From: ayyoob Date: Mon, 18 Apr 2016 02:58:55 +0530 Subject: [PATCH] added files related to activate synapse as a gateway --- .../api_templates/default_api_template.xml | 79 ++++ .../api_templates/prototype_template.xml | 262 +++++++++++++ .../api_templates/velocity_template.xml | 366 ++++++++++++++++++ modules/distribution/src/assembly/bin.xml | 25 +- .../conf/identity/thrift-authentication.xml | 44 +++ 5 files changed, 766 insertions(+), 10 deletions(-) create mode 100644 modules/distribution/src/api-resources/api_templates/default_api_template.xml create mode 100644 modules/distribution/src/api-resources/api_templates/prototype_template.xml create mode 100644 modules/distribution/src/api-resources/api_templates/velocity_template.xml create mode 100644 modules/distribution/src/repository/conf/identity/thrift-authentication.xml diff --git a/modules/distribution/src/api-resources/api_templates/default_api_template.xml b/modules/distribution/src/api-resources/api_templates/default_api_template.xml new file mode 100644 index 00000000..8cbb8f05 --- /dev/null +++ b/modules/distribution/src/api-resources/api_templates/default_api_template.xml @@ -0,0 +1,79 @@ + + #foreach($resource in $resources) + + + + + + + + + + + + 500 + Status report + Internal Server Error + Faulty invoking through default API + + + + + + +
+ + + + + + + + +
+ #if( $transport == "https" ) + + #else + + #end + + + + #if( $transport == "https" ) + + #else + + #end + + 60000 + fault + + + 1.0 + + + 0 + 0 + + + + + + + + + + + + #end ## end of resource iterator + + + + diff --git a/modules/distribution/src/api-resources/api_templates/prototype_template.xml b/modules/distribution/src/api-resources/api_templates/prototype_template.xml new file mode 100644 index 00000000..05ffc526 --- /dev/null +++ b/modules/distribution/src/api-resources/api_templates/prototype_template.xml @@ -0,0 +1,262 @@ + + + ##################### 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 + #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 + + #else + ## print nothing. + #end +#end + +#macro ( timeout $config) + #if( $config.get("actionSelect") == "neverTimeout" ) + ## print nothing. + #elseif($config.get("actionDuration")|| $config.get("actionSelect")) + + #print_if_exist_only("duration" $config.get("actionDuration")) + #print_if_exist_only("responseAction" $config.get("actionSelect")) + + #end + + #print_list( "errorCodes" $config.get("suspendErrorCode")) + #print_if_exist_only("initialDuration" $config.get("suspendDuration")) + #print_if_exist_only("maximumDuration" $config.get("suspendMaxDuration")) + #print_if_exist( $config.get("factor") 1.0) + + + #print_list("errorCodes" $config.get("retryErroCode")) + #print_if_exist( $config.get("retryTimeOut") 0) + #print_if_exist( $config.get("retryDelay") 0) + +#end + + #macro ( http_endpoint $name $ep ) + + +#timeout( $ep.get('config') ) + + #if($destinationBasedStatsEnabled) + + #end + + #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) + + + + #else + + #end + #end + +#if ($endpointClass == "http") +#http_endpoint($ep_name $endpoints) +#elseif ($endpointClass == "address") + + #set( $advance_ep = $endpoints.get("config") ) +
+ #timeout( $endpoints.get('config') ) +
+#if($destinationBasedStatsEnabled) + +#end +
+ #elseif ($endpointClass == "wsdl") + + +#timeout() + + #if($destinationBasedStatsEnabled) + + #end + + #elseif ($endpointClass == "failover") + #set( $failover_endpoints = $endpoint_config.get("${type}_failovers")) + + + #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 + + + #elseif ($endpointClass == "load_balance") + +#if($endpoint_config.get("sessionManagement") && $endpoint_config.get("sessionManagement") != "" && $endpoint_config.get("sessionManagement") != "none") + +#if($endpoint_config.get("sessionTimeOut") && $endpoint_config.get("sessionTimeOut") != "") +$endpoint_config.get("sessionTimeOut") +#end + + #end + + #set( $i = 0) + #foreach($endpoint in $endpoints) + #http_endpoint("${ep_name}_$i" $endpoint) + #set( $i = $i + 1) + #end + + + #end +
+ #if($destinationBasedStatsEnabled) + + + + + + #end + #end + + ######################## End of Macros ###################################### + + + +#if($apiIsBlocked) +## if API is blocked send the API Block message + + + + + + 700700 + API blocked + This API has been blocked temporarily. Please try again later or contact the system administrators. + + + + + + +
+ + + +#else +## api not blocked +#set ($resourceNo = 0) +#foreach($resource in $resources) + + + #if(!$resource.getMediationScript().equalsIgnoreCase("null")) + + + + + + + + + + #else + + #end + #if($resource.getMethodsAsString().contains("GET")||$resource.getMethodsAsString().contains("DELETE")) + + #end + + + + + + + #set ($resourceNo = $resourceNo + 1) + #end ## end of resource iterator + ## print the handlers + #if($handlers.size() > 0) + +#foreach($handler in $handlers) + + #if($handler.hasProperties()) + #set ($map = $handler.getProperties() ) + #foreach($property in $map.entrySet()) + + #end + #end + +#end + +#end +#if($apiStatus == 'PROTOTYPED') +#end +#end +## end of apiIsBlocked check + diff --git a/modules/distribution/src/api-resources/api_templates/velocity_template.xml b/modules/distribution/src/api-resources/api_templates/velocity_template.xml new file mode 100644 index 00000000..a3d2d0a8 --- /dev/null +++ b/modules/distribution/src/api-resources/api_templates/velocity_template.xml @@ -0,0 +1,366 @@ + + + ##################### 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 + #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 + + #else + ## print nothing. + #end + #end + + #macro ( timeout $config) + #if( $config.get("actionSelect") == "neverTimeout" ) + ## print nothing. + #elseif($config.get("actionDuration")|| $config.get("actionSelect")) + +#print_if_exist_only("duration" $config.get("actionDuration")) +#print_if_exist_only("responseAction" $config.get("actionSelect")) + + #end + +#print_list( "errorCodes" $config.get("suspendErrorCode")) +#print_if_exist_only("initialDuration" $config.get("suspendDuration")) +#print_if_exist_only("maximumDuration" $config.get("suspendMaxDuration")) +#print_if_exist( $config.get("factor") 1.0) + + +#print_list("errorCodes" $config.get("retryErroCode")) +#print_if_exist( $config.get("retryTimeOut") 0) +#print_if_exist( $config.get("retryDelay") 0) + + #end + + #macro ( http_endpoint $name $ep ) + + +#timeout( $ep.get('config') ) + + #if($destinationBasedStatsEnabled) + + #end + + #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) + + + + #else + #if($isEndpointAuthDigest) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #else + + #end + #end + #end + + +## If endpoint is http +#if ($endpointClass == "http") +#http_endpoint($ep_name $endpoints) +#elseif ($endpointClass == "address") + + #set( $advance_ep = $endpoints.get("config") ) +
+ #timeout( $endpoints.get('config') ) +
+#if($destinationBasedStatsEnabled) + +#end +
+ #elseif ($endpointClass == "wsdl") + +#if (${type} == "production") + +#timeout() + + #else + + #timeout() + + #end + #if($destinationBasedStatsEnabled) + + #end + + #elseif ($endpointClass == "failover") + #set( $failover_endpoints = $endpoint_config.get("${type}_failovers")) + + + #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 + + + #elseif ($endpointClass == "load_balance") + +#if($endpoint_config.get("sessionManagement") && $endpoint_config.get("sessionManagement") != "" && $endpoint_config.get("sessionManagement") != "none") + +#if($endpoint_config.get("sessionTimeOut") && $endpoint_config.get("sessionTimeOut") != "") +$endpoint_config.get("sessionTimeOut") +#end + + #end + + #set( $i = 0) + #foreach($endpoint in $endpoints) + #http_endpoint("${ep_name}_$i" $endpoint) + #set( $i = $i + 1) + #end + + +#elseif ($endpointClass == "default") + + + + + #end +
+ #if($destinationBasedStatsEnabled) + + + + + + + + + + #end + #end + + ######################## End of Macros ###################################### + + + +#if($apiIsBlocked) +## if API is blocked send the API Block message + + + + + + 700700 + API blocked + This API has been blocked temporarily. Please try again later or contact the system administrators. + + + + + + +
+ + + + #else + ## api not blocked + #set ($resourceNo = 0) + #foreach($resource in $resources) + + + +## check and set jwt +#if($jwtIsEnabled && ($apiStatus != 'PROTOTYPED')) + +#end +## check and set response caching +#if($responseCacheEnabled) + + + +#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') + + + #end + + #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') + + + #if($environmentType !='hybrid') + + + + #if($environmentType == 'production') + Sandbox Key Provided for Production Gateway + #elseif($environmentType == 'sandbox') + Production Key Provided for Sandbox Gateway + #end + + + + + +
+ + + + #else + #if($endpoint_config.get("production_endpoints") && $endpoint_config.get("sandbox_endpoints")) + #draw_endpoint( "sandbox" $endpoint_config ) + #elseif($endpoint_config.get("production_endpoints")) + + #elseif($endpoint_config.get("sandbox_endpoints")) + + #end + #end + + +#end + + + +## check and set response caching +#if($responseCacheEnabled) + +#end + + + + #set ($resourceNo = $resourceNo + 1) + #end ## end of resource iterator + ## print the handlers + #if($handlers.size() > 0) + +#foreach($handler in $handlers) + + #if($handler.hasProperties()) + #set ($map = $handler.getProperties() ) + #foreach($property in $map.entrySet()) + + #end + #end + +#end + + #end + #end + #if($apiStatus == 'PROTOTYPED') + #end + ## end of apiIsBlocked check + + + + + + diff --git a/modules/distribution/src/assembly/bin.xml b/modules/distribution/src/assembly/bin.xml index 46023646..c41947e2 100644 --- a/modules/distribution/src/assembly/bin.xml +++ b/modules/distribution/src/assembly/bin.xml @@ -111,7 +111,7 @@ **/nimbus-jose-jwt_2.26.1.wso2v2.jar **/org.wso2.carbon.hostobjects.sso_4.4.3.jar **/org.wso2.carbon.hostobjects.sso_4.3.2.jar - **/libthrift_0.8.0.wso2v1.jar + **/am#sample#calculator#v1.war **/api.war @@ -880,15 +880,6 @@ 644 - - - ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/identity/thrift-authentication.xml - - ${pom.artifactId}-${pom.version}/repository/conf/identity - - true - 644 - src/repository/conf/application-authenticators.xml ${pom.artifactId}-${pom.version}/repository/conf/security/ @@ -908,6 +899,20 @@ 644 + + src/repository/conf/identity/thrift-authentication.xml + ${pom.artifactId}-${pom.version}/repository/conf/identity + true + 644 + + + + src/repository/conf/identity/identity-providers/CDMF_DEFAULT_IDP.xml + + ${pom.artifactId}-${pom.version}/repository/conf/identity/identity-providers + true + 644 + diff --git a/modules/distribution/src/repository/conf/identity/thrift-authentication.xml b/modules/distribution/src/repository/conf/identity/thrift-authentication.xml new file mode 100644 index 00000000..646da0b1 --- /dev/null +++ b/modules/distribution/src/repository/conf/identity/thrift-authentication.xml @@ -0,0 +1,44 @@ + + + + + + + + + + jdbc/WSO2AM_DB + + + + + + org.wso2.carbon.identity.thrift.authentication.dao.DBThriftSessionDAO + + + 30000 + + + 10711 + + + 1800000 + +