Skip to content
Snippets Groups Projects
Commit 488dd84b authored by Gospodin Bodurov's avatar Gospodin Bodurov
Browse files

Fix key storage agent

parent e30bb617
No related branches found
No related tags found
1 merge request!54Smime reflector
...@@ -95,7 +95,7 @@ func (s *KeyStorageServerImpl) GetKey(ctx context.Context, in *api.GetKeyRequest ...@@ -95,7 +95,7 @@ func (s *KeyStorageServerImpl) GetKey(ctx context.Context, in *api.GetKeyRequest
if in.KeyType == api.KeyType_KT_EMPTY { if in.KeyType == api.KeyType_KT_EMPTY {
getKeyResponse.StatusList = utils.AddStatus(getKeyResponse.StatusList, getKeyResponse.StatusList = utils.AddStatus(getKeyResponse.StatusList,
"400", api.StatusType_ERROR, "KeyType cannot be empty") "400", api.StatusType_ERROR, "KeyType cannot be empty")
return getKeyResponse, nil return getKeyResponse, errors.New("KeyType cannot be empty")
} }
key := &api.Key{} key := &api.Key{}
...@@ -106,13 +106,14 @@ func (s *KeyStorageServerImpl) GetKey(ctx context.Context, in *api.GetKeyRequest ...@@ -106,13 +106,14 @@ func (s *KeyStorageServerImpl) GetKey(ctx context.Context, in *api.GetKeyRequest
getKeyResponse.Key = nil getKeyResponse.Key = nil
getKeyResponse.StatusList = utils.AddStatus(getKeyResponse.StatusList, getKeyResponse.StatusList = utils.AddStatus(getKeyResponse.StatusList,
"500", api.StatusType_ERROR, err.Error()) "500", api.StatusType_ERROR, err.Error())
return getKeyResponse, nil return getKeyResponse, err.Error()
} }
if errorsString != "" { if errorsString != "" {
getKeyResponse.Key = nil getKeyResponse.Key = nil
getKeyResponse.StatusList = utils.AddStatus(getKeyResponse.StatusList, getKeyResponse.StatusList = utils.AddStatus(getKeyResponse.StatusList,
"500", api.StatusType_ERROR, errorsString) "500", api.StatusType_ERROR, errorsString)
return nil, errors.New(errorsString)
} }
if !hasData { if !hasData {
...@@ -120,7 +121,7 @@ func (s *KeyStorageServerImpl) GetKey(ctx context.Context, in *api.GetKeyRequest ...@@ -120,7 +121,7 @@ func (s *KeyStorageServerImpl) GetKey(ctx context.Context, in *api.GetKeyRequest
getKeyResponse.Key = nil getKeyResponse.Key = nil
getKeyResponse.StatusList = utils.AddStatus(getKeyResponse.StatusList, getKeyResponse.StatusList = utils.AddStatus(getKeyResponse.StatusList,
"500", api.StatusType_ERROR, err.Error()) "500", api.StatusType_ERROR, err.Error())
return getKeyResponse, nil return getKeyResponse, err.Error()
} }
getKeyResponse.Key = key getKeyResponse.Key = key
...@@ -139,13 +140,13 @@ func (s *KeyStorageServerImpl) SetKey(ctx context.Context, in *api.SetKeyRequest ...@@ -139,13 +140,13 @@ func (s *KeyStorageServerImpl) SetKey(ctx context.Context, in *api.SetKeyRequest
if in.Uuid == "root" { if in.Uuid == "root" {
setKeyResponse.StatusList = utils.AddStatus(setKeyResponse.StatusList, setKeyResponse.StatusList = utils.AddStatus(setKeyResponse.StatusList,
"400", api.StatusType_ERROR, "Can not set root CA keys") "400", api.StatusType_ERROR, "Can not set root CA keys")
return setKeyResponse, nil return setKeyResponse, errors.New("Can not set root CA keys")
} }
if in.KeyType == api.KeyType_KT_EMPTY { if in.KeyType == api.KeyType_KT_EMPTY {
setKeyResponse.StatusList = utils.AddStatus(setKeyResponse.StatusList, setKeyResponse.StatusList = utils.AddStatus(setKeyResponse.StatusList,
"400", api.StatusType_ERROR, "KeyType cannot be empty") "400", api.StatusType_ERROR, "KeyType cannot be empty")
return setKeyResponse, nil return setKeyResponse, errors.New("KeyType cannot be empty")
} }
key := &api.Key{} key := &api.Key{}
...@@ -156,13 +157,13 @@ func (s *KeyStorageServerImpl) SetKey(ctx context.Context, in *api.SetKeyRequest ...@@ -156,13 +157,13 @@ func (s *KeyStorageServerImpl) SetKey(ctx context.Context, in *api.SetKeyRequest
log.Printf("grpc call GetData to DataStorage failed: %s", err) log.Printf("grpc call GetData to DataStorage failed: %s", err)
setKeyResponse.StatusList = utils.AddStatus(setKeyResponse.StatusList, setKeyResponse.StatusList = utils.AddStatus(setKeyResponse.StatusList,
"500", api.StatusType_ERROR, err.Error()) "500", api.StatusType_ERROR, err.Error())
return setKeyResponse, nil return setKeyResponse, err.Error()
} }
if len(key.Content) > 0 { if len(key.Content) > 0 {
setKeyResponse.StatusList = utils.AddStatus(setKeyResponse.StatusList, setKeyResponse.StatusList = utils.AddStatus(setKeyResponse.StatusList,
"400", api.StatusType_ERROR, "Key is already set") "400", api.StatusType_ERROR, "Key is already set")
return setKeyResponse, nil return setKeyResponse, errors.New("Key is already set")
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment