Refactoring and cleanup.
This commit is contained in:
@@ -30,7 +30,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Marko Zivanovic <marko@zivanovic.in.rs>
|
||||
*/
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
|
||||
@@ -78,7 +78,7 @@ public class SasController {
|
||||
response = processValidationErrors(br);
|
||||
} else {
|
||||
try {
|
||||
String secret = ShamirSecretSharing.joinToUtf8String(makeSecretShares(params));
|
||||
String secret = ShamirSecretSharing.joinToUtf8String(decodeSecretShares(params));
|
||||
response = SasResponse.ok().withData(new JoinResponse(secret));
|
||||
} catch (RuntimeException ex) {
|
||||
response = SasResponse.badRequest().withInvalidParameterValueError("shares", params.getShares(),
|
||||
@@ -102,7 +102,7 @@ public class SasController {
|
||||
return r;
|
||||
}
|
||||
|
||||
private List<SecretShare> makeSecretShares(JoinParameters params) {
|
||||
private List<SecretShare> decodeSecretShares(JoinParameters params) {
|
||||
List<SecretShare> shares = new ArrayList<>(params.getShares().size());
|
||||
params.getShares().stream().forEach(share -> {
|
||||
shares.add(Utils.decodeFromBinary(Base64.getDecoder().decode(share)));
|
||||
|
||||
@@ -24,17 +24,17 @@
|
||||
|
||||
angular.module('sasServices', []).
|
||||
factory('SasService', ['$resource', function ($resource) {
|
||||
return $resource("/sas", {}, {
|
||||
return $resource("https://share-a-secret-api.herokuapp.com/sas", {}, {
|
||||
split: {
|
||||
url: "/sas/split",
|
||||
url: "https://share-a-secret-api.herokuapp.com/sas/split",
|
||||
method: "POST"
|
||||
},
|
||||
join: {
|
||||
url: "/sas/join",
|
||||
url: "https://share-a-secret-api.herokuapp.com/sas/join",
|
||||
method: "POST"
|
||||
},
|
||||
version: {
|
||||
url: "/sas/version",
|
||||
url: "https://share-a-secret-api.herokuapp.com/sas/version",
|
||||
method: "GET"
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user