Skip to content

Commit

Permalink
Merge pull request #127 from Ashi1993/gateway
Browse files Browse the repository at this point in the history
Adding Accelerator Gateway Implementation
  • Loading branch information
aka4rKO authored Oct 2, 2024
2 parents ccaa8bc + 118d0f4 commit 0a65db6
Show file tree
Hide file tree
Showing 26 changed files with 2,593 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,9 @@ public class FinancialServicesConstants {
"Identity.TokenSubject.RemoveUserStoreDomainFromSubject";
public static final String REMOVE_TENANT_DOMAIN_FROM_SUBJECT =
"Identity.TokenSubject.RemoveTenantDomainFromSubject";
public static final String PUBLISHER_HOSTNAME = "PublisherURL";
public static final String REQUEST_ROUTER = "Gateway.RequestRouter";
public static final String GATEWAY_CACHE_EXPIRY = "Gateway.Cache.GatewayCache.CacheAccessExpiry";
public static final String GATEWAY_CACHE_MODIFIED_EXPIRY = "Gateway.Cache.GatewayCache.CacheModifiedExpiry";
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
~ Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
~
~ WSO2 LLC. 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>financial-services-accelerator</artifactId>
<groupId>org.wso2.financial.services.accelerator</groupId>
<version>4.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>org.wso2.financial.services.accelerator.gateway</artifactId>
<name>WSO2 Financial Services - Gateway Module</name>
<description>WSO2 Financial Services - Gateway Module</description>
<url>http://maven.apache.org</url>
<packaging>bundle</packaging>

<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser</artifactId>
</dependency>
<dependency>
<groupId>commons-io.wso2</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.impl</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.common.gateway</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.financial.services.accelerator</groupId>
<artifactId>org.wso2.financial.services.accelerator.common</artifactId>
</dependency>
<!-- Unit Test Dependencies -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
<xmlOutput>true</xmlOutput>
<failOnError>true</failOnError>
<spotbugsXmlOutputDirectory>${project.build.directory}/spotbugs</spotbugsXmlOutputDirectory>
<excludeFilterFile>${project.basedir}/src/main/resources/findbugs-exclude.xml</excludeFilterFile>
<includeFilterFile>${project.basedir}/src/main/resources/findbugs-include.xml</includeFilterFile>
<plugins>
<plugin>
<groupId>com.h3xstream.findsecbugs</groupId>
<artifactId>findsecbugs-plugin</artifactId>
<version>${com.h3xstream.findsecbugs.version}</version>
</plugin>
</plugins>
</configuration>
<executions>
<execution>
<id>analyze-compile</id>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
<reuseForks>true</reuseForks>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<configuration>
<excludes>
<!--Excluding them in coverage reports-->
<exclude>**/*Constants.class</exclude>
<exclude>**/*Component.class</exclude>
<exclude>**/*DataHolder.class</exclude>
<exclude>**/*Cache.class</exclude>
<exclude>**/*CacheKey.class</exclude>
<exclude>**/*APIRequestContext.class</exclude>
<exclude>**/*APIResponseContext.class</exclude>
<exclude>**/*ExecutorError.class</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-prepare-agent-integration</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-report-integration</id>
<goals>
<goal>report-integration</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule implementation="org.jacoco.maven.RuleConfiguration">
<element>BUNDLE</element>
<limits>
<limit implementation="org.jacoco.report.check.Limit">
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>0.8</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>
${project.artifactId}
</Bundle-SymbolicName>
<Private-Package>
org.wso2.financial.services.accelerator.gateway.internal
</Private-Package>
<Import-Package>
org.osgi.framework; version="${osgi.framework.imp.pkg.version.range}",
org.osgi.service.component; version="${osgi.service.component.imp.pkg.version.range}",
org.apache.commons.io;version="${org.apache.commons.io.version.range}",
io.swagger.parser.*;version="${swagger.parser.version}",
org.apache.commons.logging;version="${commons.logging.version}",
org.apache.http.*;version="${orbit.httpcore.version}",
org.json;version="${org.json.version.range}",
org.wso2.carbon.apimgt.common.gateway.*;version="${org.wso2.carbon.apimgt.version.range}",
org.wso2.carbon.apimgt.impl;version="${org.wso2.carbon.apimgt.version.range}",
org.wso2.financial.services.accelerator.common.*;version="${project.version}"
</Import-Package>
<Export-Package>
!org.wso2.financial.services.accelerator.gateway.internal,
org.wso2.financial.services.accelerator.gateway.*;version="${project.version}",
</Export-Package>
<_dsannotations>*</_dsannotations>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
* <p>
* WSO2 LLC. 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
*/

package org.wso2.financial.services.accelerator.gateway.cache;

import org.wso2.financial.services.accelerator.common.caching.FinancialServicesBaseCache;
import org.wso2.financial.services.accelerator.gateway.internal.GatewayDataHolder;

/**
* Cache definition to store API Resource Security Schemes
*/
public class GatewayCache extends FinancialServicesBaseCache<GatewayCacheKey, Object> {

private static final String cacheName = "FINANCIAL_SERVICES_GATEWAY_CACHE";

private final Integer accessExpiryMinutes;
private final Integer modifiedExpiryMinutes;

/**
* Initialize with unique cache name.
*/
public GatewayCache() {

super(cacheName);
this.accessExpiryMinutes = setAccessExpiryMinutes();
this.modifiedExpiryMinutes = setModifiedExpiryMinutes();
}

@Override
public int getCacheAccessExpiryMinutes() {

return accessExpiryMinutes;
}

@Override
public int getCacheModifiedExpiryMinutes() {

return modifiedExpiryMinutes;
}

public int setAccessExpiryMinutes() {

return GatewayDataHolder.getInstance().getGatewayCacheAccessExpiry();
}

public int setModifiedExpiryMinutes() {

return GatewayDataHolder.getInstance().getGatewayCacheModifiedExpiry();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
* <p>
* WSO2 LLC. 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
*/

package org.wso2.financial.services.accelerator.gateway.cache;


import org.wso2.financial.services.accelerator.common.caching.FinancialServicesBaseCacheKey;

import java.io.Serializable;
import java.util.Objects;

/**
* Cache Key for Financial Services Gateway cache.
*/
public class GatewayCacheKey extends FinancialServicesBaseCacheKey implements Serializable {

private static final long serialVersionUID = 883027070771592120L;
public String gatewayCacheKey;

public GatewayCacheKey(String gatewayCacheKey) {

this.gatewayCacheKey = gatewayCacheKey;
}

public static GatewayCacheKey of(String gatewayCacheKey) {

return new GatewayCacheKey(gatewayCacheKey);
}

@Override
public boolean equals(Object o) {

if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GatewayCacheKey that = (GatewayCacheKey) o;
return Objects.equals(gatewayCacheKey, that.gatewayCacheKey);
}

@Override
public int hashCode() {

return Objects.hash(gatewayCacheKey);
}
}
Loading

0 comments on commit 0a65db6

Please sign in to comment.