-
Notifications
You must be signed in to change notification settings - Fork 34
/
UtilityBeans.java
83 lines (72 loc) · 2.57 KB
/
UtilityBeans.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package org.stellar.anchor.platform.component.share;
import com.google.gson.Gson;
import java.util.List;
import javax.validation.Validator;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.stellar.anchor.api.exception.NotSupportedException;
import org.stellar.anchor.auth.JwtService;
import org.stellar.anchor.config.*;
import org.stellar.anchor.healthcheck.HealthCheckable;
import org.stellar.anchor.horizon.Horizon;
import org.stellar.anchor.platform.config.*;
import org.stellar.anchor.platform.service.HealthCheckService;
import org.stellar.anchor.platform.service.SimpleMoreInfoUrlConstructor;
import org.stellar.anchor.platform.validator.RequestValidator;
import org.stellar.anchor.sep24.MoreInfoUrlConstructor;
import org.stellar.anchor.util.GsonUtils;
@Configuration
public class UtilityBeans {
@Bean
public Gson gson() {
return GsonUtils.builder().create();
}
@Bean
@DependsOn("configManager")
public HealthCheckService healthCheckService(List<HealthCheckable> checkables) {
return new HealthCheckService(checkables);
}
@Bean
@ConfigurationProperties(prefix = "")
AppConfig appConfig() {
return new PropertyAppConfig();
}
@Bean
MoreInfoUrlConstructor moreInfoUrlConstructor(
PropertyClientsConfig clientsConfig, PropertySep24Config sep24Config, JwtService jwtService) {
return new SimpleMoreInfoUrlConstructor(
clientsConfig, sep24Config.getMoreInfoUrl(), jwtService);
}
@Bean
@ConfigurationProperties(prefix = "sep24")
PropertySep24Config sep24Config(SecretConfig secretConfig, CustodyConfig custodyConfig) {
return new PropertySep24Config(secretConfig, custodyConfig);
}
@Bean
@ConfigurationProperties(prefix = "sep6")
PropertySep6Config sep6Config(CustodyConfig custodyConfig) {
return new PropertySep6Config(custodyConfig);
}
/**********************************
* Secret configurations
*/
@Bean
PropertySecretConfig secretConfig() {
return new PropertySecretConfig();
}
@Bean
public JwtService jwtService(SecretConfig secretConfig, CustodySecretConfig custodySecretConfig)
throws NotSupportedException {
return new JwtService(secretConfig, custodySecretConfig);
}
@Bean
public Horizon horizon(AppConfig appConfig) {
return new Horizon(appConfig);
}
@Bean
public RequestValidator requestValidator(Validator validator) {
return new RequestValidator(validator);
}
}