diff --git a/.gitignore b/.gitignore index a7e4258..aa4214b 100644 --- a/.gitignore +++ b/.gitignore @@ -22,24 +22,47 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* -replay_pid* -# ---> Maven +# ---> JetBrains +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/ target/ -pom.xml.tag -pom.xml.releaseBackup -pom.xml.versionsBackup -pom.xml.next -release.properties -dependency-reduced-pom.xml -buildNumber.properties -.mvn/timing.properties -# https://github.com/takari/maven-wrapper#usage-without-binary-jar -.mvn/wrapper/maven-wrapper.jar -# Eclipse m2e generated files -# Eclipse Core -.project -# JDT-specific (Eclipse Java Development Tools) -.classpath +# CMake +cmake-build-*/ +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +# Local Deployment scripts +make.sh diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..1e9758b --- /dev/null +++ b/pom.xml @@ -0,0 +1,69 @@ + + + 4.0.0 + + eu.dnetlib + uoa-spring-boot-parent + 1.0.0 + + client-management + 1.0-SNAPSHOT + war + client-management + + scm:git:gitea@code-repo.d4science.org:MaDgIK/client-management.git + HEAD + + + + eu.dnetlib + uoa-login-core + 2.0.0 + + + + io.springfox + springfox-swagger2 + ${swagger-version} + + + + io.springfox + springfox-swagger-ui + ${swagger-version} + + + + + + src/main/resources + true + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot-version} + + eu.dnetlib.clientmanagement.ClientManagementApplication + true + + + + + repackage + + + + + + maven-war-plugin + 2.6 + + false + + + + + diff --git a/src/main/java/eu/dnetlib/clientmanagement/ClientManagementApplication.java b/src/main/java/eu/dnetlib/clientmanagement/ClientManagementApplication.java new file mode 100644 index 0000000..bea5170 --- /dev/null +++ b/src/main/java/eu/dnetlib/clientmanagement/ClientManagementApplication.java @@ -0,0 +1,22 @@ +package eu.dnetlib.clientmanagement; + +import eu.dnetlib.authentication.configuration.AuthenticationConfiguration; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.annotation.PropertySources; + +@SpringBootApplication(scanBasePackages = {"eu.dnetlib.clientmanagement"}) +@PropertySources({ + @PropertySource("classpath:authentication.properties"), + @PropertySource(value = "classpath:dnet-override.properties", ignoreResourceNotFound = true) +}) +@Import({AuthenticationConfiguration.class}) +public class ClientManagementApplication { + + public static void main(String[] args) { + SpringApplication.run(ClientManagementApplication.class, args); + } + +} diff --git a/src/main/java/eu/dnetlib/clientmanagement/ServletInitializer.java b/src/main/java/eu/dnetlib/clientmanagement/ServletInitializer.java new file mode 100644 index 0000000..af42aa1 --- /dev/null +++ b/src/main/java/eu/dnetlib/clientmanagement/ServletInitializer.java @@ -0,0 +1,13 @@ +package eu.dnetlib.clientmanagement; + +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.support.SpringBootServletInitializer; + +public class ServletInitializer extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(ClientManagementApplication.class); + } + +} diff --git a/src/main/java/eu/dnetlib/clientmanagement/controllers/HealthController.java b/src/main/java/eu/dnetlib/clientmanagement/controllers/HealthController.java new file mode 100644 index 0000000..6db9b6f --- /dev/null +++ b/src/main/java/eu/dnetlib/clientmanagement/controllers/HealthController.java @@ -0,0 +1,36 @@ +package eu.dnetlib.clientmanagement.controllers; + +import eu.dnetlib.authentication.configuration.AuthenticationConfiguration; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +@RestController +public class HealthController { + private final Logger log = LogManager.getLogger(this.getClass()); + private final AuthenticationConfiguration configuration; + + @Autowired + public HealthController(AuthenticationConfiguration configuration) { + this.configuration = configuration; + } + + @RequestMapping(value = {"", "/health_check"}, method = RequestMethod.GET) + public String hello() { + log.debug("Hello from Client Management service!"); + return "Hello from Client Management service!"; + } + + @PreAuthorize("hasAnyAuthority('PORTAL_ADMINISTRATOR')") + @RequestMapping(value = "/health_check/advanced", method = RequestMethod.GET) + public Map checkEverything() { + Map response = configuration.getProperties(); + return response; + } +}