mirror of
https://github.com/valitydev/adapter-bank-spring-boot-starter.git
synced 2024-11-06 01:05:20 +00:00
refactor project, update deps, add flow lib (#15)
This commit is contained in:
parent
4c5457466f
commit
55a702ab84
3
.github/workflows/deploy.yml
vendored
3
.github/workflows/deploy.yml
vendored
@ -8,9 +8,10 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
uses: valitydev/base-workflow/.github/workflows/maven-library-deploy.yml@v1
|
uses: valitydev/java-workflow/.github/workflows/maven-library-deploy.yml@v1
|
||||||
secrets:
|
secrets:
|
||||||
server-username: ${{ secrets.OSSRH_USERNAME }}
|
server-username: ${{ secrets.OSSRH_USERNAME }}
|
||||||
server-password: ${{ secrets.OSSRH_TOKEN }}
|
server-password: ${{ secrets.OSSRH_TOKEN }}
|
||||||
deploy-secret-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
|
deploy-secret-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
|
||||||
deploy-secret-key-password: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
|
deploy-secret-key-password: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
|
||||||
|
mm-webhook-url: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
|
||||||
|
63
README.md
63
README.md
@ -1,21 +1,56 @@
|
|||||||
### adapter-bank-spring-boot-starter
|
### adapter-bank-spring-boot-starter
|
||||||
|
|
||||||
**Adapter-bank-spring-boot-starter** - это подключаемый Spring Boot модуль для стандартных
|
**Adapter-bank-spring-boot-starter** - это подключаемый Spring Boot модуль для стандартных компонентов proxy-адаптеров.
|
||||||
компонентов proxy-алаптеров.
|
|
||||||
|
|
||||||
Для корректной работы Вашего адаптера необходимо:
|
```yaml
|
||||||
* подключить необходимые properties (AdapterProperties, TimerProperties). Если поля родителя
|
adapter:
|
||||||
не покрывают всех необходимых бизнес-полей, то необходимо унаследоваться от родителя и
|
url: http://127.0.0.1
|
||||||
при помощи аннотаций @Configuration и @ConfigurationProperties создать соответствующий
|
callbackUrl: http://127.0.0.1:8080
|
||||||
класс конфигураций .Если поля родителя полностью покрывают case, то можно не создавать
|
pathCallbackUrl: /${server.rest.endpoint}/term_url
|
||||||
класс-наследник, а создать соответствующий bean в конфигурации. Например:
|
pathRecurrentCallbackUrl: /${server.rest.endpoint}/rec_term_url
|
||||||
|
defaultTermUrl: https://checkout.empayre.com/v1/finish-interaction.html
|
||||||
|
tagPrefix: adapter-
|
||||||
|
|
||||||
|
bender:
|
||||||
|
client:
|
||||||
|
url: http://127.0.0.1:8022/v1/bender
|
||||||
|
networkTimeout: 5000
|
||||||
|
namespace: namespace
|
||||||
|
|
||||||
@Bean
|
cds:
|
||||||
@Primary
|
client:
|
||||||
@ConfigurationProperties("time.config")
|
identity-document-storage:
|
||||||
public TimerProperties timerProperties() {
|
url: http://127.0.0.1:8022/v1/identity_document_storage
|
||||||
return new TimerProperties();
|
networkTimeout: 5000
|
||||||
}
|
storage:
|
||||||
|
url: http://127.0.0.1:8022/v1/storage
|
||||||
|
networkTimeout: 5000
|
||||||
|
|
||||||
|
hellgate:
|
||||||
|
client:
|
||||||
|
url: http://127.0.0.1:8022/v1/proxyhost/provider
|
||||||
|
networkTimeout: 30000
|
||||||
|
|
||||||
|
time:
|
||||||
|
config:
|
||||||
|
maxTimePollingMin: 60
|
||||||
|
pollingDelayMs: 1000
|
||||||
|
redirectTimeoutMin: 15
|
||||||
|
exponential: 2
|
||||||
|
defaultInitialExponential: 2
|
||||||
|
maxTimeBackOff: 600
|
||||||
|
maxTimeCoefficient: 2
|
||||||
|
|
||||||
|
rest-template:
|
||||||
|
requestTimeout: 60000
|
||||||
|
poolTimeout: 10000
|
||||||
|
connectionTimeout: 10000
|
||||||
|
maxTotalPooling: 200
|
||||||
|
defaultMaxPerRoute: 200
|
||||||
|
networkTimeout: 60000
|
||||||
|
connectTimeout: 10000
|
||||||
|
|
||||||
|
error-mapping:
|
||||||
|
file: classpath:fixture/errors.json
|
||||||
|
patternReason: "'%s' - '%s'" # 'code' - 'description'
|
||||||
|
```
|
102
pom.xml
102
pom.xml
@ -12,7 +12,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>adapter-bank-spring-boot-starter</artifactId>
|
<artifactId>adapter-bank-spring-boot-starter</artifactId>
|
||||||
<version>0.0.1</version>
|
<version>0.0.2</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>adapter-bank-spring-boot-starter</name>
|
<name>adapter-bank-spring-boot-starter</name>
|
||||||
<description>Spring boot starter for bank adapter</description>
|
<description>Spring boot starter for bank adapter</description>
|
||||||
@ -39,26 +39,16 @@
|
|||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>15</maven.compiler.source>
|
<spring-boot.version>2.6.7</spring-boot.version>
|
||||||
<maven.compiler.target>15</maven.compiler.target>
|
<damsel.version>1.563-d384c12</damsel.version>
|
||||||
<java.version>15</java.version>
|
|
||||||
|
|
||||||
<adapter-client-lib.version>1.0.1</adapter-client-lib.version>
|
|
||||||
<adapter-thrift-lib.version>1.0.0</adapter-thrift-lib.version>
|
|
||||||
<adapter-common-lib.version>1.0.0</adapter-common-lib.version>
|
|
||||||
|
|
||||||
<damsel.version>1.544-dcd92dd</damsel.version>
|
|
||||||
<cds-proto.version>1.66-01353ce</cds-proto.version>
|
<cds-proto.version>1.66-01353ce</cds-proto.version>
|
||||||
|
|
||||||
<spring-boot.version>2.6.3</spring-boot.version>
|
|
||||||
<woody.version>1.0.4</woody.version>
|
<woody.version>1.0.4</woody.version>
|
||||||
<geck.version>0.0.1</geck.version>
|
<geck.version>0.0.1</geck.version>
|
||||||
<lombok.version>1.18.22</lombok.version>
|
<lombok.version>1.18.24</lombok.version>
|
||||||
<slf4j-api.version>1.7.30</slf4j-api.version>
|
<slf4j-api.version>1.7.36</slf4j-api.version>
|
||||||
<javax.servlet-api.version>4.0.1</javax.servlet-api.version>
|
<javax.servlet-api.version>4.0.1</javax.servlet-api.version>
|
||||||
<hibernate-validator.version>6.1.5.Final</hibernate-validator.version>
|
<jackson.version>2.13.2</jackson.version>
|
||||||
<error-mapping-java.version>1.0.0</error-mapping-java.version>
|
<adapter-flow-lib.version>0.1.5</adapter-flow-lib.version>
|
||||||
<junit.version>4.12</junit.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -82,9 +72,22 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate.validator</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>hibernate-validator</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>${hibernate-validator.version}</version>
|
<version>${jackson.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
<version>${jackson.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
<version>${jackson.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--spring-->
|
<!--spring-->
|
||||||
@ -109,21 +112,30 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
<version>${spring-boot.version}</version>
|
<version>${spring-boot.version}</version>
|
||||||
<scope>provided</scope>
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.hibernate</groupId>
|
||||||
|
<artifactId>hibernate-validator</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-aop</artifactId>
|
<artifactId>spring-boot-starter-aop</artifactId>
|
||||||
<version>${spring-boot.version}</version>
|
<version>${spring-boot.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--vality-->
|
<!--vality-->
|
||||||
<dependency>
|
|
||||||
<groupId>dev.vality</groupId>
|
|
||||||
<artifactId>error-mapping-java</artifactId>
|
|
||||||
<version>${error-mapping-java.version}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.vality.woody</groupId>
|
<groupId>dev.vality.woody</groupId>
|
||||||
<artifactId>woody-thrift</artifactId>
|
<artifactId>woody-thrift</artifactId>
|
||||||
@ -143,37 +155,37 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.vality.adapter-thrift-lib</groupId>
|
<groupId>dev.vality</groupId>
|
||||||
<artifactId>cds-utils</artifactId>
|
<artifactId>bender-proto</artifactId>
|
||||||
<version>${adapter-thrift-lib.version}</version>
|
<version>1.20-be9cdeb</version>
|
||||||
</dependency>
|
<scope>provided</scope>
|
||||||
<dependency>
|
|
||||||
<groupId>dev.vality.adapter-thrift-lib</groupId>
|
|
||||||
<artifactId>damsel-utils</artifactId>
|
|
||||||
<version>${adapter-thrift-lib.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.vality.geck</groupId>
|
<groupId>dev.vality.geck</groupId>
|
||||||
<artifactId>serializer</artifactId>
|
<artifactId>serializer</artifactId>
|
||||||
<version>${geck.version}</version>
|
<version>${geck.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>dev.vality.adapter-client-lib</groupId>
|
|
||||||
<artifactId>hellgate-adapter-client</artifactId>
|
|
||||||
<version>${adapter-client-lib.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.vality</groupId>
|
<groupId>dev.vality</groupId>
|
||||||
<artifactId>adapter-common-lib</artifactId>
|
<artifactId>adapter-flow-lib</artifactId>
|
||||||
<version>${adapter-common-lib.version}</version>
|
<version>${adapter-flow-lib.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- test -->
|
<!-- test -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<version>${junit.version}</version>
|
<version>${spring-boot.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.22.2</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.bank.spring.boot.starter.configuration.properties.AdapterProperties;
|
||||||
|
import dev.vality.adapter.flow.lib.service.TagManagementService;
|
||||||
|
import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableConfigurationProperties({AdapterProperties.class})
|
||||||
|
public class AdapterConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public TagManagementService tagManagementService(
|
||||||
|
dev.vality.adapter.flow.lib.utils.AdapterProperties adapterProperties) {
|
||||||
|
return new TagManagementService(adapterProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public CallbackUrlExtractor callbackUrlExtractor(
|
||||||
|
dev.vality.adapter.flow.lib.utils.AdapterProperties adapterProperties) {
|
||||||
|
return new CallbackUrlExtractor(adapterProperties);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.bank.spring.boot.starter.configuration.properties.BenderClientProperties;
|
||||||
|
import dev.vality.adapter.common.bender.BenderClient;
|
||||||
|
import dev.vality.adapter.flow.lib.service.IdGenerator;
|
||||||
|
import dev.vality.bender.BenderSrv;
|
||||||
|
import dev.vality.woody.thrift.impl.http.THSpawnClientBuilder;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableConfigurationProperties({BenderClientProperties.class})
|
||||||
|
public class BenderConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public BenderSrv.Iface benderSrv(BenderClientProperties properties) throws IOException {
|
||||||
|
return new THSpawnClientBuilder()
|
||||||
|
.withAddress(properties.getUrl().getURI())
|
||||||
|
.withNetworkTimeout(properties.getNetworkTimeout())
|
||||||
|
.build(BenderSrv.Iface.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public BenderClient benderClient(BenderSrv.Iface benderSrv, BenderClientProperties properties) {
|
||||||
|
return new BenderClient(benderSrv, properties.getNamespace());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public IdGenerator idGenerator(BenderSrv.Iface benderSrv) {
|
||||||
|
return new IdGenerator(benderSrv);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.bank.spring.boot.starter.configuration.properties.CdsIdStorageClientProperties;
|
||||||
|
import dev.vality.adapter.common.cds.CdsIdStorageClient;
|
||||||
|
import dev.vality.damsel.identity_document_storage.IdentityDocumentStorageSrv;
|
||||||
|
import dev.vality.woody.thrift.impl.http.THSpawnClientBuilder;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableConfigurationProperties(CdsIdStorageClientProperties.class)
|
||||||
|
public class CdsIdStorageClientConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public IdentityDocumentStorageSrv.Iface identityDocumentStorageSrv(CdsIdStorageClientProperties properties)
|
||||||
|
throws IOException {
|
||||||
|
return new THSpawnClientBuilder()
|
||||||
|
.withAddress(properties.getUrl().getURI())
|
||||||
|
.withNetworkTimeout(properties.getNetworkTimeout())
|
||||||
|
.build(IdentityDocumentStorageSrv.Iface.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public CdsIdStorageClient cdsIdStorageClient(IdentityDocumentStorageSrv.Iface identityDocumentStorageSrv) {
|
||||||
|
return new CdsIdStorageClient(identityDocumentStorageSrv);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.bank.spring.boot.starter.configuration.properties.CdsStorageClientProperties;
|
||||||
|
import dev.vality.adapter.common.cds.CdsStorageClient;
|
||||||
|
import dev.vality.cds.storage.StorageSrv;
|
||||||
|
import dev.vality.woody.thrift.impl.http.THSpawnClientBuilder;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableConfigurationProperties({CdsStorageClientProperties.class})
|
||||||
|
public class CdsStorageClientConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public StorageSrv.Iface storageSrv(CdsStorageClientProperties properties) throws IOException {
|
||||||
|
return new THSpawnClientBuilder()
|
||||||
|
.withAddress(properties.getUrl().getURI())
|
||||||
|
.withNetworkTimeout(properties.getNetworkTimeout())
|
||||||
|
.build(StorageSrv.Iface.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public CdsStorageClient cdsStorageClient(StorageSrv.Iface storageSrv) {
|
||||||
|
return new CdsStorageClient(storageSrv);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.common.cds.CdsStorageClient;
|
||||||
|
import dev.vality.adapter.flow.lib.converter.entry.CtxToEntryModelConverter;
|
||||||
|
import dev.vality.adapter.flow.lib.serde.TemporaryContextDeserializer;
|
||||||
|
import dev.vality.adapter.flow.lib.service.IdGenerator;
|
||||||
|
import dev.vality.adapter.flow.lib.service.TemporaryContextService;
|
||||||
|
import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class CtxToEntryModelConverterConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public CtxToEntryModelConverter ctxToEntryModelConverter(
|
||||||
|
CdsStorageClient cdsStorageClient,
|
||||||
|
TemporaryContextDeserializer temporaryContextDeserializer,
|
||||||
|
IdGenerator idGenerator,
|
||||||
|
TemporaryContextService temporaryContextService,
|
||||||
|
CallbackUrlExtractor callbackUrlExtractor) {
|
||||||
|
return new CtxToEntryModelConverter(
|
||||||
|
cdsStorageClient,
|
||||||
|
temporaryContextDeserializer,
|
||||||
|
idGenerator,
|
||||||
|
temporaryContextService,
|
||||||
|
callbackUrlExtractor);
|
||||||
|
}
|
||||||
|
}
|
@ -1,30 +0,0 @@
|
|||||||
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import dev.vality.adapter.common.state.deserializer.AdapterDeserializer;
|
|
||||||
import dev.vality.adapter.common.state.deserializer.CallbackDeserializer;
|
|
||||||
import dev.vality.adapter.common.state.deserializer.RecurrentTokenDeserializer;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class DeserializerConfiguration {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public CallbackDeserializer callbackDeserializer(ObjectMapper objectMapper) {
|
|
||||||
return new CallbackDeserializer(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public AdapterDeserializer adapterDeserializer(ObjectMapper objectMapper) {
|
|
||||||
return new AdapterDeserializer(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public RecurrentTokenDeserializer recTokenDeserializer(ObjectMapper objectMapper) {
|
|
||||||
return new RecurrentTokenDeserializer(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,14 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.flow.lib.converter.base.EntryModelToBaseRequestModelConverter;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class EntryModelToBaseRequestModelConverterConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public EntryModelToBaseRequestModelConverter entryModelToBaseRequestModelConverter() {
|
||||||
|
return new EntryModelToBaseRequestModelConverter();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.flow.lib.converter.ExitStateModelToTemporaryContextConverter;
|
||||||
|
import dev.vality.adapter.flow.lib.converter.exit.ExitModelToProxyResultConverter;
|
||||||
|
import dev.vality.adapter.flow.lib.flow.ResultIntentResolver;
|
||||||
|
import dev.vality.adapter.flow.lib.serde.TemporaryContextSerializer;
|
||||||
|
import dev.vality.adapter.flow.lib.service.IntentResultFactory;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class ExitModelToProxyResultConverterConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ExitModelToProxyResultConverter exitModelToProxyResultConverter(
|
||||||
|
IntentResultFactory intentResultFactory,
|
||||||
|
TemporaryContextSerializer temporaryContextSerializer,
|
||||||
|
ResultIntentResolver resultIntentResolver,
|
||||||
|
ExitStateModelToTemporaryContextConverter exitStateModelToTemporaryContextConverter) {
|
||||||
|
return new ExitModelToProxyResultConverter(
|
||||||
|
intentResultFactory,
|
||||||
|
temporaryContextSerializer,
|
||||||
|
resultIntentResolver,
|
||||||
|
exitStateModelToTemporaryContextConverter);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.flow.lib.converter.ExitStateModelToTemporaryContextConverter;
|
||||||
|
import dev.vality.adapter.flow.lib.converter.exit.ExitModelToRecTokenProxyResultConverter;
|
||||||
|
import dev.vality.adapter.flow.lib.flow.RecurrentResultIntentResolver;
|
||||||
|
import dev.vality.adapter.flow.lib.serde.TemporaryContextSerializer;
|
||||||
|
import dev.vality.adapter.flow.lib.service.RecurrentIntentResultFactory;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class ExitModelToRecTokenProxyResultConverterConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ExitModelToRecTokenProxyResultConverter exitModelToRecTokenProxyResultConverter(
|
||||||
|
RecurrentIntentResultFactory recurrentIntentResultFactory,
|
||||||
|
TemporaryContextSerializer temporaryContextSerializer,
|
||||||
|
RecurrentResultIntentResolver recurrentResultIntentResolver,
|
||||||
|
ExitStateModelToTemporaryContextConverter exitStateModelToTemporaryContextConverter) {
|
||||||
|
return new ExitModelToRecTokenProxyResultConverter(
|
||||||
|
recurrentIntentResultFactory,
|
||||||
|
temporaryContextSerializer,
|
||||||
|
recurrentResultIntentResolver,
|
||||||
|
exitStateModelToTemporaryContextConverter);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.flow.lib.converter.ExitStateModelToTemporaryContextConverter;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class ExitStateModelToTemporaryContextConverterConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ExitStateModelToTemporaryContextConverter exitStateModelToTemporaryContextConverter() {
|
||||||
|
return new ExitStateModelToTemporaryContextConverter();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.flow.lib.service.ExponentialBackOffPollingService;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class ExponentialBackOffPollingServiceConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ExponentialBackOffPollingService exponentialBackOffPollingService() {
|
||||||
|
return new ExponentialBackOffPollingService();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.bank.spring.boot.starter.configuration.properties.HellgateClientProperties;
|
||||||
|
import dev.vality.adapter.common.hellgate.HellgateClient;
|
||||||
|
import dev.vality.damsel.proxy_provider.ProviderProxyHostSrv;
|
||||||
|
import dev.vality.woody.thrift.impl.http.THSpawnClientBuilder;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableConfigurationProperties({HellgateClientProperties.class})
|
||||||
|
public class HellgateClientConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ProviderProxyHostSrv.Iface providerProxyHostSrv(HellgateClientProperties properties) throws IOException {
|
||||||
|
return new THSpawnClientBuilder()
|
||||||
|
.withAddress(properties.getUrl().getURI())
|
||||||
|
.withNetworkTimeout(properties.getNetworkTimeout())
|
||||||
|
.build(ProviderProxyHostSrv.Iface.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public HellgateClient hellgateClient(ProviderProxyHostSrv.Iface providerProxyHostSrv) {
|
||||||
|
return new HellgateClient(providerProxyHostSrv);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.common.mapper.ErrorMapping;
|
||||||
|
import dev.vality.adapter.flow.lib.serde.ParametersSerializer;
|
||||||
|
import dev.vality.adapter.flow.lib.service.ExponentialBackOffPollingService;
|
||||||
|
import dev.vality.adapter.flow.lib.service.IntentResultFactory;
|
||||||
|
import dev.vality.adapter.flow.lib.service.PollingInfoService;
|
||||||
|
import dev.vality.adapter.flow.lib.service.TagManagementService;
|
||||||
|
import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor;
|
||||||
|
import dev.vality.adapter.flow.lib.utils.TimerProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class IntentResultFactoryConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public IntentResultFactory intentResultFactory(
|
||||||
|
TimerProperties timerProperties,
|
||||||
|
CallbackUrlExtractor callbackUrlExtractor,
|
||||||
|
TagManagementService tagManagementService,
|
||||||
|
ParametersSerializer parametersSerializer,
|
||||||
|
PollingInfoService pollingInfoService,
|
||||||
|
ErrorMapping errorMapping,
|
||||||
|
ExponentialBackOffPollingService exponentialBackOffPollingService) {
|
||||||
|
return new IntentResultFactory(
|
||||||
|
timerProperties,
|
||||||
|
callbackUrlExtractor,
|
||||||
|
tagManagementService,
|
||||||
|
parametersSerializer,
|
||||||
|
pollingInfoService,
|
||||||
|
errorMapping,
|
||||||
|
exponentialBackOffPollingService);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.common.component.LoggingInterceptor;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class LoggingInterceptorConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public LoggingInterceptor loggingInterceptor() {
|
||||||
|
return new LoggingInterceptor();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.flow.lib.handler.callback.PaymentCallbackHandler;
|
||||||
|
import dev.vality.adapter.flow.lib.serde.TemporaryContextDeserializer;
|
||||||
|
import dev.vality.adapter.flow.lib.serde.TemporaryContextSerializer;
|
||||||
|
import dev.vality.adapter.flow.lib.service.TemporaryContextService;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class PaymentCallbackHandlerConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public PaymentCallbackHandler paymentCallbackHandler(
|
||||||
|
TemporaryContextDeserializer temporaryContextDeserializer,
|
||||||
|
TemporaryContextSerializer temporaryContextSerializer,
|
||||||
|
TemporaryContextService temporaryContextService) {
|
||||||
|
return new PaymentCallbackHandler(
|
||||||
|
temporaryContextDeserializer,
|
||||||
|
temporaryContextSerializer,
|
||||||
|
temporaryContextService);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.bank.spring.boot.starter.configuration.utils.CommonHandlerUtils;
|
||||||
|
import dev.vality.adapter.flow.lib.client.RemoteClient;
|
||||||
|
import dev.vality.adapter.flow.lib.converter.base.EntryModelToBaseRequestModelConverter;
|
||||||
|
import dev.vality.adapter.flow.lib.converter.entry.CtxToEntryModelConverter;
|
||||||
|
import dev.vality.adapter.flow.lib.converter.exit.ExitModelToProxyResultConverter;
|
||||||
|
import dev.vality.adapter.flow.lib.flow.StepResolver;
|
||||||
|
import dev.vality.adapter.flow.lib.handler.ServerFlowHandler;
|
||||||
|
import dev.vality.adapter.flow.lib.model.BaseResponseModel;
|
||||||
|
import dev.vality.adapter.flow.lib.model.EntryStateModel;
|
||||||
|
import dev.vality.adapter.flow.lib.model.ExitStateModel;
|
||||||
|
import dev.vality.adapter.flow.lib.processor.Processor;
|
||||||
|
import dev.vality.damsel.proxy_provider.PaymentContext;
|
||||||
|
import dev.vality.damsel.proxy_provider.PaymentProxyResult;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class PaymentServerFlowHandlerConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ServerFlowHandler<PaymentContext, PaymentProxyResult> paymentServerFlowHandler(
|
||||||
|
RemoteClient remoteClient,
|
||||||
|
EntryModelToBaseRequestModelConverter entryModelToBaseRequestModelConverter,
|
||||||
|
Processor<ExitStateModel, BaseResponseModel, EntryStateModel> baseProcessor,
|
||||||
|
StepResolver<EntryStateModel, ExitStateModel> stepResolver,
|
||||||
|
CtxToEntryModelConverter ctxToEntryModelConverter,
|
||||||
|
ExitModelToProxyResultConverter exitModelToProxyResultConverter) {
|
||||||
|
return new ServerFlowHandler<>(
|
||||||
|
CommonHandlerUtils.getHandlers(remoteClient, entryModelToBaseRequestModelConverter, baseProcessor),
|
||||||
|
stepResolver,
|
||||||
|
ctxToEntryModelConverter,
|
||||||
|
exitModelToProxyResultConverter);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.flow.lib.model.BaseResponseModel;
|
||||||
|
import dev.vality.adapter.flow.lib.model.EntryStateModel;
|
||||||
|
import dev.vality.adapter.flow.lib.model.ExitStateModel;
|
||||||
|
import dev.vality.adapter.flow.lib.processor.*;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class ProcessorConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Processor<ExitStateModel, BaseResponseModel, EntryStateModel> baseProcessor() {
|
||||||
|
ErrorProcessor errorProcessor = new ErrorProcessor();
|
||||||
|
SuccessFinishProcessor baseProcessor = new SuccessFinishProcessor(errorProcessor);
|
||||||
|
RedirectProcessor redirectProcessor = new RedirectProcessor(baseProcessor);
|
||||||
|
return new RetryProcessor(redirectProcessor);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.common.cds.CdsStorageClient;
|
||||||
|
import dev.vality.adapter.flow.lib.converter.entry.RecCtxToEntryModelConverter;
|
||||||
|
import dev.vality.adapter.flow.lib.serde.TemporaryContextDeserializer;
|
||||||
|
import dev.vality.adapter.flow.lib.service.IdGenerator;
|
||||||
|
import dev.vality.adapter.flow.lib.service.TemporaryContextService;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RecCtxToEntryModelConverterConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RecCtxToEntryModelConverter recCtxToEntryModelConverter(
|
||||||
|
CdsStorageClient cdsStorageClient,
|
||||||
|
TemporaryContextDeserializer temporaryContextDeserializer,
|
||||||
|
IdGenerator idGenerator,
|
||||||
|
TemporaryContextService temporaryContextService) {
|
||||||
|
return new RecCtxToEntryModelConverter(
|
||||||
|
temporaryContextDeserializer,
|
||||||
|
cdsStorageClient,
|
||||||
|
idGenerator,
|
||||||
|
temporaryContextService);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.common.mapper.ErrorMapping;
|
||||||
|
import dev.vality.adapter.flow.lib.service.ExponentialBackOffPollingService;
|
||||||
|
import dev.vality.adapter.flow.lib.service.PollingInfoService;
|
||||||
|
import dev.vality.adapter.flow.lib.service.RecurrentIntentResultFactory;
|
||||||
|
import dev.vality.adapter.flow.lib.service.TagManagementService;
|
||||||
|
import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor;
|
||||||
|
import dev.vality.adapter.flow.lib.utils.TimerProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RecurrentIntentResultFactoryConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RecurrentIntentResultFactory recurrentIntentResultFactory(
|
||||||
|
TimerProperties timerProperties,
|
||||||
|
CallbackUrlExtractor callbackUrlExtractor,
|
||||||
|
TagManagementService tagManagementService,
|
||||||
|
PollingInfoService pollingInfoService,
|
||||||
|
ErrorMapping errorMapping,
|
||||||
|
ExponentialBackOffPollingService exponentialBackOffPollingService) {
|
||||||
|
return new RecurrentIntentResultFactory(
|
||||||
|
timerProperties,
|
||||||
|
callbackUrlExtractor,
|
||||||
|
tagManagementService,
|
||||||
|
pollingInfoService,
|
||||||
|
errorMapping,
|
||||||
|
exponentialBackOffPollingService);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.flow.lib.flow.RecurrentResultIntentResolver;
|
||||||
|
import dev.vality.adapter.flow.lib.flow.simple.SimpleRedirectGenerateTokenResultIntentResolver;
|
||||||
|
import dev.vality.adapter.flow.lib.service.RecurrentIntentResultFactory;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RecurrentResultIntentResolverConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RecurrentResultIntentResolver recurrentResultIntentResolver(
|
||||||
|
RecurrentIntentResultFactory recurrentIntentResultFactory) {
|
||||||
|
return new SimpleRedirectGenerateTokenResultIntentResolver(recurrentIntentResultFactory);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.flow.lib.handler.callback.RecurrentTokenCallbackHandler;
|
||||||
|
import dev.vality.adapter.flow.lib.serde.TemporaryContextDeserializer;
|
||||||
|
import dev.vality.adapter.flow.lib.serde.TemporaryContextSerializer;
|
||||||
|
import dev.vality.adapter.flow.lib.service.TemporaryContextService;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RecurrentTokenCallbackHandlerConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RecurrentTokenCallbackHandler recurrentTokenCallbackHandler(
|
||||||
|
TemporaryContextDeserializer temporaryContextDeserializer,
|
||||||
|
TemporaryContextSerializer temporaryContextSerializer,
|
||||||
|
TemporaryContextService temporaryContextService) {
|
||||||
|
return new RecurrentTokenCallbackHandler(
|
||||||
|
temporaryContextDeserializer,
|
||||||
|
temporaryContextSerializer,
|
||||||
|
temporaryContextService);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.common.component.RequestLoggingAspect;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RequestLoggingAspectConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RequestLoggingAspect requestLoggingAspect() {
|
||||||
|
return new RequestLoggingAspect();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,129 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.http.client.config.RequestConfig;
|
||||||
|
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||||
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||||
|
import org.apache.http.ssl.SSLContextBuilder;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.actuate.metrics.web.client.MetricsRestTemplateCustomizer;
|
||||||
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||||
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||||
|
import org.springframework.web.client.DefaultResponseErrorHandler;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import java.security.KeyManagementException;
|
||||||
|
import java.security.KeyStoreException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RestTemplateConfiguration {
|
||||||
|
|
||||||
|
@Value("${rest-template.maxTotalPooling}")
|
||||||
|
private int maxTotalPooling;
|
||||||
|
|
||||||
|
@Value("${rest-template.defaultMaxPerRoute}")
|
||||||
|
private int defaultMaxPerRoute;
|
||||||
|
|
||||||
|
@Value("${rest-template.requestTimeout}")
|
||||||
|
private int requestTimeout;
|
||||||
|
|
||||||
|
@Value("${rest-template.poolTimeout}")
|
||||||
|
private int poolTimeout;
|
||||||
|
|
||||||
|
@Value("${rest-template.connectionTimeout}")
|
||||||
|
private int connectionTimeout;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public PoolingHttpClientConnectionManager poolingHttpClientConnectionManager() {
|
||||||
|
PoolingHttpClientConnectionManager result = new PoolingHttpClientConnectionManager();
|
||||||
|
result.setMaxTotal(maxTotalPooling);
|
||||||
|
result.setDefaultMaxPerRoute(defaultMaxPerRoute);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RequestConfig requestConfig() {
|
||||||
|
return RequestConfig.custom()
|
||||||
|
.setConnectionRequestTimeout(poolTimeout)
|
||||||
|
.setConnectTimeout(connectionTimeout)
|
||||||
|
.setSocketTimeout(requestTimeout)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public SSLContext sslContext() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
|
||||||
|
return new SSLContextBuilder()
|
||||||
|
.loadTrustMaterial(null, (x509Certificates, s) -> true)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public CloseableHttpClient httpClient(
|
||||||
|
PoolingHttpClientConnectionManager manager,
|
||||||
|
RequestConfig requestConfig,
|
||||||
|
SSLContext sslContext) {
|
||||||
|
return HttpClients.custom()
|
||||||
|
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
|
||||||
|
.setSSLContext(sslContext)
|
||||||
|
.setConnectionManager(manager)
|
||||||
|
.setDefaultRequestConfig(requestConfig)
|
||||||
|
.disableAutomaticRetries()
|
||||||
|
.setConnectionManagerShared(true)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public HttpComponentsClientHttpRequestFactory requestFactory(CloseableHttpClient httpClient) {
|
||||||
|
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
|
||||||
|
requestFactory.setHttpClient(httpClient);
|
||||||
|
return requestFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestTemplateBuilder restTemplateBuilder(
|
||||||
|
HttpComponentsClientHttpRequestFactory requestFactory,
|
||||||
|
MetricsRestTemplateCustomizer metricsRestTemplateCustomizer) {
|
||||||
|
return new RestTemplateBuilder()
|
||||||
|
.requestFactory(() -> requestFactory)
|
||||||
|
.additionalCustomizers(metricsRestTemplateCustomizer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
|
||||||
|
RestTemplate restTemplate = restTemplateBuilder
|
||||||
|
.setConnectTimeout(Duration.ofMillis(connectionTimeout))
|
||||||
|
.setReadTimeout(Duration.ofMillis(requestTimeout))
|
||||||
|
.build();
|
||||||
|
restTemplate.setErrorHandler(getDefaultResponseErrorHandler());
|
||||||
|
setMessageConverter(restTemplate);
|
||||||
|
return restTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setMessageConverter(RestTemplate restTemplate) {
|
||||||
|
for (HttpMessageConverter converter : restTemplate.getMessageConverters()) {
|
||||||
|
if (converter instanceof StringHttpMessageConverter) {
|
||||||
|
((StringHttpMessageConverter) converter).setWriteAcceptCharset(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private DefaultResponseErrorHandler getDefaultResponseErrorHandler() {
|
||||||
|
return new DefaultResponseErrorHandler() {
|
||||||
|
@Override
|
||||||
|
protected boolean hasError(HttpStatus statusCode) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.flow.lib.flow.ResultIntentResolver;
|
||||||
|
import dev.vality.adapter.flow.lib.flow.simple.SimpleRedirectWithPollingResultIntentResolver;
|
||||||
|
import dev.vality.adapter.flow.lib.service.IntentResultFactory;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class ResultIntentResolverConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ResultIntentResolver resultIntentResolver(IntentResultFactory intentResultFactory) {
|
||||||
|
return new SimpleRedirectWithPollingResultIntentResolver(intentResultFactory);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import dev.vality.adapter.flow.lib.serde.ParametersDeserializer;
|
||||||
|
import dev.vality.adapter.flow.lib.serde.ParametersSerializer;
|
||||||
|
import dev.vality.adapter.flow.lib.serde.TemporaryContextDeserializer;
|
||||||
|
import dev.vality.adapter.flow.lib.serde.TemporaryContextSerializer;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class SerdeConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public TemporaryContextDeserializer adapterDeserializer(ObjectMapper objectMapper) {
|
||||||
|
return new TemporaryContextDeserializer(objectMapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public TemporaryContextSerializer adapterSerializer(ObjectMapper objectMapper) {
|
||||||
|
return new TemporaryContextSerializer(objectMapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ParametersDeserializer parametersDeserializer(ObjectMapper objectMapper) {
|
||||||
|
return new ParametersDeserializer(objectMapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ParametersSerializer parametersSerializer(ObjectMapper objectMapper) {
|
||||||
|
return new ParametersSerializer(objectMapper);
|
||||||
|
}
|
||||||
|
}
|
@ -1,30 +0,0 @@
|
|||||||
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import dev.vality.adapter.common.state.serializer.AdapterSerializer;
|
|
||||||
import dev.vality.adapter.common.state.serializer.CallbackSerializer;
|
|
||||||
import dev.vality.adapter.common.state.serializer.RecurrentTokenSerializer;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class SerializerConfiguration {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public CallbackSerializer callbackSerializer(ObjectMapper objectMapper) {
|
|
||||||
return new CallbackSerializer(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public AdapterSerializer adapterSerializer(ObjectMapper objectMapper) {
|
|
||||||
return new AdapterSerializer(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public RecurrentTokenSerializer recTokenSerializer(ObjectMapper objectMapper) {
|
|
||||||
return new RecurrentTokenSerializer(objectMapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,30 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.flow.lib.handler.ProxyProviderServiceImpl;
|
||||||
|
import dev.vality.adapter.flow.lib.handler.ServerFlowHandler;
|
||||||
|
import dev.vality.adapter.flow.lib.handler.ServerHandlerLogDecorator;
|
||||||
|
import dev.vality.adapter.flow.lib.handler.callback.PaymentCallbackHandler;
|
||||||
|
import dev.vality.adapter.flow.lib.handler.callback.RecurrentTokenCallbackHandler;
|
||||||
|
import dev.vality.adapter.flow.lib.validator.AdapterConfigurationValidator;
|
||||||
|
import dev.vality.damsel.proxy_provider.*;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class ServerHandlerLogDecoratorConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ProviderProxySrv.Iface serverHandlerLogDecorator(
|
||||||
|
PaymentCallbackHandler paymentCallbackHandler,
|
||||||
|
RecurrentTokenCallbackHandler recurrentTokenCallbackHandler,
|
||||||
|
ServerFlowHandler<PaymentContext, PaymentProxyResult> paymentServerFlowHandler,
|
||||||
|
ServerFlowHandler<RecurrentTokenContext, RecurrentTokenProxyResult> tokenServerFlowHandler,
|
||||||
|
AdapterConfigurationValidator adapterConfigurationValidator) {
|
||||||
|
return new ServerHandlerLogDecorator(new ProxyProviderServiceImpl(
|
||||||
|
paymentCallbackHandler,
|
||||||
|
recurrentTokenCallbackHandler,
|
||||||
|
paymentServerFlowHandler,
|
||||||
|
tokenServerFlowHandler,
|
||||||
|
adapterConfigurationValidator));
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,16 @@
|
|||||||
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import dev.vality.adapter.common.component.SimpleErrorMapping;
|
||||||
import dev.vality.adapter.common.mapper.SimpleErrorMapping;
|
import dev.vality.adapter.common.mapper.ErrorMapping;
|
||||||
import dev.vality.adapter.common.mapper.SimpleObjectMapper;
|
|
||||||
import dev.vality.error.mapping.ErrorMapping;
|
|
||||||
import java.io.IOException;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class AppConfiguration {
|
public class SimpleErrorMappingConfiguration {
|
||||||
|
|
||||||
@Value("${error-mapping.file}")
|
@Value("${error-mapping.file}")
|
||||||
private Resource errorMappingFilePath;
|
private Resource errorMappingFilePath;
|
||||||
@ -24,10 +23,4 @@ public class AppConfiguration {
|
|||||||
return new SimpleErrorMapping(errorMappingFilePath, errorMappingPattern).createErrorMapping();
|
return new SimpleErrorMapping(errorMappingFilePath, errorMappingPattern).createErrorMapping();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ObjectMapper objectMapper() {
|
|
||||||
return new SimpleObjectMapper().createSimpleObjectMapperFactory();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import dev.vality.adapter.common.component.SimpleObjectMapper;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class SimpleObjectMapperConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ObjectMapper objectMapper() {
|
||||||
|
return new SimpleObjectMapper().createSimpleObjectMapperFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.flow.lib.serde.ParametersDeserializer;
|
||||||
|
import dev.vality.adapter.flow.lib.service.TemporaryContextService;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class TemporaryContextServiceConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public TemporaryContextService temporaryContextService(ParametersDeserializer parametersDeserializer) {
|
||||||
|
return new TemporaryContextService(parametersDeserializer);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.common.hellgate.HellgateClient;
|
||||||
|
import dev.vality.adapter.flow.lib.serde.ParametersDeserializer;
|
||||||
|
import dev.vality.adapter.flow.lib.serde.ParametersSerializer;
|
||||||
|
import dev.vality.adapter.flow.lib.service.TagManagementService;
|
||||||
|
import dev.vality.adapter.flow.lib.service.ThreeDsAdapterService;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class ThreeDsAdapterServiceConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ThreeDsAdapterService threeDsAdapterService(
|
||||||
|
HellgateClient hellgateClient,
|
||||||
|
ParametersSerializer parametersSerializer,
|
||||||
|
ParametersDeserializer parametersDeserializer,
|
||||||
|
TagManagementService tagManagementService) {
|
||||||
|
return new ThreeDsAdapterService(
|
||||||
|
hellgateClient,
|
||||||
|
parametersSerializer,
|
||||||
|
parametersDeserializer,
|
||||||
|
tagManagementService);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.bank.spring.boot.starter.configuration.properties.TimerProperties;
|
||||||
|
import dev.vality.adapter.flow.lib.service.PollingInfoService;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableConfigurationProperties({TimerProperties.class})
|
||||||
|
public class TimerConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public PollingInfoService pollingInfoService(
|
||||||
|
dev.vality.adapter.flow.lib.utils.TimerProperties timerProperties) {
|
||||||
|
return new PollingInfoService(timerProperties);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.bank.spring.boot.starter.configuration.utils.CommonHandlerUtils;
|
||||||
|
import dev.vality.adapter.flow.lib.client.RemoteClient;
|
||||||
|
import dev.vality.adapter.flow.lib.converter.base.EntryModelToBaseRequestModelConverter;
|
||||||
|
import dev.vality.adapter.flow.lib.converter.entry.RecCtxToEntryModelConverter;
|
||||||
|
import dev.vality.adapter.flow.lib.converter.exit.ExitModelToRecTokenProxyResultConverter;
|
||||||
|
import dev.vality.adapter.flow.lib.flow.StepResolver;
|
||||||
|
import dev.vality.adapter.flow.lib.handler.ServerFlowHandler;
|
||||||
|
import dev.vality.adapter.flow.lib.model.BaseResponseModel;
|
||||||
|
import dev.vality.adapter.flow.lib.model.EntryStateModel;
|
||||||
|
import dev.vality.adapter.flow.lib.model.ExitStateModel;
|
||||||
|
import dev.vality.adapter.flow.lib.processor.Processor;
|
||||||
|
import dev.vality.damsel.proxy_provider.RecurrentTokenContext;
|
||||||
|
import dev.vality.damsel.proxy_provider.RecurrentTokenProxyResult;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class TokenServerFlowHandlerConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ServerFlowHandler<RecurrentTokenContext, RecurrentTokenProxyResult> tokenServerFlowHandler(
|
||||||
|
RemoteClient remoteClient,
|
||||||
|
EntryModelToBaseRequestModelConverter entryModelToBaseRequestModelConverter,
|
||||||
|
Processor<ExitStateModel, BaseResponseModel, EntryStateModel> baseProcessor,
|
||||||
|
StepResolver<EntryStateModel, ExitStateModel> stepResolver,
|
||||||
|
RecCtxToEntryModelConverter recCtxToEntryStateModelConverter,
|
||||||
|
ExitModelToRecTokenProxyResultConverter exitModelToRecTokenProxyResultConverter) {
|
||||||
|
return new ServerFlowHandler<>(
|
||||||
|
CommonHandlerUtils.getHandlers(remoteClient, entryModelToBaseRequestModelConverter, baseProcessor),
|
||||||
|
stepResolver,
|
||||||
|
recCtxToEntryStateModelConverter,
|
||||||
|
exitModelToRecTokenProxyResultConverter);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration.properties;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
@ConfigurationProperties(prefix = "adapter")
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@Validated
|
||||||
|
public class AdapterProperties extends dev.vality.adapter.flow.lib.utils.AdapterProperties {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration.properties;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@ConfigurationProperties(prefix = "bender.client")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Validated
|
||||||
|
public class BenderClientProperties {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private Resource url;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private int networkTimeout = 5000;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private String namespace;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration.properties;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@ConfigurationProperties(prefix = "cds.client.identity-document-storage")
|
||||||
|
@Validated
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class CdsIdStorageClientProperties {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private Resource url;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private int networkTimeout = 5000;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration.properties;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@ConfigurationProperties(prefix = "cds.client.storage")
|
||||||
|
@Validated
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class CdsStorageClientProperties {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private Resource url;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private int networkTimeout = 5000;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration.properties;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@ConfigurationProperties(prefix = "hellgate.client")
|
||||||
|
@Validated
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class HellgateClientProperties {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private Resource url;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private int networkTimeout = 5000;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration.properties;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
@ConfigurationProperties("time.config")
|
||||||
|
@Validated
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class TimerProperties extends dev.vality.adapter.flow.lib.utils.TimerProperties {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration.utils;
|
||||||
|
|
||||||
|
import dev.vality.adapter.flow.lib.client.RemoteClient;
|
||||||
|
import dev.vality.adapter.flow.lib.converter.base.EntryModelToBaseRequestModelConverter;
|
||||||
|
import dev.vality.adapter.flow.lib.handler.CommonHandler;
|
||||||
|
import dev.vality.adapter.flow.lib.handler.payment.*;
|
||||||
|
import dev.vality.adapter.flow.lib.model.BaseResponseModel;
|
||||||
|
import dev.vality.adapter.flow.lib.model.EntryStateModel;
|
||||||
|
import dev.vality.adapter.flow.lib.model.ExitStateModel;
|
||||||
|
import dev.vality.adapter.flow.lib.processor.Processor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CommonHandlerUtils {
|
||||||
|
|
||||||
|
public static List<CommonHandler<ExitStateModel, EntryStateModel>> getHandlers(
|
||||||
|
RemoteClient remoteClient,
|
||||||
|
EntryModelToBaseRequestModelConverter entryModelToBaseRequestModelConverter,
|
||||||
|
Processor<ExitStateModel, BaseResponseModel, EntryStateModel> baseProcessor) {
|
||||||
|
return List.of(
|
||||||
|
new AuthHandler(remoteClient, entryModelToBaseRequestModelConverter, baseProcessor),
|
||||||
|
new CancelHandler(remoteClient, entryModelToBaseRequestModelConverter, baseProcessor),
|
||||||
|
new CaptureHandler(remoteClient, entryModelToBaseRequestModelConverter, baseProcessor),
|
||||||
|
new StatusHandler(remoteClient, entryModelToBaseRequestModelConverter, baseProcessor),
|
||||||
|
new DoNothingHandler(),
|
||||||
|
new PaymentHandler(remoteClient, entryModelToBaseRequestModelConverter, baseProcessor),
|
||||||
|
new GenerateTokenHandler(remoteClient, entryModelToBaseRequestModelConverter, baseProcessor),
|
||||||
|
new RefundHandler(remoteClient, entryModelToBaseRequestModelConverter, baseProcessor));
|
||||||
|
}
|
||||||
|
}
|
@ -1,42 +0,0 @@
|
|||||||
package dev.vality.adapter.bank.spring.boot.starter.controller;
|
|
||||||
|
|
||||||
import dev.vality.adapter.common.controller.AdapterController;
|
|
||||||
import dev.vality.adapter.common.state.deserializer.CallbackDeserializer;
|
|
||||||
import dev.vality.adapter.common.state.serializer.CallbackSerializer;
|
|
||||||
import dev.vality.adapter.helpers.hellgate.HellgateAdapterClient;
|
|
||||||
import java.io.IOException;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/${server.rest.endpoint}")
|
|
||||||
public class AdapterControllerDecorator {
|
|
||||||
|
|
||||||
private AdapterController adapterController;
|
|
||||||
|
|
||||||
public AdapterControllerDecorator(
|
|
||||||
HellgateAdapterClient hgClient,
|
|
||||||
CallbackSerializer callbackSerializer,
|
|
||||||
CallbackDeserializer callbackDeserializer
|
|
||||||
) {
|
|
||||||
adapterController = new AdapterController(hgClient, callbackSerializer, callbackDeserializer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping(value = "term_url")
|
|
||||||
public String receivePaymentIncomingParameters(HttpServletRequest servletRequest,
|
|
||||||
HttpServletResponse servletResponse) throws IOException {
|
|
||||||
return adapterController.receivePaymentIncomingParameters(servletRequest, servletResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping(value = "rec_term_url")
|
|
||||||
public String receiveRecurrentIncomingParameters(HttpServletRequest servletRequest,
|
|
||||||
HttpServletResponse servletResponse) throws IOException {
|
|
||||||
return adapterController.receiveRecurrentIncomingParameters(servletRequest, servletResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
package dev.vality.adapter.bank.spring.boot.starter.flow;
|
|
||||||
|
|
||||||
import dev.vality.adapter.bank.spring.boot.starter.model.GeneralEntryStateModel;
|
|
||||||
import dev.vality.adapter.bank.spring.boot.starter.model.GeneralExitStateModel;
|
|
||||||
import dev.vality.adapter.common.enums.Step;
|
|
||||||
|
|
||||||
public class DefaultStepResolverImpl implements StepResolver<GeneralEntryStateModel, GeneralExitStateModel> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Step resolveEntry(GeneralEntryStateModel stateModel) {
|
|
||||||
switch (stateModel.getTargetStatus()) {
|
|
||||||
case PROCESSED:
|
|
||||||
return resolveProcessedSteps(stateModel);
|
|
||||||
case CAPTURED:
|
|
||||||
return Step.CAPTURE;
|
|
||||||
case REFUNDED:
|
|
||||||
return Step.REFUND;
|
|
||||||
case CANCELLED:
|
|
||||||
return Step.CANCEL;
|
|
||||||
default:
|
|
||||||
throw new IllegalStateException("Unknown status of entryState");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Step resolveProcessedSteps(GeneralEntryStateModel stateModel) {
|
|
||||||
if (isNextThreeDs(stateModel)) {
|
|
||||||
return Step.FINISH_THREE_DS;
|
|
||||||
} else if (stateModel.isMakeRecurrent()) {
|
|
||||||
return Step.AUTH_RECURRENT;
|
|
||||||
} else if (stateModel.getRecToken() != null && !stateModel.getRecToken().isEmpty()) {
|
|
||||||
return Step.RECURRENT;
|
|
||||||
}
|
|
||||||
return Step.AUTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isNextThreeDs(GeneralEntryStateModel stateModel) {
|
|
||||||
Step step = stateModel.getAdapterContext().getStep();
|
|
||||||
return stateModel.getAdapterContext() != null
|
|
||||||
&& (Step.FINISH_THREE_DS.equals(step) || Step.GENERATE_TOKEN_FINISH_THREE_DS.equals(step));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Step resolveExit(GeneralExitStateModel stateModel) {
|
|
||||||
Step step = stateModel.getGeneralEntryStateModel().getAdapterContext().getStep();
|
|
||||||
Step nextStep = stateModel.getAdapterContext().getStep();
|
|
||||||
switch (step) {
|
|
||||||
case AUTH_RECURRENT:
|
|
||||||
if (Step.FINISH_THREE_DS.equals(nextStep)) {
|
|
||||||
return Step.GENERATE_TOKEN_FINISH_THREE_DS;
|
|
||||||
} else {
|
|
||||||
return Step.GENERATE_TOKEN_CAPTURE;
|
|
||||||
}
|
|
||||||
case GENERATE_TOKEN_FINISH_THREE_DS:
|
|
||||||
return Step.GENERATE_TOKEN_CAPTURE;
|
|
||||||
case GENERATE_TOKEN_CAPTURE:
|
|
||||||
return Step.GENERATE_TOKEN_REFUND;
|
|
||||||
case GENERATE_TOKEN_REFUND:
|
|
||||||
return Step.GENERATE_TOKEN_FINISH;
|
|
||||||
default:
|
|
||||||
return nextStep;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package dev.vality.adapter.bank.spring.boot.starter.flow;
|
|
||||||
|
|
||||||
import dev.vality.adapter.bank.spring.boot.starter.model.GeneralEntryStateModel;
|
|
||||||
import dev.vality.adapter.bank.spring.boot.starter.model.GeneralExitStateModel;
|
|
||||||
import dev.vality.adapter.common.enums.Step;
|
|
||||||
|
|
||||||
public interface StepResolver<T extends GeneralEntryStateModel, R extends GeneralExitStateModel> {
|
|
||||||
|
|
||||||
Step resolveEntry(T entryStateModel);
|
|
||||||
|
|
||||||
Step resolveExit(R exitStateModel);
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package dev.vality.adapter.bank.spring.boot.starter.logging.annotation;
|
|
||||||
|
|
||||||
import org.springframework.core.annotation.AliasFor;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
@Target({ElementType.METHOD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface GetLogging {
|
|
||||||
|
|
||||||
@AliasFor("value")
|
|
||||||
String endpoint() default "/";
|
|
||||||
|
|
||||||
@AliasFor("endpoint")
|
|
||||||
String value() default "/";
|
|
||||||
|
|
||||||
RequestMethod method() default RequestMethod.GET;
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package dev.vality.adapter.bank.spring.boot.starter.logging.annotation;
|
|
||||||
|
|
||||||
import org.springframework.core.annotation.AliasFor;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
@Target({ElementType.METHOD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface PostLogging {
|
|
||||||
|
|
||||||
@AliasFor("value")
|
|
||||||
String endpoint() default "/";
|
|
||||||
|
|
||||||
@AliasFor("endpoint")
|
|
||||||
String value() default "/";
|
|
||||||
|
|
||||||
RequestMethod method() default RequestMethod.POST;
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
package dev.vality.adapter.bank.spring.boot.starter.logging.aspect;
|
|
||||||
|
|
||||||
import dev.vality.adapter.bank.spring.boot.starter.logging.annotation.GetLogging;
|
|
||||||
import dev.vality.adapter.bank.spring.boot.starter.logging.annotation.PostLogging;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
|
||||||
import org.aspectj.lang.annotation.Around;
|
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
|
||||||
import org.aspectj.lang.reflect.MethodSignature;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.core.annotation.AnnotationUtils;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Aspect
|
|
||||||
@Configuration
|
|
||||||
public class RequestLoggingAspect {
|
|
||||||
|
|
||||||
private static final String REQUEST_LOG = "Request [{} {}]: {}";
|
|
||||||
private static final String RESPONSE_LOG = "Response [{} {}]: {}";
|
|
||||||
|
|
||||||
@Around("@annotation(dev.vality.adapter.bank.spring.boot.starter.logging.annotation.GetLogging)")
|
|
||||||
public Object logGetRequest(ProceedingJoinPoint joinPoint) throws Throwable {
|
|
||||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
|
||||||
GetLogging getLogging = AnnotationUtils.findAnnotation(signature.getMethod(), GetLogging.class);
|
|
||||||
|
|
||||||
RequestMethod method = getLogging.method();
|
|
||||||
String endpoint = getLogging.value();
|
|
||||||
|
|
||||||
return log(joinPoint, method, endpoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Around("@annotation(dev.vality.adapter.bank.spring.boot.starter.logging.annotation.PostLogging)")
|
|
||||||
public Object logPostRequest(ProceedingJoinPoint joinPoint) throws Throwable {
|
|
||||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
|
||||||
PostLogging postLogging = AnnotationUtils.findAnnotation(signature.getMethod(), PostLogging.class);
|
|
||||||
|
|
||||||
RequestMethod method = postLogging.method();
|
|
||||||
String endpoint = postLogging.value();
|
|
||||||
|
|
||||||
return log(joinPoint, method, endpoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object log(
|
|
||||||
ProceedingJoinPoint joinPoint,
|
|
||||||
RequestMethod method,
|
|
||||||
String endpoint) throws Throwable {
|
|
||||||
if (joinPoint.getArgs().length != 1) {
|
|
||||||
log.debug("Unable to log request. Unsupported method signature with more than one argument: {}",
|
|
||||||
joinPoint.getArgs());
|
|
||||||
return joinPoint.proceed();
|
|
||||||
}
|
|
||||||
|
|
||||||
Object request = joinPoint.getArgs()[0];
|
|
||||||
log.info(REQUEST_LOG, method, endpoint, request);
|
|
||||||
Object response = joinPoint.proceed();
|
|
||||||
log.info(RESPONSE_LOG, method, endpoint, response);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
package dev.vality.adapter.bank.spring.boot.starter.model;
|
|
||||||
|
|
||||||
import dev.vality.adapter.common.enums.TargetStatus;
|
|
||||||
import dev.vality.adapter.common.model.AdapterContext;
|
|
||||||
import java.util.Map;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class GeneralEntryStateModel {
|
|
||||||
|
|
||||||
@ToString.Exclude
|
|
||||||
private String pan;
|
|
||||||
@ToString.Exclude
|
|
||||||
private Byte expMonth;
|
|
||||||
@ToString.Exclude
|
|
||||||
private Short expYear;
|
|
||||||
@ToString.Exclude
|
|
||||||
private String cvv2;
|
|
||||||
@ToString.Exclude
|
|
||||||
private String cardHolder;
|
|
||||||
|
|
||||||
private String orderId;
|
|
||||||
private Long amount;
|
|
||||||
private Short currencyCode;
|
|
||||||
private String currencySymbolCode;
|
|
||||||
private String createdAt;
|
|
||||||
|
|
||||||
private String ip;
|
|
||||||
private String email;
|
|
||||||
private String phone;
|
|
||||||
|
|
||||||
private Long refundAmount;
|
|
||||||
private String refundId;
|
|
||||||
private String invoiceDetails;
|
|
||||||
private String callbackUrl;
|
|
||||||
|
|
||||||
@ToString.Exclude
|
|
||||||
private Map<String, String> options;
|
|
||||||
|
|
||||||
private AdapterContext adapterContext;
|
|
||||||
private TargetStatus targetStatus;
|
|
||||||
|
|
||||||
private String recToken;
|
|
||||||
private boolean makeRecurrent;
|
|
||||||
|
|
||||||
private String tokenProvider;
|
|
||||||
private String cryptogram;
|
|
||||||
private String eci;
|
|
||||||
|
|
||||||
private String trxId;
|
|
||||||
private Map<String, String> trxExtra;
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package dev.vality.adapter.bank.spring.boot.starter.model;
|
|
||||||
|
|
||||||
import dev.vality.adapter.common.model.AdapterContext;
|
|
||||||
import java.util.Map;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class GeneralExitStateModel {
|
|
||||||
|
|
||||||
private String errorCode;
|
|
||||||
private String errorMessage;
|
|
||||||
private AdapterContext adapterContext;
|
|
||||||
private GeneralEntryStateModel generalEntryStateModel;
|
|
||||||
|
|
||||||
private Map<String, String> trxExtra;
|
|
||||||
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package dev.vality.adapter.bank.spring.boot.starter.service;
|
|
||||||
|
|
||||||
import dev.vality.adapter.bank.spring.boot.starter.model.GeneralExitStateModel;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public interface ThreeDsPropertiesService {
|
|
||||||
Map<String, String> initProperties(GeneralExitStateModel generalExitStateModel);
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
package dev.vality.adapter.bank.spring.boot.starter.service;
|
|
||||||
|
|
||||||
import dev.vality.adapter.bank.spring.boot.starter.model.GeneralExitStateModel;
|
|
||||||
import dev.vality.adapter.common.constants.ThreeDsFields;
|
|
||||||
import dev.vality.adapter.common.model.AdapterContext;
|
|
||||||
import dev.vality.adapter.common.properties.CommonAdapterProperties;
|
|
||||||
import dev.vality.adapter.common.utils.converter.RedirectUtils;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class ThreeDsPropertiesServiceImpl implements ThreeDsPropertiesService {
|
|
||||||
|
|
||||||
private final CommonAdapterProperties adapterProperties;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, String> initProperties(GeneralExitStateModel generalExitStateModel) {
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
AdapterContext adapterContext = generalExitStateModel.getAdapterContext();
|
|
||||||
params.put(ThreeDsFields.PA_REQ.getValue(), adapterContext.getPaReq());
|
|
||||||
params.put(ThreeDsFields.MD.getValue(), adapterContext.getMd());
|
|
||||||
params.put(ThreeDsFields.TERM_URL.getValue(), RedirectUtils.getCallbackUrl(
|
|
||||||
adapterProperties.getCallbackUrl(),
|
|
||||||
adapterProperties.getPathCallbackUrl())
|
|
||||||
);
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +1,33 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||||
dev.vality.adapter.bank.spring.boot.starter.configuration.AppConfiguration,\
|
dev.vality.adapter.bank.spring.boot.starter.configuration.SimpleObjectMapperConfiguration,\
|
||||||
dev.vality.adapter.bank.spring.boot.starter.configuration.SerializerConfiguration,\
|
dev.vality.adapter.bank.spring.boot.starter.configuration.SimpleErrorMappingConfiguration,\
|
||||||
dev.vality.adapter.bank.spring.boot.starter.configuration.DeserializerConfiguration,\
|
dev.vality.adapter.bank.spring.boot.starter.configuration.RestTemplateConfiguration,\
|
||||||
dev.vality.adapter.bank.spring.boot.starter.controller.AdapterControllerDecorator,\
|
dev.vality.adapter.bank.spring.boot.starter.configuration.RequestLoggingAspectConfiguration,\
|
||||||
dev.vality.adapter.bank.spring.boot.starter.service.ThreeDsPropertiesServiceImpl,\
|
dev.vality.adapter.bank.spring.boot.starter.configuration.NetworkConfiguration,\
|
||||||
dev.vality.adapter.bank.spring.boot.starter.logging.aspect.RequestLoggingAspect
|
dev.vality.adapter.bank.spring.boot.starter.configuration.LoggingInterceptorConfiguration,\
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.HellgateClientConfiguration,\
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.CdsStorageClientConfiguration,\
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.CdsIdStorageClientConfiguration,\
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.BenderConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.AdapterConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.TimerConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.SerdeConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.ProcessorConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.CtxToEntryModelConverterConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.EntryModelToBaseRequestModelConverterConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.ExitModelToProxyResultConverterConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.ExitModelToRecTokenProxyResultConverterConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.ExitStateModelToTemporaryContextConverterConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.ExponentialBackOffPollingServiceConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.IntentResultFactoryConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.PaymentCallbackHandlerConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.PaymentServerFlowHandlerConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.RecCtxToEntryModelConverterConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.RecurrentIntentResultFactoryConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.RecurrentResultIntentResolverConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.RecurrentTokenCallbackHandlerConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.ResultIntentResolverConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.ServerHandlerLogDecoratorConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.TemporaryContextServiceConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.ThreeDsAdapterServiceConfiguration, \
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.TokenServerFlowHandlerConfiguration
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
time.config:
|
|
||||||
redirectTimeout: 600
|
|
||||||
maxTimePolling: 600
|
|
||||||
pollingDelay: 10
|
|
||||||
---
|
|
||||||
error-mapping:
|
|
||||||
file: classpath:fixture/errors.json
|
|
||||||
patternReason: "'%s' - '%s'" # 'code' - 'description'
|
|
@ -1,7 +1 @@
|
|||||||
[
|
[]
|
||||||
{
|
|
||||||
"codeRegex": ".*",
|
|
||||||
"descriptionRegex": ".*",
|
|
||||||
"mapping": "ResultUnexpected"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.flow.lib.client.RemoteClient;
|
||||||
|
import org.springframework.boot.test.context.TestComponent;
|
||||||
|
|
||||||
|
@TestComponent
|
||||||
|
public class RemoteClientImpl implements RemoteClient {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
|
@SuppressWarnings({"all"})
|
||||||
|
@SpringBootTest(classes = {
|
||||||
|
RemoteClientImpl.class,
|
||||||
|
Validator.class,
|
||||||
|
StepResolver.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.SimpleObjectMapperConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.SimpleErrorMappingConfiguration.class,
|
||||||
|
// dev.vality.adapter.bank.spring.boot.starter.configuration.RestTemplateConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.RequestLoggingAspectConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.NetworkConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.LoggingInterceptorConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.HellgateClientConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.CdsStorageClientConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.CdsIdStorageClientConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.BenderConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.AdapterConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.TimerConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.SerdeConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.ProcessorConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.CtxToEntryModelConverterConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.EntryModelToBaseRequestModelConverterConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.ExitModelToProxyResultConverterConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.ExitModelToRecTokenProxyResultConverterConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.ExitStateModelToTemporaryContextConverterConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.ExponentialBackOffPollingServiceConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.IntentResultFactoryConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.PaymentCallbackHandlerConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.PaymentServerFlowHandlerConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.RecCtxToEntryModelConverterConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.RecurrentIntentResultFactoryConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.RecurrentResultIntentResolverConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.RecurrentTokenCallbackHandlerConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.ResultIntentResolverConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.ServerHandlerLogDecoratorConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.TemporaryContextServiceConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.ThreeDsAdapterServiceConfiguration.class,
|
||||||
|
dev.vality.adapter.bank.spring.boot.starter.configuration.TokenServerFlowHandlerConfiguration.class})
|
||||||
|
@PropertySource("classpath:application.yml")
|
||||||
|
public class StarterTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void build() {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.flow.lib.flow.simple.SimpleRedirectWIthPollingStepResolverImpl;
|
||||||
|
import org.springframework.boot.test.context.TestComponent;
|
||||||
|
|
||||||
|
@TestComponent
|
||||||
|
public class StepResolver extends SimpleRedirectWIthPollingStepResolverImpl {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package dev.vality.adapter.bank.spring.boot.starter.configuration;
|
||||||
|
|
||||||
|
import dev.vality.adapter.flow.lib.validator.AdapterConfigurationValidator;
|
||||||
|
import org.springframework.boot.test.context.TestComponent;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@TestComponent
|
||||||
|
public class Validator implements AdapterConfigurationValidator {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate(Map<String, String> map) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
package dev.vality.adapter.bank.spring.boot.starter.utils;
|
package dev.vality.adapter.bank.spring.boot.starter.utils;
|
||||||
|
|
||||||
import dev.vality.adapter.common.utils.converter.CardDataUtils;
|
import dev.vality.adapter.common.utils.CardDataUtils;
|
||||||
import dev.vality.cds.storage.AuthData;
|
import dev.vality.cds.storage.AuthData;
|
||||||
import dev.vality.cds.storage.CardSecurityCode;
|
import dev.vality.cds.storage.CardSecurityCode;
|
||||||
import dev.vality.cds.storage.SessionData;
|
import dev.vality.cds.storage.SessionData;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class SessionDataUtilsTest {
|
public class SessionDataUtilsTest {
|
||||||
|
|
||||||
@ -16,25 +16,25 @@ public class SessionDataUtilsTest {
|
|||||||
SessionData sessionData = new SessionData();
|
SessionData sessionData = new SessionData();
|
||||||
String cvv2 = CardDataUtils.extractCvv2(sessionData);
|
String cvv2 = CardDataUtils.extractCvv2(sessionData);
|
||||||
|
|
||||||
Assert.assertNull(cvv2);
|
Assertions.assertNull(cvv2);
|
||||||
|
|
||||||
AuthData authData = new AuthData();
|
AuthData authData = new AuthData();
|
||||||
sessionData.setAuthData(authData);
|
sessionData.setAuthData(authData);
|
||||||
cvv2 = CardDataUtils.extractCvv2(sessionData);
|
cvv2 = CardDataUtils.extractCvv2(sessionData);
|
||||||
|
|
||||||
Assert.assertNull(cvv2);
|
Assertions.assertNull(cvv2);
|
||||||
|
|
||||||
CardSecurityCode cardSecurityCode = new CardSecurityCode();
|
CardSecurityCode cardSecurityCode = new CardSecurityCode();
|
||||||
authData.setCardSecurityCode(cardSecurityCode);
|
authData.setCardSecurityCode(cardSecurityCode);
|
||||||
cvv2 = CardDataUtils.extractCvv2(sessionData);
|
cvv2 = CardDataUtils.extractCvv2(sessionData);
|
||||||
|
|
||||||
Assert.assertNull(cvv2);
|
Assertions.assertNull(cvv2);
|
||||||
|
|
||||||
cardSecurityCode.setValue(CARD_SECURITY_CODE);
|
cardSecurityCode.setValue(CARD_SECURITY_CODE);
|
||||||
|
|
||||||
cvv2 = CardDataUtils.extractCvv2(sessionData);
|
cvv2 = CardDataUtils.extractCvv2(sessionData);
|
||||||
|
|
||||||
Assert.assertEquals(CARD_SECURITY_CODE, cvv2);
|
Assertions.assertEquals(CARD_SECURITY_CODE, cvv2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package dev.vality.adapter.bank.spring.boot.starter.utils;
|
package dev.vality.adapter.bank.spring.boot.starter.utils;
|
||||||
|
|
||||||
import dev.vality.adapter.common.utils.encryption.HmacEncryption;
|
import dev.vality.adapter.common.utils.HmacEncryption;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
@ -15,6 +15,6 @@ public class SignGeneratorTest {
|
|||||||
"142003010515302116F2B2DD7E603A7ADA33https://www.sample.com/shop/reply";
|
"142003010515302116F2B2DD7E603A7ADA33https://www.sample.com/shop/reply";
|
||||||
|
|
||||||
String s = HmacEncryption.calculateHMacSha1(test, "00112233445566778899AABBCCDDEEFF");
|
String s = HmacEncryption.calculateHMacSha1(test, "00112233445566778899AABBCCDDEEFF");
|
||||||
Assert.assertEquals("FACC882CA67E109E409E3974DDEDA8AAB13A5E48", s.toUpperCase());
|
Assertions.assertEquals("FACC882CA67E109E409E3974DDEDA8AAB13A5E48", s.toUpperCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
59
src/test/resources/application.yml
Normal file
59
src/test/resources/application.yml
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
adapter:
|
||||||
|
url: http://127.0.0.1
|
||||||
|
callbackUrl: http://127.0.0.1:8080
|
||||||
|
pathCallbackUrl: /${server.rest.endpoint}/term_url
|
||||||
|
pathRecurrentCallbackUrl: /${server.rest.endpoint}/rec_term_url
|
||||||
|
defaultTermUrl: https://checkout.empayre.com/v1/finish-interaction.html
|
||||||
|
tagPrefix: adapter-
|
||||||
|
|
||||||
|
bender:
|
||||||
|
client:
|
||||||
|
url: http://127.0.0.1:8022/v1/bender
|
||||||
|
networkTimeout: 5000
|
||||||
|
namespace: namespace
|
||||||
|
|
||||||
|
cds:
|
||||||
|
client:
|
||||||
|
identity-document-storage:
|
||||||
|
url: http://127.0.0.1:8022/v1/identity_document_storage
|
||||||
|
networkTimeout: 5000
|
||||||
|
storage:
|
||||||
|
url: http://127.0.0.1:8022/v1/storage
|
||||||
|
networkTimeout: 5000
|
||||||
|
|
||||||
|
hellgate:
|
||||||
|
client:
|
||||||
|
url: http://127.0.0.1:8022/v1/proxyhost/provider
|
||||||
|
networkTimeout: 30000
|
||||||
|
|
||||||
|
time:
|
||||||
|
config:
|
||||||
|
maxTimePollingMin: 60
|
||||||
|
pollingDelayMs: 1000
|
||||||
|
redirectTimeoutMin: 15
|
||||||
|
exponential: 2
|
||||||
|
defaultInitialExponential: 2
|
||||||
|
maxTimeBackOff: 600
|
||||||
|
maxTimeCoefficient: 2
|
||||||
|
|
||||||
|
rest-template:
|
||||||
|
requestTimeout: 60000
|
||||||
|
poolTimeout: 10000
|
||||||
|
connectionTimeout: 10000
|
||||||
|
maxTotalPooling: 200
|
||||||
|
defaultMaxPerRoute: 200
|
||||||
|
networkTimeout: 60000
|
||||||
|
connectTimeout: 10000
|
||||||
|
|
||||||
|
error-mapping:
|
||||||
|
file: classpath:fixture/errors.json
|
||||||
|
patternReason: "'%s' - '%s'" # 'code' - 'description'
|
||||||
|
|
||||||
|
server:
|
||||||
|
rest:
|
||||||
|
port: '8083'
|
||||||
|
endpoint: 'endpoint'
|
||||||
|
|
||||||
|
spring:
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
1
src/test/resources/fixture/errors.json
Normal file
1
src/test/resources/fixture/errors.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
[]
|
Loading…
Reference in New Issue
Block a user