You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2020/03/16 08:49:18 UTC
[syncope] 05/08: [SYNCOPE-1545] move config to configuration class,
add support for restful registry with entity-mapping and add
support for config validation
This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch SYNCOPE-1545
in repository https://gitbox.apache.org/repos/asf/syncope.git
commit f58aa1440a43d1c58784d0b930c22d9988046174
Author: Misagh Moayyed <mm...@gmail.com>
AuthorDate: Mon Mar 9 16:37:19 2020 +0330
[SYNCOPE-1545] move config to configuration class, add support for restful registry with entity-mapping and add support for config validation
---
wa/pom.xml | 4 ++
.../apache/syncope/wa/SyncopeWAApplication.java | 24 ++++-------
.../syncope/wa/config/SyncopeWAConfiguration.java | 49 ++++++++++++++++++++++
wa/src/main/resources/META-INF/spring.factories | 17 ++++++++
4 files changed, 79 insertions(+), 15 deletions(-)
diff --git a/wa/pom.xml b/wa/pom.xml
index 13d69aa..09d2fa2 100644
--- a/wa/pom.xml
+++ b/wa/pom.xml
@@ -165,6 +165,10 @@ under the License.
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
+ <artifactId>cas-server-support-rest-service-registry</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apereo.cas</groupId>
<artifactId>cas-server-webapp-config</artifactId>
</dependency>
<dependency>
diff --git a/wa/src/main/java/org/apache/syncope/wa/SyncopeWAApplication.java b/wa/src/main/java/org/apache/syncope/wa/SyncopeWAApplication.java
index 16d985d..dac26bb 100644
--- a/wa/src/main/java/org/apache/syncope/wa/SyncopeWAApplication.java
+++ b/wa/src/main/java/org/apache/syncope/wa/SyncopeWAApplication.java
@@ -18,13 +18,12 @@
*/
package org.apache.syncope.wa;
-import org.apache.commons.lang.StringUtils;
-import org.apache.syncope.common.keymaster.client.api.model.NetworkService;
-import org.apache.syncope.common.keymaster.client.api.startstop.KeymasterStart;
-import org.apache.syncope.common.keymaster.client.api.startstop.KeymasterStop;
import org.apereo.cas.configuration.CasConfigurationProperties;
+import org.apereo.cas.configuration.CasConfigurationPropertiesValidator;
import org.apereo.cas.util.AsciiArtUtils;
import org.apereo.cas.util.DateTimeUtils;
+
+import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -44,7 +43,6 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
-import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.event.EventListener;
@@ -88,17 +86,13 @@ public class SyncopeWAApplication extends SpringBootServletInitializer {
*/
@EventListener
public void handleApplicationReadyEvent(final ApplicationReadyEvent event) {
+ if (!Boolean.getBoolean("SKIP_CONFIG_VALIDATION")) {
+ CasConfigurationPropertiesValidator validator =
+ new CasConfigurationPropertiesValidator(event.getApplicationContext());
+ validator.validate();
+ }
+
AsciiArtUtils.printAsciiArtReady(LOG, StringUtils.EMPTY);
LOG.info("Ready to process requests @ [{}]", DateTimeUtils.zonedDateTimeOf(event.getTimestamp()));
}
-
- @Bean
- public KeymasterStart keymasterStart() {
- return new KeymasterStart(NetworkService.Type.WA);
- }
-
- @Bean
- public KeymasterStop keymasterStop() {
- return new KeymasterStop(NetworkService.Type.WA);
- }
}
diff --git a/wa/src/main/java/org/apache/syncope/wa/config/SyncopeWAConfiguration.java b/wa/src/main/java/org/apache/syncope/wa/config/SyncopeWAConfiguration.java
new file mode 100644
index 0000000..2107f51
--- /dev/null
+++ b/wa/src/main/java/org/apache/syncope/wa/config/SyncopeWAConfiguration.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.syncope.wa.config;
+
+import org.apereo.cas.services.DefaultRegisteredServiceEntityMapper;
+import org.apereo.cas.services.RegisteredServiceEntityMapper;
+
+import org.apache.syncope.common.keymaster.client.api.model.NetworkService;
+import org.apache.syncope.common.keymaster.client.api.startstop.KeymasterStart;
+import org.apache.syncope.common.keymaster.client.api.startstop.KeymasterStop;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration(proxyBeanMethods = false)
+public class SyncopeWAConfiguration {
+ @Bean
+ @ConditionalOnProperty(name = "cas.serviceRegistry.rest.url")
+ public RegisteredServiceEntityMapper registeredServiceEntityMapper() {
+ return new DefaultRegisteredServiceEntityMapper();
+ }
+
+ @Bean
+ public KeymasterStart keymasterStart() {
+ return new KeymasterStart(NetworkService.Type.WA);
+ }
+
+ @Bean
+ public KeymasterStop keymasterStop() {
+ return new KeymasterStop(NetworkService.Type.WA);
+ }
+}
diff --git a/wa/src/main/resources/META-INF/spring.factories b/wa/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000..db54cd0
--- /dev/null
+++ b/wa/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=org.apache.syncope.wa.config.SyncopeWAConfiguration