sftpgo-mirror/kms/basesecret.go

72 lines
1.6 KiB
Go
Raw Permalink Normal View History

2020-11-30 20:46:34 +00:00
package kms
import (
sdkkms "github.com/sftpgo/sdk/kms"
)
2021-07-13 19:17:21 +00:00
// 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"`
2020-11-30 20:46:34 +00:00
}
// GetStatus returns the secret's status
func (s *BaseSecret) GetStatus() sdkkms.SecretStatus {
2020-11-30 20:46:34 +00:00
return s.Status
}
// GetPayload returns the secret's payload
2021-07-13 19:17:21 +00:00
func (s *BaseSecret) GetPayload() string {
2020-11-30 20:46:34 +00:00
return s.Payload
}
// GetKey returns the secret's key
2021-07-13 19:17:21 +00:00
func (s *BaseSecret) GetKey() string {
2020-11-30 20:46:34 +00:00
return s.Key
}
// GetMode returns the encryption mode
2021-07-13 19:17:21 +00:00
func (s *BaseSecret) GetMode() int {
return s.Mode
}
// GetAdditionalData returns the secret's additional data
2021-07-13 19:17:21 +00:00
func (s *BaseSecret) GetAdditionalData() string {
2020-11-30 20:46:34 +00:00
return s.AdditionalData
}
// SetKey sets the secret's key
2021-07-13 19:17:21 +00:00
func (s *BaseSecret) SetKey(value string) {
2020-11-30 20:46:34 +00:00
s.Key = value
}
// SetAdditionalData sets the secret's additional data
2021-07-13 19:17:21 +00:00
func (s *BaseSecret) SetAdditionalData(value string) {
2020-11-30 20:46:34 +00:00
s.AdditionalData = value
}
// SetStatus sets the secret's status
func (s *BaseSecret) SetStatus(value sdkkms.SecretStatus) {
2020-11-30 20:46:34 +00:00
s.Status = value
}
2021-07-13 19:17:21 +00:00
func (s *BaseSecret) isEmpty() bool {
2020-11-30 20:46:34 +00:00
if s.Status != "" {
return false
}
if s.Payload != "" {
return false
}
if s.Key != "" {
return false
}
if s.AdditionalData != "" {
return false
}
return true
}