Frontend should display version information.
This commit is contained in:
@@ -52,6 +52,10 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>pl.project13.maven</groupId>
|
||||||
|
<artifactId>git-commit-id-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,10 @@
|
|||||||
package rs.in.zivanovic.share.a.secret.api.controllers;
|
package rs.in.zivanovic.share.a.secret.api.controllers;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.MissingResourceException;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
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.ShamirSecretSharing;
|
||||||
import rs.in.zivanovic.share.a.secret.api.dto.SasResponse;
|
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.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")
|
@RequestMapping("/sas")
|
||||||
public class SasController {
|
public class SasController {
|
||||||
|
|
||||||
|
@Value("${info.build.version:'<N/A>'}")
|
||||||
|
private String version;
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = "/split")
|
@RequestMapping(method = RequestMethod.POST, value = "/split")
|
||||||
public ResponseEntity split(@Valid @RequestBody SplitParameters params, BindingResult br) {
|
public ResponseEntity split(@Valid @RequestBody SplitParameters params, BindingResult br) {
|
||||||
if (br.hasErrors()) {
|
if (br.hasErrors()) {
|
||||||
@@ -62,4 +69,17 @@ public class SasController {
|
|||||||
params.getThreshold());
|
params.getThreshold());
|
||||||
return SasResponse.ok().withData(new Shares(shares)).build();
|
return SasResponse.ok().withData(new Shares(shares)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = "/version")
|
||||||
|
public ResponseEntity version() {
|
||||||
|
String commitId = "<N/A>";
|
||||||
|
String buildTime = "<N/A>";
|
||||||
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,7 @@ import org.springframework.http.HttpStatus;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Every call to share-a-secret API service returns object of SasResponse class
|
* Every call to share-a-secret API service returns object of SasResponse class as response.
|
||||||
* as response.
|
|
||||||
*
|
*
|
||||||
* @author Marko Zivanovic <marko@zivanovic.in.rs>
|
* @author Marko Zivanovic <marko@zivanovic.in.rs>
|
||||||
*/
|
*/
|
||||||
@@ -48,13 +47,14 @@ public class SasResponse {
|
|||||||
return new SasResponse(status);
|
return new SasResponse(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SasResponse withData(Shares shares) {
|
public SasResponse withData(Object data) {
|
||||||
data = shares;
|
this.data = data;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SasResponse withInvalidParameterValueError(String field, Object value, String reason) {
|
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) {
|
public SasResponse withError(int code, String message) {
|
||||||
|
|||||||
@@ -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 <marko@zivanovic.in.rs>
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
info.build.artifact=@project.artifactId@
|
||||||
|
info.build.name=@project.name@
|
||||||
|
info.build.description=@project.description@
|
||||||
|
info.build.version=@project.version@
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
spring:
|
|
||||||
jackson:
|
|
||||||
serialization:
|
|
||||||
WRITE_NULL_PROPERTIES: false
|
|
||||||
|
|
||||||
@@ -90,7 +90,18 @@
|
|||||||
</tabset>
|
</tabset>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<hr/>
|
||||||
|
<small class="text-muted">
|
||||||
|
Share-a-secret service version {{version.frontendVersion}} built at {{version.buildTime}}.<br/>
|
||||||
|
Full source code available under <a href="http://opensource.org/licenses/MIT">MIT license</a> at <a href="https://github.com/zmarko/share-a-secret-api">GitHub</a>.<br/>
|
||||||
|
Copyright © 2014 Marko Zivanovic.<br/>
|
||||||
|
This web site uses material from the Wikipedia article <a href="https://en.wikipedia.org/wiki/Secret_sharing">"Secret sharing"</a>, which is released under the <a href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-Share-Alike License 3.0</a>.
|
||||||
|
</small>
|
||||||
|
</footer>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -39,4 +39,8 @@ angular.module('sasApp', [
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}).run(function (SasService, $rootScope) {
|
||||||
|
SasService.version({}, function (response) {
|
||||||
|
$rootScope.version = response.data;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
angular.module('sasControllers', []).
|
angular.module('sasControllers', []).
|
||||||
controller('MainController', ['$scope', 'SplitService',
|
controller('MainController', ['$scope', 'SasService',
|
||||||
function ($scope, SplitService) {
|
function ($scope, SasService) {
|
||||||
|
|
||||||
$scope.total = 10;
|
$scope.total = 10;
|
||||||
$scope.threshold = 3;
|
$scope.threshold = 3;
|
||||||
@@ -48,7 +48,7 @@ angular.module('sasControllers', []).
|
|||||||
$scope.errors = [];
|
$scope.errors = [];
|
||||||
$scope.shares = [];
|
$scope.shares = [];
|
||||||
clickedShares = {};
|
clickedShares = {};
|
||||||
SplitService.split({
|
SasService.split({
|
||||||
secret: $scope.secret,
|
secret: $scope.secret,
|
||||||
total: $scope.total,
|
total: $scope.total,
|
||||||
threshold: $scope.threshold},
|
threshold: $scope.threshold},
|
||||||
|
|||||||
@@ -23,10 +23,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
angular.module('sasServices', []).
|
angular.module('sasServices', []).
|
||||||
factory('SplitService', ['$resource', function ($resource) {
|
factory('SasService', ['$resource', function ($resource) {
|
||||||
return $resource("/sas/split", {}, {
|
return $resource("/sas", {}, {
|
||||||
split: {
|
split: {
|
||||||
|
url: "/sas/split",
|
||||||
method: "POST"
|
method: "POST"
|
||||||
|
},
|
||||||
|
version: {
|
||||||
|
url: "/sas/version",
|
||||||
|
method: "GET"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}]);
|
}]);
|
||||||
|
|||||||
Reference in New Issue
Block a user