keystore added
This commit is contained in:
snoop
2017-06-04 16:34:10 +09:00
parent 88e5d15982
commit cd7f0cbc0a
4 changed files with 101 additions and 54 deletions

View File

@@ -2,10 +2,6 @@ package keystore
import (
"github.com/google/uuid"
"encoding/json"
"git.loafle.net/overflow/commons_go/model/timestamp"
"git.loafle.net/overflow/overflow_proxy_service/proxy"
"log"
)
type KeyStoreService struct {
@@ -13,11 +9,8 @@ type KeyStoreService struct {
}
type ApiKey struct {
Id json.Number `json:"id,Number,omitempty"`
Apikey string `json:"apiKey,omitempty"`
CreateDAte timestamp.Timestamp`json:"createDate,omitempty"`
HostName string `json:"hostName,omitempty"`
func NewKeyStoreSerivce() *KeyStoreService {
return &KeyStoreService{}
}
func(k *KeyStoreService)CreateKey() (string,error) {
@@ -29,48 +22,3 @@ func(k *KeyStoreService)CreateKey() (string,error) {
return uu.String(), nil
}
func(k *KeyStoreService)SaveApikey(key *ApiKey) (string, error) {
bytes, err := json.Marshal(key)
if err != nil {
return "", err
}
m := make(map[string]string)
m["com.loafle.overflow.keystore.model.Apikey"] = string(bytes)
out := proxy.InvokeDB("apiKey", "create", m)
log.Print(out)
return "", nil
}
func(k *KeyStoreService)CheckApikey(apikey string) (bool, error) {
ak := ApiKey{
Apikey:apikey,
}
bytes, err := json.Marshal(ak)
if err != nil {
return false, err
}
m := make(map[string]string)
m["com.loafle.overflow.keystore.model.Apikey"] = string(bytes)
out := proxy.InvokeDB("apiKey", "findByApiKey", m)
log.Print(out)
return true, nil
}