Skip to content

Commit e4fbf0c

Browse files
authored
Merge pull request #100 from reactive-commons/feature/eda-secret
Fill with secret
2 parents df72e4b + c0ca557 commit e4fbf0c

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

async/async-rabbit-starter-eda/src/main/java/org/reactivecommons/async/rabbit/config/RabbitMqConfig.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,11 @@ public HandlerRegistry defaultHandlerRegistry() {
225225
return HandlerRegistry.register();
226226
}
227227

228+
@Bean
229+
@ConditionalOnMissingBean(AsyncPropsDomain.SecretFiller.class)
230+
public AsyncPropsDomain.SecretFiller defaultSecretFiller() {
231+
return ignored -> {
232+
};
233+
}
234+
228235
}

async/async-rabbit-starter-eda/src/main/java/org/reactivecommons/async/rabbit/config/props/AsyncProps.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
@Builder
1818
public class AsyncProps {
1919
private String appName;
20+
private String secret;
2021

2122
@NestedConfigurationProperty
2223
@Builder.Default

async/async-rabbit-starter-eda/src/main/java/org/reactivecommons/async/rabbit/config/props/AsyncPropsDomain.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.reactivecommons.async.rabbit.config.RabbitProperties;
66
import org.reactivecommons.async.rabbit.config.exceptions.InvalidConfigurationException;
77
import org.springframework.beans.factory.annotation.Value;
8+
import org.springframework.util.StringUtils;
89

910
import java.util.HashMap;
1011

@@ -15,7 +16,8 @@
1516
public class AsyncPropsDomain extends HashMap<String, AsyncProps> {
1617
public AsyncPropsDomain(@Value("${spring.application.name}") String defaultAppName,
1718
RabbitProperties defaultRabbitProperties,
18-
AsyncPropsDomainProperties configured) {
19+
AsyncPropsDomainProperties configured,
20+
SecretFiller secretFiller) {
1921
super(configured);
2022
this.computeIfAbsent(DEFAULT_DOMAIN, k -> new AsyncProps());
2123
super.forEach((key, value) -> { // To ensure that each domain has an appName
@@ -38,6 +40,9 @@ public AsyncPropsDomain(@Value("${spring.application.name}") String defaultAppNa
3840
if (value.getBrokerConfigProps() == null) {
3941
value.setBrokerConfigProps(new BrokerConfigProps(value));
4042
}
43+
if (StringUtils.hasText(value.getSecret()) && secretFiller != null) {
44+
secretFiller.fillWithSecret(value);
45+
}
4146
});
4247
}
4348

@@ -56,6 +61,7 @@ public static AsyncPropsDomainBuilder builder() {
5661
public static class AsyncPropsDomainBuilder {
5762
private String defaultAppName;
5863
private RabbitProperties defaultRabbitProperties;
64+
private SecretFiller secretFiller;
5965
private final HashMap<String, AsyncProps> domains = new HashMap<>();
6066

6167

@@ -70,6 +76,12 @@ public AsyncPropsDomainBuilder withDefaultAppName(String defaultAppName) {
7076
return this;
7177
}
7278

79+
80+
public AsyncPropsDomainBuilder withSecretFiller(SecretFiller secretFiller) {
81+
this.secretFiller = secretFiller;
82+
return this;
83+
}
84+
7385
public AsyncPropsDomainBuilder withDomain(String domain, AsyncProps props) {
7486
domains.put(domain, props);
7587
return this;
@@ -80,9 +92,13 @@ public AsyncPropsDomain build() {
8092
if (defaultRabbitProperties == null) {
8193
defaultRabbitProperties = new RabbitProperties();
8294
}
83-
return new AsyncPropsDomain(defaultAppName, defaultRabbitProperties, domainProperties);
95+
return new AsyncPropsDomain(defaultAppName, defaultRabbitProperties, domainProperties, secretFiller);
8496
}
8597

8698
}
8799

100+
public interface SecretFiller {
101+
void fillWithSecret(AsyncProps props);
102+
}
103+
88104
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=2.2.1
1+
version=2.2.2
22
springBootVersion=3.2.5
33
reactorRabbitVersion=1.5.5
44
cloudEventsVersion=3.0.0

0 commit comments

Comments
 (0)