diff --git a/handler/revoke.go b/handler/manage_device_key.go similarity index 78% rename from handler/revoke.go rename to handler/manage_device_key.go index 5f02f9b87c5a5efbbc5127e667815298feb1b655..72a389523ec64a221ee2add91189beb7bb959259 100644 --- a/handler/revoke.go +++ b/handler/manage_device_key.go @@ -26,6 +26,28 @@ import ( "golang.org/x/net/context" ) +func (s *KeyStorageServerImpl) SetAuthorized(ctx context.Context, in *api.SetAuthorizedRequest) (*api.SetAuthorizedResponse, error) { + setAuthorizedResponse := &api.SetAuthorizedResponse{} + + setAuthorizedResponse.StatusList = s.updateAll(ctx, in.Uuid, func(k *api.Key) { k.Unauthorized = !in.Value }) + if setAuthorizedResponse.StatusList != nil { + return setAuthorizedResponse, nil + } + setAuthorizedResponse.StatusList = utils.AddStatus(setAuthorizedResponse.StatusList, "200", api.StatusType_INFO, "Keys authorization updated") + return setAuthorizedResponse, nil +} + +func (s *KeyStorageServerImpl) Destroy(ctx context.Context, in *api.DestroyRequest) (*api.DestroyResponse, error) { + destroyResponse := &api.DestroyResponse{} + + destroyResponse.StatusList = s.updateAll(ctx, in.Uuid, func(k *api.Key) { k.Destroyed = true }) + if destroyResponse.StatusList != nil { + return destroyResponse, nil + } + destroyResponse.StatusList = utils.AddStatus(destroyResponse.StatusList, "200", api.StatusType_INFO, "Keys destroyed") + return destroyResponse, nil +} + func (s *KeyStorageServerImpl) Revoke(ctx context.Context, in *api.RevokeRequest) (*api.RevokeResponse, error) { revokeResponse := &api.RevokeResponse{}