1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.client.enduser;
20
21 import com.giffing.wicket.spring.boot.starter.web.config.WicketWebInitializerAutoConfig.WebSocketWicketWebInitializerAutoConfiguration;
22 import java.util.List;
23 import java.util.Map;
24 import org.apache.syncope.client.enduser.init.ClassPathScanImplementationLookup;
25 import org.apache.syncope.client.ui.commons.actuate.SyncopeCoreHealthIndicator;
26 import org.apache.syncope.common.keymaster.client.api.ServiceOps;
27 import org.apache.syncope.common.keymaster.client.api.model.NetworkService;
28 import org.apache.syncope.common.keymaster.client.api.startstop.KeymasterStart;
29 import org.apache.syncope.common.keymaster.client.api.startstop.KeymasterStop;
30 import org.apache.wicket.request.resource.IResource;
31 import org.springframework.boot.autoconfigure.SpringBootApplication;
32 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
33 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
34 import org.springframework.boot.builder.SpringApplicationBuilder;
35 import org.springframework.boot.context.properties.EnableConfigurationProperties;
36 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
37 import org.springframework.context.annotation.Bean;
38 import org.springframework.core.io.ResourceLoader;
39
40 @SpringBootApplication(proxyBeanMethods = false)
41 @EnableConfigurationProperties(EnduserProperties.class)
42 public class SyncopeEnduserApplication extends SpringBootServletInitializer {
43
44 public static void main(final String[] args) {
45 new SpringApplicationBuilder(SyncopeEnduserApplication.class).
46 properties("spring.config.name:enduser").
47 build().run(args);
48 }
49
50 @Override
51 protected SpringApplicationBuilder configure(final SpringApplicationBuilder builder) {
52 return builder.properties(Map.of(
53 WebSocketWicketWebInitializerAutoConfiguration.REGISTER_SERVER_ENDPOINT_ENABLED, false,
54 "spring.config.name", "enduser")).
55 sources(SyncopeEnduserApplication.class);
56 }
57
58 @ConditionalOnMissingBean
59 @Bean
60 public SyncopeWebApplication syncopeWebApplication(
61 final ResourceLoader resourceLoader,
62 final EnduserProperties props,
63 final ClassPathScanImplementationLookup lookup,
64 final ServiceOps serviceOps,
65 final List<IResource> resources) {
66
67 return new SyncopeWebApplication(resourceLoader, props, lookup, serviceOps, resources);
68 }
69
70 @ConditionalOnMissingBean
71 @Bean
72 public SyncopeCoreHealthIndicator syncopeCoreHealthIndicator(
73 final ServiceOps serviceOps, final EnduserProperties props) {
74
75 return new SyncopeCoreHealthIndicator(
76 serviceOps,
77 props.getAnonymousUser(),
78 props.getAnonymousKey(),
79 props.isUseGZIPCompression());
80 }
81
82 @ConditionalOnProperty(
83 prefix = "keymaster", name = "enableAutoRegistration", havingValue = "true", matchIfMissing = true)
84 @Bean
85 public KeymasterStart keymasterStart() {
86 return new KeymasterStart(NetworkService.Type.ENDUSER);
87 }
88
89 @ConditionalOnProperty(
90 prefix = "keymaster", name = "enableAutoRegistration", havingValue = "true", matchIfMissing = true)
91 @Bean
92 public KeymasterStop keymasterStop() {
93 return new KeymasterStop(NetworkService.Type.ENDUSER);
94 }
95 }