Browse Source

implemented DeleteKey, updated the GUI

master
arnaucode 7 years ago
parent
commit
0ad055c480
9 changed files with 85 additions and 37 deletions
  1. +1
    -1
      clientApp/GUI/index.html
  2. +1
    -1
      clientApp/GUI/views/login/login.html
  3. +26
    -32
      clientApp/GUI/views/main/main.html
  4. +11
    -0
      clientApp/GUI/views/main/main.js
  5. +16
    -0
      clientApp/clientApp.go
  6. +12
    -1
      clientApp/clientAppRESTFunctions.go
  7. +10
    -0
      clientApp/keys.go
  8. +8
    -2
      clientApp/restRoutes.go
  9. BIN
      documentation/screenshot02.png

+ 1
- 1
clientApp/GUI/index.html

@ -18,7 +18,7 @@
<body ng-app="webapp">
<div ng-include="'views/navbar.html'"></div>
<br><br><br><br><br>
<br><br><br>
<div ng-view></div>

+ 1
- 1
clientApp/GUI/views/login/login.html

@ -1,4 +1,4 @@
<div class="container" style="margin-top: -80px;">
<div class="container" style="margin-top: -60px;">
<div class="row">
<div class="col-sm-3">

+ 26
- 32
clientApp/GUI/views/main/main.html

@ -6,46 +6,40 @@
<div class="col-sm-8">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-sm-6">
<div ng-click="" class="btn btn-raised btn-block c_o_green300">Use ID</div>
</div>
<div class="col-sm-6">
<div ng-click="newID()" class="btn btn-raised btn-block c_o_pink300">Create new ID</div>
</div>
</div>
<div class="row">
<div class="progress progress-striped" ng-show="generatingID">
<div class="progress-bar progress-bar-success active" style="width: 100%"></div>
</div>
</div>
</div>
<hr>
<div class="card-body">
<div ng-click="newID()" class="btn btn-raised pull-right c_o_pink300">Create new ID</div>
<h4 class="card-title">
My IDs
</h4>
<div class="row" style="height:160px;" ng-repeat="id in ids">
<div class="col-sm-6">
Public Key: {{id.pubK}}
<!--<br> Private Key: {{id.privK}}-->
<br> Date of creation: {{id.date}}
<!--<br> {{id.pubKSigned}}-->
<br>
<br><br>
</div>
<div class="col-sm-6">
<div class="pull-right">
<div class="card" ng-repeat="id in ids" style="overflow-x:hidden;">
<div class="card-body">
<h4>{{id.id}}</h4>
<span class="pull-right">{{id.date | date: "dd.MM.y, HH:mm:ss"}}h</span>
<span class="badge c_o_red300" ng-show="!id.verified">Not verified</span>
<span class="badge c_o_green300" ng-show="id.verified">Verified</span>
</div>
<div class="pull-right">
<span class="badge c_o_orange300" ng-show="!id.unblindedsig">Not signed</span>
<span class="badge c_o_blue300" ng-show="id.unblindedsig">Signed</span>
<span class="badge c_o_deepPurple300" ng-show="id.blockchainref">in Blockchain</span>
<div class="row">
<div class="col-sm-6">
<div ng-click="clientApp('blindandsendtosign', id.id)" ng-show="!id.unblindedsig" class="btn btn-raised btn-sm c_o_cyan300">Send to serverIDsigner</div>
<div ng-click="clientApp('addtoblockchain', id.id)" ng-show="id.unblindedsig && !id.blockchainref" class="btn btn-raised btn-sm c_o_deepPurple300">Add to blockchain</div>
<a ng-href="#!/id/{{id.id}}" ng-show="id.blockchainref" class="btn btn-raised btn-sm c_o_green300">Use ID</a>
</div>
<div class="col-sm-6">
<!--<div ng-click="verify(id.id)" ng-show="!id.verified"class="btn btn-sm btn-raised c_o_deepPurple300 pull-right">Verify</div>-->
<div ng-click="clientApp('delete', id.id)" class="btn btn-raised pull-right btn-sm c_o_red300">
<i title="Delete" class="fa fa-trash fa-1x"></i>
</div>
</div>
</div>
<br><br>
<div ng-click="blindAndSendToSign(id.id)" ng-show="!id.unblindedsig" class="btn btn-sm btn-raised c_o_cyan300 pull-right">Send to serverIDsigner</div>
<!--<div ng-click="verify(id.id)" ng-show="!id.verified"class="btn btn-sm btn-raised c_o_deepPurple300 pull-right">Verify</div>-->
</div>
</div>
<div class="row">
<div class="progress progress-striped" ng-show="generatingID">
<div class="progress-bar progress-bar-success active" style="width: 100%"></div>
</div>
</div>
</div>

