This is an automated email from the ASF dual-hosted git repository. ilgrosso pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/syncope.git
commit cab76f2d3b07f3eee4f13c08e8bb1f06c5f42b2b Author: Francesco Chicchiriccò <ilgro...@apache.org> AuthorDate: Fri Mar 20 11:24:33 2020 +0100 [SYNCOPE-1545] Splitting wa into starter and bootstrap to allow for Spring Cloud Bootstap configuration (and reload) --- .../main/resources/archetype-resources/wa/pom.xml | 2 +- docker/wa/pom.xml | 6 +- .../wa/src/main/resources/application.properties | 8 +- fit/wa-reference/pom.xml | 4 +- pom.xml | 162 +++++++++- .../apache/syncope/sra/ZookeeperTestingServer.java | 9 +- wa/LICENSE | 202 ------------ wa/NOTICE | 5 - wa/bootstrap/pom.xml | 68 ++++ .../RestfulCloudConfigBootstrapConfiguration.java | 53 +++ .../src/main/resources/META-INF/spring.factories | 4 +- wa/pom.xml | 355 +-------------------- wa/{ => starter}/pom.xml | 92 ++---- .../syncope/wa/starter}/SyncopeWAApplication.java | 2 +- .../wa/starter}/SyncopeWAConfiguration.java | 4 +- .../src/main/resources/META-INF/spring.factories | 2 +- .../src/main/resources/application.properties | 2 + wa/{ => starter}/src/main/resources/log4j2.xml | 0 .../resources/thymeleaf}/static/images/favicon.png | Bin .../resources/thymeleaf}/static/images/logo.png | Bin .../thymeleaf}/templates/fragments/footer.html | 0 .../thymeleaf}/templates/fragments/header.html | 0 .../resources/thymeleaf}/templates/layout.html | 0 wa/{ => starter}/src/main/resources/wa.properties | 0 .../apache/syncope/wa/starter}/SyncopeWATest.java | 2 +- .../wa/starter}/ZookeeperTestingServer.java | 11 +- .../test/resources/application-debug.properties | 0 .../src/test/resources/keymaster.properties | 2 +- 28 files changed, 337 insertions(+), 658 deletions(-) diff --git a/archetype/src/main/resources/archetype-resources/wa/pom.xml b/archetype/src/main/resources/archetype-resources/wa/pom.xml index 91b4a22..79489fb 100644 --- a/archetype/src/main/resources/archetype-resources/wa/pom.xml +++ b/archetype/src/main/resources/archetype-resources/wa/pom.xml @@ -116,7 +116,7 @@ under the License. <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> - <mainClass>org.apache.syncope.wa.SyncopeWAApplication</mainClass> + <mainClass>org.apache.syncope.wa.starter.SyncopeWAApplication</mainClass> <layout>ZIP</layout> </configuration> <executions> diff --git a/docker/wa/pom.xml b/docker/wa/pom.xml index 13721b8..62b1cdd 100644 --- a/docker/wa/pom.xml +++ b/docker/wa/pom.xml @@ -49,8 +49,8 @@ under the License. </dependency> <dependency> - <groupId>org.apache.syncope</groupId> - <artifactId>syncope-wa</artifactId> + <groupId>org.apache.syncope.wa</groupId> + <artifactId>syncope-wa-starter</artifactId> <version>${project.version}</version> </dependency> @@ -92,7 +92,7 @@ under the License. <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> - <mainClass>org.apache.syncope.wa.SyncopeWAApplication</mainClass> + <mainClass>org.apache.syncope.wa.starter.SyncopeWAApplication</mainClass> <layout>ZIP</layout> </configuration> <executions> diff --git a/docker/wa/src/main/resources/application.properties b/docker/wa/src/main/resources/application.properties index 254b399..763602f 100644 --- a/docker/wa/src/main/resources/application.properties +++ b/docker/wa/src/main/resources/application.properties @@ -26,6 +26,9 @@ spring.http.encoding.force=true server.servlet.contextPath=/syncope-wa +spring.resources.static-locations=classpath:/syncope/static,classpath:/static +spring.thymeleaf.templateResolverOrder=1 + ## # Allow configuration classes to override bean definitions from Spring Boot # @@ -33,8 +36,3 @@ spring.main.allow-bean-definition-overriding=true spring.main.lazy-initialization=false service.discovery.address=${SERVICE_DISCOVERY_ADDRESS} - -# Conf directories -conf.directory=${conf.directory} -cas.standalone.configurationDirectory=${conf.directory} -cas.authn.oidc.jwksFile=file:${conf.directory}/oidc.keystore diff --git a/fit/wa-reference/pom.xml b/fit/wa-reference/pom.xml index e097196..c0adcd2 100644 --- a/fit/wa-reference/pom.xml +++ b/fit/wa-reference/pom.xml @@ -46,8 +46,8 @@ under the License. <dependencies> <dependency> - <groupId>org.apache.syncope</groupId> - <artifactId>syncope-wa</artifactId> + <groupId>org.apache.syncope.wa</groupId> + <artifactId>syncope-wa-starter</artifactId> <version>${project.version}</version> </dependency> diff --git a/pom.xml b/pom.xml index 73a80cd..44fd5e8 100644 --- a/pom.xml +++ b/pom.xml @@ -411,7 +411,7 @@ under the License. <spring.version>5.2.4.RELEASE</spring.version> <spring-security.version>5.3.0.RELEASE</spring-security.version> <spring-boot.version>2.2.5.RELEASE</spring-boot.version> - <spring-cloud-gateway.version>2.2.1.RELEASE</spring-cloud-gateway.version> + <spring-cloud-gateway.version>2.2.2.RELEASE</spring-cloud-gateway.version> <openjpa.version>3.1.1</openjpa.version> <hikaricp.version>3.4.2</hikaricp.version> @@ -423,7 +423,7 @@ under the License. <cocoon.version>3.0.0-alpha-3</cocoon.version> - <groovy.version>3.0.1</groovy.version> + <groovy.version>3.0.2</groovy.version> <flowable.version>6.5.0</flowable.version> @@ -1438,6 +1438,164 @@ under the License. </dependency> <!-- /Flowable --> + <!-- CAS --> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-core</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-core-audit</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-core-authentication</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-core-configuration-api</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-core-configuration</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-core-cookie</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-core-logout</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-core-logging</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-core-services</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-core-tickets</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-core-util</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-core-validation</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-core-web</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-core-webflow</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-core-events-configuration</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-support-thymeleaf</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-support-actions</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-support-ldap</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-support-reports</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-support-syncope-authentication</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-support-saml</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-support-person-directory</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-support-themes</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-support-oidc</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-support-validation</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-support-pm-webflow</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-support-pac4j-webflow</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-support-consent-webflow</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-support-aup-webflow</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-support-rest-service-registry</artifactId> + <version>${cas.version}</version> + </dependency> + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-webapp-config</artifactId> + <version>${cas.version}</version> + </dependency> + <!-- /CAS --> + <!-- Wicket --> <dependency> <groupId>org.apache.wicket</groupId> diff --git a/sra/src/test/java/org/apache/syncope/sra/ZookeeperTestingServer.java b/sra/src/test/java/org/apache/syncope/sra/ZookeeperTestingServer.java index 89fc3bc..930d724 100644 --- a/sra/src/test/java/org/apache/syncope/sra/ZookeeperTestingServer.java +++ b/sra/src/test/java/org/apache/syncope/sra/ZookeeperTestingServer.java @@ -27,6 +27,7 @@ import java.util.Properties; import java.util.concurrent.atomic.AtomicReference; import javax.security.auth.login.AppConfigurationEntry; import javax.security.auth.login.Configuration; +import org.apache.commons.lang3.StringUtils; import org.apache.curator.test.InstanceSpec; import org.apache.curator.test.TestingServer; import org.apache.zookeeper.server.auth.DigestLoginModule; @@ -38,12 +39,14 @@ public class ZookeeperTestingServer implements ApplicationContextInitializer<Con @Override public void initialize(final ConfigurableApplicationContext ctx) { + AtomicReference<Integer> port = new AtomicReference<>(); AtomicReference<String> username = new AtomicReference<>(); AtomicReference<String> password = new AtomicReference<>(); try (InputStream propStream = getClass().getResourceAsStream("/keymaster.properties")) { Properties props = new Properties(); props.load(propStream); + port.set(Integer.valueOf(StringUtils.substringAfter(props.getProperty("keymaster.address"), ":"))); username.set(props.getProperty("keymaster.username")); password.set(props.getProperty("keymaster.password")); } catch (Exception e) { @@ -56,9 +59,7 @@ public class ZookeeperTestingServer implements ApplicationContextInitializer<Con new AppConfigurationEntry( DigestLoginModule.class.getName(), AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, - Map.of( - "user_" + username.get(), password.get() - )) + Map.of("user_" + username.get(), password.get())) }; @Override @@ -69,7 +70,7 @@ public class ZookeeperTestingServer implements ApplicationContextInitializer<Con Map<String, Object> customProperties = new HashMap<>(); customProperties.put("authProvider.1", SASLAuthenticationProvider.class.getName()); - InstanceSpec spec = new InstanceSpec(null, 2181, -1, -1, true, 1, -1, -1, customProperties); + InstanceSpec spec = new InstanceSpec(null, port.get(), -1, -1, true, 1, -1, -1, customProperties); try { new TestingServer(spec, true); diff --git a/wa/LICENSE b/wa/LICENSE deleted file mode 100644 index d645695..0000000 --- a/wa/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. diff --git a/wa/NOTICE b/wa/NOTICE deleted file mode 100644 index 3db7985..0000000 --- a/wa/NOTICE +++ /dev/null @@ -1,5 +0,0 @@ -Apache Syncope -Copyright 2012-2019 The Apache Software Foundation - -This product includes software developed by: -The Apache Software Foundation (http://www.apache.org/). diff --git a/wa/bootstrap/pom.xml b/wa/bootstrap/pom.xml new file mode 100644 index 0000000..72b7482 --- /dev/null +++ b/wa/bootstrap/pom.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.syncope</groupId> + <artifactId>syncope-wa</artifactId> + <version>3.0.0-SNAPSHOT</version> + </parent> + + <name>Apache Syncope WA Bootstrap</name> + <description>Apache Syncope WA Bootstrap</description> + <groupId>org.apache.syncope.wa</groupId> + <artifactId>syncope-wa-bootstrap</artifactId> + <packaging>jar</packaging> + + <properties> + <rootpom.basedir>${basedir}/../..</rootpom.basedir> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.syncope.client.am</groupId> + <artifactId>syncope-client-am-lib</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apereo.cas</groupId> + <artifactId>cas-server-core-configuration-api</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + </plugin> + </plugins> + + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + </resource> + </resources> + </build> +</project> diff --git a/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/RestfulCloudConfigBootstrapConfiguration.java b/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/RestfulCloudConfigBootstrapConfiguration.java new file mode 100644 index 0000000..262931f --- /dev/null +++ b/wa/bootstrap/src/main/java/org/apache/syncope/wa/bootstrap/RestfulCloudConfigBootstrapConfiguration.java @@ -0,0 +1,53 @@ +/* + * 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.bootstrap; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.net.URI; +import java.util.Map; +import javax.ws.rs.core.MediaType; +import org.apache.cxf.jaxrs.client.WebClient; +import org.springframework.cloud.bootstrap.config.PropertySourceLocator; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; +import org.springframework.core.env.MapPropertySource; +import org.springframework.core.env.PropertySource; + +@Configuration(value = "restfulCloudConfigBootstrapConfiguration", proxyBeanMethods = false) +public class RestfulCloudConfigBootstrapConfiguration implements PropertySourceLocator { + + private static final ObjectMapper MAPPER = new ObjectMapper().findAndRegisterModules(); + + @Override + public PropertySource<?> locate(final Environment environment) { + try { + String content = WebClient.create(URI.create("https://demo5926981.mockable.io/casproperties")). + accept(MediaType.APPLICATION_JSON_TYPE). + get(). + readEntity(String.class); + + Map<String, Object> payload = MAPPER.readValue(content, new TypeReference<Map<String, Object>>() { + }); + return new MapPropertySource(getClass().getName(), payload); + } catch (Exception e) { + throw new IllegalArgumentException("Unable to fetch settings", e); + } + } +} diff --git a/wa/src/main/resources/META-INF/spring.factories b/wa/bootstrap/src/main/resources/META-INF/spring.factories similarity index 85% copy from wa/src/main/resources/META-INF/spring.factories copy to wa/bootstrap/src/main/resources/META-INF/spring.factories index db54cd0..4cd20b8 100644 --- a/wa/src/main/resources/META-INF/spring.factories +++ b/wa/bootstrap/src/main/resources/META-INF/spring.factories @@ -14,4 +14,6 @@ # 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 + +org.springframework.cloud.bootstrap.BootstrapConfiguration=\ + org.apache.syncope.wa.bootstrap.RestfulCloudConfigBootstrapConfiguration diff --git a/wa/pom.xml b/wa/pom.xml index 8cb9d18..eaaf61e 100644 --- a/wa/pom.xml +++ b/wa/pom.xml @@ -30,7 +30,7 @@ under the License. <name>Apache Syncope WA</name> <description>Apache Syncope WA</description> <artifactId>syncope-wa</artifactId> - <packaging>jar</packaging> + <packaging>pom</packaging> <properties> <guava.version>28.2-jre</guava.version> @@ -41,356 +41,8 @@ under the License. <rootpom.basedir>${basedir}/..</rootpom.basedir> </properties> - <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-bom</artifactId> - <version>${cas.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - - <dependencies> - <dependency> - <groupId>org.apache.syncope.common.keymaster</groupId> - <artifactId>syncope-common-keymaster-client-api</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.syncope.client.am</groupId> - <artifactId>syncope-client-am-lib</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>org.glassfish</groupId> - <artifactId>javax.el</artifactId> - </dependency> - - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-core</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-core-audit</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-core-authentication</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-core-configuration</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-core-cookie</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-core-logout</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-core-logging</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-core-services</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-core-tickets</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-core-util</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-core-validation</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-core-web</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-core-webflow</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-core-events-configuration</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-thymeleaf</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-actions</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-ldap</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-reports</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-syncope-authentication</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-saml</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-person-directory</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-themes</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-oidc</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-validation</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-pm-webflow</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-pac4j-webflow</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-consent-webflow</artifactId> - </dependency> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-aup-webflow</artifactId> - </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> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-web</artifactId> - <exclusions> - <exclusion> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-actuator</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-security</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.syncope.common.keymaster</groupId> - <artifactId>syncope-common-keymaster-client-zookeeper</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.curator</groupId> - <artifactId>curator-test</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-tomcat</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-test</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-checkstyle-plugin</artifactId> - </plugin> - </plugins> - - <resources> - <resource> - <directory>src/main/resources</directory> - <filtering>true</filtering> - </resource> - - <resource> - <directory>${basedir}/../src/main/resources</directory> - <filtering>true</filtering> - <includes> - <include>banner.txt</include> - </includes> - </resource> - </resources> - - <testResources> - <testResource> - <directory>${basedir}/src/test/resources</directory> - <filtering>true</filtering> - </testResource> - </testResources> - </build> - <profiles> <profile> - <id>debug</id> - - <properties> - <skipTests>true</skipTests> - </properties> - - <dependencies> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-undertow</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.syncope.common.keymaster</groupId> - <artifactId>syncope-common-keymaster-client-zookeeper</artifactId> - <version>${project.version}</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.apache.curator</groupId> - <artifactId>curator-test</artifactId> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-devtools</artifactId> - </dependency> - </dependencies> - - <build> - <defaultGoal>clean package io.fabric8:docker-maven-plugin:start spring-boot:run</defaultGoal> - - <plugins> - <plugin> - <groupId>io.fabric8</groupId> - <artifactId>docker-maven-plugin</artifactId> - <configuration> - <images> - <image> - <name>zookeeper:${zookeeper.version}</name> - <run> - <ports> - <port>2181:2181</port> - </ports> - <volumes> - <bind> - <volume>${project.build.testOutputDirectory}/zoo.cfg:/conf/zoo.cfg</volume> - <volume>${project.build.testOutputDirectory}/java.env:/conf/java.env</volume> - <volume>${project.build.testOutputDirectory}/server-jaas.conf:/conf/server-jaas.conf</volume> - <volume>${project.build.testOutputDirectory}/client-jaas.conf:/conf/client-jaas.conf</volume> - </bind> - </volumes> - </run> - </image> - </images> - </configuration> - </plugin> - - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>add-source</goal> - </goals> - <configuration> - <sources> - <source>${basedir}/src/test/java</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <excludes> - <exclude>**/org/apache/syncope/wa/**Test.java</exclude> - <exclude>**/org/apache/syncope/wa/**Zookeeper*.java</exclude> - </excludes> - </configuration> - </plugin> - - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <configuration> - <mainClass>org.apache.syncope.wa.SyncopeWAApplication</mainClass> - <jvmArguments> - -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n - </jvmArguments> - <profiles> - <profile>debug</profile> - </profiles> - </configuration> - </plugin> - </plugins> - - <resources> - <resource> - <directory>${basedir}/src/test/resources</directory> - <filtering>true</filtering> - </resource> - </resources> - - <testResources> - <testResource> - <directory>${basedir}/../common/keymaster/client-zookeeper/src/main/resources</directory> - <filtering>true</filtering> - </testResource> - </testResources> - </build> - </profile> - - <profile> <id>site</id> <build> @@ -434,4 +86,9 @@ under the License. <url>https://build.shibboleth.net/nexus/content/groups/public</url> </repository> </repositories> + + <modules> + <module>bootstrap</module> + <module>starter</module> + </modules> </project> diff --git a/wa/pom.xml b/wa/starter/pom.xml similarity index 83% copy from wa/pom.xml copy to wa/starter/pom.xml index 8cb9d18..51bd951 100644 --- a/wa/pom.xml +++ b/wa/starter/pom.xml @@ -23,38 +23,28 @@ under the License. <parent> <groupId>org.apache.syncope</groupId> - <artifactId>syncope</artifactId> + <artifactId>syncope-wa</artifactId> <version>3.0.0-SNAPSHOT</version> </parent> - <name>Apache Syncope WA</name> - <description>Apache Syncope WA</description> - <artifactId>syncope-wa</artifactId> + <name>Apache Syncope WA Spring Boot Starter</name> + <description>Apache Syncope WA Spring Boot Starter</description> + <groupId>org.apache.syncope.wa</groupId> + <artifactId>syncope-wa-starter</artifactId> <packaging>jar</packaging> <properties> - <guava.version>28.2-jre</guava.version> - <opensaml.version>3.4.5</opensaml.version> - <bootstrap.version>4.4.1</bootstrap.version> - <slf4j.version>2.0.0-alpha1</slf4j.version> - - <rootpom.basedir>${basedir}/..</rootpom.basedir> + <rootpom.basedir>${basedir}/../..</rootpom.basedir> </properties> - <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.apereo.cas</groupId> - <artifactId>cas-server-support-bom</artifactId> - <version>${cas.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - <dependencies> <dependency> + <groupId>org.apache.syncope.wa</groupId> + <artifactId>syncope-wa-bootstrap</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> <groupId>org.apache.syncope.common.keymaster</groupId> <artifactId>syncope-common-keymaster-client-api</artifactId> <version>${project.version}</version> @@ -252,9 +242,9 @@ under the License. <directory>src/main/resources</directory> <filtering>true</filtering> </resource> - + <resource> - <directory>${basedir}/../src/main/resources</directory> + <directory>${basedir}/../../src/main/resources</directory> <filtering>true</filtering> <includes> <include>banner.txt</include> @@ -269,7 +259,7 @@ under the License. </testResource> </testResources> </build> - + <profiles> <profile> <id>debug</id> @@ -353,8 +343,8 @@ under the License. <artifactId>maven-compiler-plugin</artifactId> <configuration> <excludes> - <exclude>**/org/apache/syncope/wa/**Test.java</exclude> - <exclude>**/org/apache/syncope/wa/**Zookeeper*.java</exclude> + <exclude>**/org/apache/syncope/wa/starter/**Test.java</exclude> + <exclude>**/org/apache/syncope/wa/starter/**Zookeeper*.java</exclude> </excludes> </configuration> </plugin> @@ -363,7 +353,7 @@ under the License. <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> - <mainClass>org.apache.syncope.wa.SyncopeWAApplication</mainClass> + <mainClass>org.apache.syncope.wa.starter.SyncopeWAApplication</mainClass> <jvmArguments> -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n </jvmArguments> @@ -383,55 +373,11 @@ under the License. <testResources> <testResource> - <directory>${basedir}/../common/keymaster/client-zookeeper/src/main/resources</directory> + <directory>${basedir}/../../common/keymaster/client-zookeeper/src/main/resources</directory> <filtering>true</filtering> </testResource> </testResources> </build> </profile> - - <profile> - <id>site</id> - - <build> - <plugins> - <plugin> - <groupId>org.asciidoctor</groupId> - <artifactId>asciidoctor-maven-plugin</artifactId> - <inherited>false</inherited> - <configuration> - <skip>true</skip> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-site-plugin</artifactId> - <inherited>true</inherited> - <configuration> - <skip>true</skip> - <skipDeploy>true</skipDeploy> - <generateReports>false</generateReports> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-antrun-plugin</artifactId> - <executions> - <execution> - <id>copy-docs-to-site</id> - <phase>none</phase> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> </profiles> - - <repositories> - <repository> - <id>shibboleth</id> - <url>https://build.shibboleth.net/nexus/content/groups/public</url> - </repository> - </repositories> </project> diff --git a/wa/src/main/java/org/apache/syncope/wa/SyncopeWAApplication.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/SyncopeWAApplication.java similarity index 99% rename from wa/src/main/java/org/apache/syncope/wa/SyncopeWAApplication.java rename to wa/starter/src/main/java/org/apache/syncope/wa/starter/SyncopeWAApplication.java index dac26bb..4d5d43a 100644 --- a/wa/src/main/java/org/apache/syncope/wa/SyncopeWAApplication.java +++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/SyncopeWAApplication.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.syncope.wa; +package org.apache.syncope.wa.starter; import org.apereo.cas.configuration.CasConfigurationProperties; import org.apereo.cas.configuration.CasConfigurationPropertiesValidator; diff --git a/wa/src/main/java/org/apache/syncope/wa/config/SyncopeWAConfiguration.java b/wa/starter/src/main/java/org/apache/syncope/wa/starter/SyncopeWAConfiguration.java similarity index 98% rename from wa/src/main/java/org/apache/syncope/wa/config/SyncopeWAConfiguration.java rename to wa/starter/src/main/java/org/apache/syncope/wa/starter/SyncopeWAConfiguration.java index 701cb53..16375c3 100644 --- a/wa/src/main/java/org/apache/syncope/wa/config/SyncopeWAConfiguration.java +++ b/wa/starter/src/main/java/org/apache/syncope/wa/starter/SyncopeWAConfiguration.java @@ -16,15 +16,15 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.syncope.wa.config; +package org.apache.syncope.wa.starter; import java.io.Serializable; import org.apereo.cas.services.DefaultRegisteredServiceEntityMapper; +import org.apereo.cas.services.RegisteredService; 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.apereo.cas.services.RegisteredService; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/wa/src/main/resources/META-INF/spring.factories b/wa/starter/src/main/resources/META-INF/spring.factories similarity index 94% rename from wa/src/main/resources/META-INF/spring.factories rename to wa/starter/src/main/resources/META-INF/spring.factories index db54cd0..6dc6c03 100644 --- a/wa/src/main/resources/META-INF/spring.factories +++ b/wa/starter/src/main/resources/META-INF/spring.factories @@ -14,4 +14,4 @@ # 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 +org.springframework.boot.autoconfigure.EnableAutoConfiguration=org.apache.syncope.wa.starter.SyncopeWAConfiguration diff --git a/wa/src/main/resources/application.properties b/wa/starter/src/main/resources/application.properties similarity index 94% rename from wa/src/main/resources/application.properties rename to wa/starter/src/main/resources/application.properties index 53ae4b0..5ad1d51 100644 --- a/wa/src/main/resources/application.properties +++ b/wa/starter/src/main/resources/application.properties @@ -26,6 +26,8 @@ spring.http.encoding.force=true server.servlet.contextPath=/syncope-wa +spring.resources.static-locations=classpath:/thymeleaf/static,classpath:/static + management.endpoints.web.exposure.include=health,loggers management.endpoint.health.show-details=always diff --git a/wa/src/main/resources/log4j2.xml b/wa/starter/src/main/resources/log4j2.xml similarity index 100% rename from wa/src/main/resources/log4j2.xml rename to wa/starter/src/main/resources/log4j2.xml diff --git a/wa/src/main/resources/static/images/favicon.png b/wa/starter/src/main/resources/thymeleaf/static/images/favicon.png similarity index 100% rename from wa/src/main/resources/static/images/favicon.png rename to wa/starter/src/main/resources/thymeleaf/static/images/favicon.png diff --git a/wa/src/main/resources/static/images/logo.png b/wa/starter/src/main/resources/thymeleaf/static/images/logo.png similarity index 100% rename from wa/src/main/resources/static/images/logo.png rename to wa/starter/src/main/resources/thymeleaf/static/images/logo.png diff --git a/wa/src/main/resources/templates/fragments/footer.html b/wa/starter/src/main/resources/thymeleaf/templates/fragments/footer.html similarity index 100% rename from wa/src/main/resources/templates/fragments/footer.html rename to wa/starter/src/main/resources/thymeleaf/templates/fragments/footer.html diff --git a/wa/src/main/resources/templates/fragments/header.html b/wa/starter/src/main/resources/thymeleaf/templates/fragments/header.html similarity index 100% rename from wa/src/main/resources/templates/fragments/header.html rename to wa/starter/src/main/resources/thymeleaf/templates/fragments/header.html diff --git a/wa/src/main/resources/templates/layout.html b/wa/starter/src/main/resources/thymeleaf/templates/layout.html similarity index 100% rename from wa/src/main/resources/templates/layout.html rename to wa/starter/src/main/resources/thymeleaf/templates/layout.html diff --git a/wa/src/main/resources/wa.properties b/wa/starter/src/main/resources/wa.properties similarity index 100% rename from wa/src/main/resources/wa.properties rename to wa/starter/src/main/resources/wa.properties diff --git a/wa/src/test/java/org/apache/syncope/wa/SyncopeWATest.java b/wa/starter/src/test/java/org/apache/syncope/wa/starter/SyncopeWATest.java similarity index 99% rename from wa/src/test/java/org/apache/syncope/wa/SyncopeWATest.java rename to wa/starter/src/test/java/org/apache/syncope/wa/starter/SyncopeWATest.java index d504cc8..93799d4 100644 --- a/wa/src/test/java/org/apache/syncope/wa/SyncopeWATest.java +++ b/wa/starter/src/test/java/org/apache/syncope/wa/starter/SyncopeWATest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.syncope.wa; +package org.apache.syncope.wa.starter; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; diff --git a/wa/src/test/java/org/apache/syncope/wa/ZookeeperTestingServer.java b/wa/starter/src/test/java/org/apache/syncope/wa/starter/ZookeeperTestingServer.java similarity index 87% rename from wa/src/test/java/org/apache/syncope/wa/ZookeeperTestingServer.java rename to wa/starter/src/test/java/org/apache/syncope/wa/starter/ZookeeperTestingServer.java index 956e6f3..c5b1ec9 100644 --- a/wa/src/test/java/org/apache/syncope/wa/ZookeeperTestingServer.java +++ b/wa/starter/src/test/java/org/apache/syncope/wa/starter/ZookeeperTestingServer.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.syncope.wa; +package org.apache.syncope.wa.starter; import static org.junit.jupiter.api.Assertions.fail; @@ -27,6 +27,7 @@ import java.util.Properties; import java.util.concurrent.atomic.AtomicReference; import javax.security.auth.login.AppConfigurationEntry; import javax.security.auth.login.Configuration; +import org.apache.commons.lang3.StringUtils; import org.apache.curator.test.InstanceSpec; import org.apache.curator.test.TestingServer; import org.apache.zookeeper.server.auth.DigestLoginModule; @@ -38,12 +39,14 @@ public class ZookeeperTestingServer implements ApplicationContextInitializer<Con @Override public void initialize(final ConfigurableApplicationContext ctx) { + AtomicReference<Integer> port = new AtomicReference<>(); AtomicReference<String> username = new AtomicReference<>(); AtomicReference<String> password = new AtomicReference<>(); try (InputStream propStream = getClass().getResourceAsStream("/keymaster.properties")) { Properties props = new Properties(); props.load(propStream); + port.set(Integer.valueOf(StringUtils.substringAfter(props.getProperty("keymaster.address"), ":"))); username.set(props.getProperty("keymaster.username")); password.set(props.getProperty("keymaster.password")); } catch (Exception e) { @@ -56,9 +59,7 @@ public class ZookeeperTestingServer implements ApplicationContextInitializer<Con new AppConfigurationEntry( DigestLoginModule.class.getName(), AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, - Map.of( - "user_" + username.get(), password.get() - )) + Map.of("user_" + username.get(), password.get())) }; @Override @@ -69,7 +70,7 @@ public class ZookeeperTestingServer implements ApplicationContextInitializer<Con Map<String, Object> customProperties = new HashMap<>(); customProperties.put("authProvider.1", SASLAuthenticationProvider.class.getName()); - InstanceSpec spec = new InstanceSpec(null, 2181, -1, -1, true, 1, -1, -1, customProperties); + InstanceSpec spec = new InstanceSpec(null, port.get(), -1, -1, true, 1, -1, -1, customProperties); try { new TestingServer(spec, true); diff --git a/wa/src/test/resources/application-debug.properties b/wa/starter/src/test/resources/application-debug.properties similarity index 100% rename from wa/src/test/resources/application-debug.properties rename to wa/starter/src/test/resources/application-debug.properties diff --git a/wa/src/test/resources/keymaster.properties b/wa/starter/src/test/resources/keymaster.properties similarity index 96% rename from wa/src/test/resources/keymaster.properties rename to wa/starter/src/test/resources/keymaster.properties index f374d8c..8d216e7 100644 --- a/wa/src/test/resources/keymaster.properties +++ b/wa/starter/src/test/resources/keymaster.properties @@ -14,6 +14,6 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -keymaster.address=127.0.0.1:2181 +keymaster.address=127.0.0.1:3181 keymaster.username=${anonymousUser} keymaster.password=${anonymousKey}