From 524120e5b6836b7d307ca2b09fc54b7afadd0916 Mon Sep 17 00:00:00 2001 From: jiahuihu Date: Fri, 10 May 2024 03:44:14 +0800 Subject: [PATCH] remove clients config prefix --- .../main/java/org/stellar/anchor/sep31/Sep31Service.java | 2 +- .../anchor/platform/component/share/ClientsBeans.java | 2 +- .../anchor/platform/config/PropertyClientsConfig.java | 6 ++++-- .../stellar/anchor/platform/config/PropertySep10Config.java | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/stellar/anchor/sep31/Sep31Service.java b/core/src/main/java/org/stellar/anchor/sep31/Sep31Service.java index 9d8552e9f9..d24deeaf0e 100644 --- a/core/src/main/java/org/stellar/anchor/sep31/Sep31Service.java +++ b/core/src/main/java/org/stellar/anchor/sep31/Sep31Service.java @@ -592,7 +592,7 @@ String getClientName(String account) throws BadRequestException { throw new BadRequestException("Client not found"); } - if (client != null) { + if (client != null && client.getDomains() != null) { boolean hasDomainIntersection = new HashSet<>(sep10Config.getAllowedClientDomains()).containsAll(client.getDomains()); if (!hasDomainIntersection) { diff --git a/platform/src/main/java/org/stellar/anchor/platform/component/share/ClientsBeans.java b/platform/src/main/java/org/stellar/anchor/platform/component/share/ClientsBeans.java index 65cde42742..2aa783eb9d 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/component/share/ClientsBeans.java +++ b/platform/src/main/java/org/stellar/anchor/platform/component/share/ClientsBeans.java @@ -8,7 +8,7 @@ @Configuration public class ClientsBeans { @Bean - @ConfigurationProperties(prefix = "clients") + @ConfigurationProperties(prefix = "") PropertyClientsConfig clientsConfig() { return new PropertyClientsConfig(); } diff --git a/platform/src/main/java/org/stellar/anchor/platform/config/PropertyClientsConfig.java b/platform/src/main/java/org/stellar/anchor/platform/config/PropertyClientsConfig.java index 9c266aced9..c2773975c2 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/config/PropertyClientsConfig.java +++ b/platform/src/main/java/org/stellar/anchor/platform/config/PropertyClientsConfig.java @@ -104,7 +104,8 @@ private void validateClient(ClientConfig clientConfig, Errors errors) { } public void validateCustodialClient(ClientConfig clientConfig, Errors errors) { - if (clientConfig.getSigningKeys() == null || clientConfig.getSigningKeys().isEmpty()) { + if (isEmpty(clientConfig.getSigningKey()) + && (clientConfig.getSigningKeys() == null || clientConfig.getSigningKeys().isEmpty())) { errors.reject( "empty-client-signing-keys", "The client.signingKeys cannot be empty and must be defined"); @@ -119,7 +120,8 @@ public void validateCustodialClient(ClientConfig clientConfig, Errors errors) { } public void validateNonCustodialClient(ClientConfig clientConfig, Errors errors) { - if (clientConfig.getDomains() == null || clientConfig.getDomains().isEmpty()) { + if (isEmpty(clientConfig.getDomain()) + && (clientConfig.getDomains() == null || clientConfig.getDomains().isEmpty())) { errors.reject( "empty-client-domains", "The client.domains cannot be empty and must be defined"); } diff --git a/platform/src/main/java/org/stellar/anchor/platform/config/PropertySep10Config.java b/platform/src/main/java/org/stellar/anchor/platform/config/PropertySep10Config.java index f7e2429a1f..ec2807b37d 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/config/PropertySep10Config.java +++ b/platform/src/main/java/org/stellar/anchor/platform/config/PropertySep10Config.java @@ -169,8 +169,8 @@ void validateClientAttribution(Errors errors) { if (clientAttributionRequired) { List nonCustodialClientNames = clientsConfig.clients.stream() - .filter(cfg -> cfg.getType() == NONCUSTODIAL && !cfg.getDomains().isEmpty()) - .flatMap(cfg -> cfg.getDomains().stream()) + .filter(cfg -> cfg.getType() == NONCUSTODIAL) + .map(ClientConfig::getName) .collect(Collectors.toList()); if (nonCustodialClientNames.isEmpty()) {