+ 11
- 0
clientApp/GUI/views/main/main.js

@ -61,4 +61,15 @@ angular.module('app.main', ['ngRoute'])
console.log('data error');
});
};
$scope.clientApp = function(route, param) {
$http.get(clientapi + route + '/' + param)
.then(function(data) {
console.log('data success');
console.log(data);
$scope.ids = data.data;
}, function(data) {
console.log('data error');
});
};
});

+ 16
- 0
clientApp/clientApp.go

@ -8,6 +8,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"os/exec"
"time"
"github.com/cryptoballot/fdh"
@ -124,3 +125,18 @@ func Verify(packPubK string) {
return
}
func Delete(keyID string) []Key {
originalKeys := readKeys()
//remove key .pem files
key := getKeyByKeyID(keyID)
_, err := exec.Command("rm", keysDir+"/"+key.PrivK).CombinedOutput()
check(err)
_, err = exec.Command("rm", keysDir+"/"+key.PubK).CombinedOutput()
check(err)
//remove key from keys.json
keys := removeKey(keyID, originalKeys)
saveKeys(keys)
return keys
}

+ 12
- 1
clientApp/clientAppRESTFunctions.go

@ -37,7 +37,7 @@ func GetNewID(w http.ResponseWriter, r *http.Request) {
}
func GetBlindAndSendToSign(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
idKey := vars["idKey"]
idKey := vars["keyid"]
color.Green(idKey)
keys := BlindAndSendToSign(idKey)
@ -59,3 +59,14 @@ func GetVerify(w http.ResponseWriter, r *http.Request) {
check(err)
fmt.Fprintln(w, string(jResp))
}
func GetDelete(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
keyID := vars["keyid"]
keys := Delete(keyID)
jResp, err := json.Marshal(keys)
check(err)
fmt.Fprintln(w, string(jResp))
}

+ 10
- 0
clientApp/keys.go

@ -24,6 +24,8 @@ type Key struct {
UnblindedSig []byte `json:"unblindedsig"`
Verified bool `json:"verified"`
ServerVerifier *rsa.PublicKey `json:"serververifier"`
SignerID string `json:"signerid"`
BlockchainRef string `json:"blockchainref"`
}
func ExportRsaPrivateKeyAsPemStr(privkey *rsa.PrivateKey) string {
@ -151,6 +153,14 @@ func getKeyByKeyID(keyID string) (k Key) {
}
return k
}
func removeKey(keyID string, originalKeys []Key) (keys []Key) {
for _, key := range originalKeys {
if key.ID != keyID {
keys = append(keys, key)
}
}
return
}
/*
func getServerPubK(url string) ownrsa.RSAPublicKey {

+ 8
- 2
clientApp/restRoutes.go

@ -30,13 +30,19 @@ var routes = Routes{
Route{
"GetBlindAndSendToSign",
"GET",
"/blindandsendtosign/{idKey}",
"/blindandsendtosign/{keyid}",
GetBlindAndSendToSign,
},
Route{
"GetVerify",
"GET",
"/verify/{idKey}",
"/verify/{keyid}",
GetVerify,
},
Route{
"GetDelete",
"GET",
"/delete/{keyid}",
GetDelete,
},
}

BIN
documentation/screenshot02.png

Before After
Width: 853  |  Height: 626  |  Size: 61 KiB Width: 853  |  Height: 628  |  Size: 67 KiB

Loading…
Cancel
Save