Merge remote-tracking branch 'origin/master'

This commit is contained in:
geek 2017-06-02 20:10:11 +09:00
commit 88e5d15982
3 changed files with 81 additions and 13 deletions

View File

@ -0,0 +1,76 @@
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 {
}
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(k *KeyStoreService)CreateKey() (string,error) {
uu, err := uuid.NewUUID();
if err != nil {
return "", err
}
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
}

View File

@ -0,0 +1 @@
package keystore

View File

@ -1,7 +1,7 @@
package noauthagent package noauthagent
import ( import (
"github.com/google/uuid"
"git.loafle.net/overflow/commons_go/model/timestamp" "git.loafle.net/overflow/commons_go/model/timestamp"
"git.loafle.net/overflow/overflow_proxy_service/proxy" "git.loafle.net/overflow/overflow_proxy_service/proxy"
"encoding/json" "encoding/json"
@ -26,6 +26,9 @@ type NoAuthAgent struct {
HostName string `json:"hostName,omitempty"` HostName string `json:"hostName,omitempty"`
} }
func NewNoAuthAgent(apikey string, localIp int64, hostName string) *NoAuthAgent { func NewNoAuthAgent(apikey string, localIp int64, hostName string) *NoAuthAgent {
na := &NoAuthAgent{ na := &NoAuthAgent{
@ -37,18 +40,6 @@ func NewNoAuthAgent(apikey string, localIp int64, hostName string) *NoAuthAgent
return na return na
} }
func(as *NoAuthAgentService)CreateTempKey(na *NoAuthAgent) (error) {
uu, err := uuid.NewUUID();
if err != nil {
return err
}
na.TempKey = uu.String()
return nil
}
func(as *NoAuthAgentService)SaveNoAuthAgent(na *NoAuthAgent) (string, error) { func(as *NoAuthAgentService)SaveNoAuthAgent(na *NoAuthAgent) (string, error) {