diff --git a/pom.xml b/pom.xml
index 062268e..975ede6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,6 +52,10 @@
org.springframework.boot
spring-boot-maven-plugin
+
+ pl.project13.maven
+ git-commit-id-plugin
+
diff --git a/src/main/java/rs/in/zivanovic/share/a/secret/api/controllers/SasController.java b/src/main/java/rs/in/zivanovic/share/a/secret/api/controllers/SasController.java
index 1481fc6..74b474e 100644
--- a/src/main/java/rs/in/zivanovic/share/a/secret/api/controllers/SasController.java
+++ b/src/main/java/rs/in/zivanovic/share/a/secret/api/controllers/SasController.java
@@ -24,7 +24,10 @@
package rs.in.zivanovic.share.a.secret.api.controllers;
import java.util.List;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
import javax.validation.Valid;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
@@ -36,6 +39,7 @@ import rs.in.zivanovic.share.a.secret.api.SecretShare;
import rs.in.zivanovic.share.a.secret.api.ShamirSecretSharing;
import rs.in.zivanovic.share.a.secret.api.dto.SasResponse;
import rs.in.zivanovic.share.a.secret.api.dto.SplitParameters;
+import rs.in.zivanovic.share.a.secret.api.dto.Version;
/**
*
@@ -45,6 +49,9 @@ import rs.in.zivanovic.share.a.secret.api.dto.SplitParameters;
@RequestMapping("/sas")
public class SasController {
+ @Value("${info.build.version:''}")
+ private String version;
+
@RequestMapping(method = RequestMethod.POST, value = "/split")
public ResponseEntity split(@Valid @RequestBody SplitParameters params, BindingResult br) {
if (br.hasErrors()) {
@@ -62,4 +69,17 @@ public class SasController {
params.getThreshold());
return SasResponse.ok().withData(new Shares(shares)).build();
}
+
+ @RequestMapping(method = RequestMethod.GET, value = "/version")
+ public ResponseEntity version() {
+ String commitId = "";
+ String buildTime = "";
+ try {
+ ResourceBundle rb = ResourceBundle.getBundle("git");
+ commitId = rb.getString("git.commit.id.abbrev");
+ buildTime = rb.getString("git.build.time");
+ } catch (MissingResourceException ex) {
+ }
+ return SasResponse.ok().withData(new Version(String.format("%s.%s", version, commitId), buildTime)).build();
+ }
}
diff --git a/src/main/java/rs/in/zivanovic/share/a/secret/api/dto/SasResponse.java b/src/main/java/rs/in/zivanovic/share/a/secret/api/dto/SasResponse.java
index fb255c7..385ae63 100644
--- a/src/main/java/rs/in/zivanovic/share/a/secret/api/dto/SasResponse.java
+++ b/src/main/java/rs/in/zivanovic/share/a/secret/api/dto/SasResponse.java
@@ -29,8 +29,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
/**
- * Every call to share-a-secret API service returns object of SasResponse class
- * as response.
+ * Every call to share-a-secret API service returns object of SasResponse class as response.
*
* @author Marko Zivanovic
*/
@@ -48,13 +47,14 @@ public class SasResponse {
return new SasResponse(status);
}
- public SasResponse withData(Shares shares) {
- data = shares;
+ public SasResponse withData(Object data) {
+ this.data = data;
return this;
}
public SasResponse withInvalidParameterValueError(String field, Object value, String reason) {
- return withError(Error.INVALID_PARAMETER_VALUE, String.format("Invalid value '%s' for field '%s' because '%s'", value, field, reason));
+ return withError(Error.INVALID_PARAMETER_VALUE, String.format("Invalid value '%s' for field '%s' because '%s'",
+ value, field, reason));
}
public SasResponse withError(int code, String message) {
diff --git a/src/main/java/rs/in/zivanovic/share/a/secret/api/dto/Version.java b/src/main/java/rs/in/zivanovic/share/a/secret/api/dto/Version.java
new file mode 100644
index 0000000..80bda7a
--- /dev/null
+++ b/src/main/java/rs/in/zivanovic/share/a/secret/api/dto/Version.java
@@ -0,0 +1,55 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2014 Marko Zivanovic.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package rs.in.zivanovic.share.a.secret.api.dto;
+
+/**
+ *
+ * @author Marko Zivanovic
+ */
+public class Version {
+
+ private String frontendVersion;
+ private String buildTime;
+
+ public Version(String frontendVersion, String buildTime) {
+ this.frontendVersion = frontendVersion;
+ this.buildTime = buildTime;
+ }
+
+ public String getFrontendVersion() {
+ return frontendVersion;
+ }
+
+ public void setFrontendVersion(String frontendVersion) {
+ this.frontendVersion = frontendVersion;
+ }
+
+ public String getBuildTime() {
+ return buildTime;
+ }
+
+ public void setBuildTime(String buildTime) {
+ this.buildTime = buildTime;
+ }
+}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
new file mode 100644
index 0000000..e5e005c
--- /dev/null
+++ b/src/main/resources/application.properties
@@ -0,0 +1,4 @@
+info.build.artifact=@project.artifactId@
+info.build.name=@project.name@
+info.build.description=@project.description@
+info.build.version=@project.version@
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
deleted file mode 100644
index 7bc2b98..0000000
--- a/src/main/resources/application.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-spring:
- jackson:
- serialization:
- WRITE_NULL_PROPERTIES: false
-
\ No newline at end of file
diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html
index cc92be3..84d7a5f 100644
--- a/src/main/resources/static/index.html
+++ b/src/main/resources/static/index.html
@@ -90,7 +90,18 @@
+
+
+