/
basesecret.go
85 lines (73 loc) · 2.2 KB
/
basesecret.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright (C) 2019-2022 Nicola Murino
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, version 3.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package kms
import (
sdkkms "github.com/sftpgo/sdk/kms"
)
// BaseSecret defines the base struct shared among all the secret providers
type BaseSecret struct {
Status sdkkms.SecretStatus `json:"status,omitempty"`
Payload string `json:"payload,omitempty"`
Key string `json:"key,omitempty"`
AdditionalData string `json:"additional_data,omitempty"`
// 1 means encrypted using a master key
Mode int `json:"mode,omitempty"`
}
// GetStatus returns the secret's status
func (s *BaseSecret) GetStatus() sdkkms.SecretStatus {
return s.Status
}
// GetPayload returns the secret's payload
func (s *BaseSecret) GetPayload() string {
return s.Payload
}
// GetKey returns the secret's key
func (s *BaseSecret) GetKey() string {
return s.Key
}
// GetMode returns the encryption mode
func (s *BaseSecret) GetMode() int {
return s.Mode
}
// GetAdditionalData returns the secret's additional data
func (s *BaseSecret) GetAdditionalData() string {
return s.AdditionalData
}
// SetKey sets the secret's key
func (s *BaseSecret) SetKey(value string) {
s.Key = value
}
// SetAdditionalData sets the secret's additional data
func (s *BaseSecret) SetAdditionalData(value string) {
s.AdditionalData = value
}
// SetStatus sets the secret's status
func (s *BaseSecret) SetStatus(value sdkkms.SecretStatus) {
s.Status = value
}
func (s *BaseSecret) isEmpty() bool {
if s.Status != "" {
return false
}
if s.Payload != "" {
return false
}
if s.Key != "" {
return false
}
if s.AdditionalData != "" {
return false
}
return true
}