mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
move kms implementation outside the sdk package
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
71
kms/basesecret.go
Normal file
71
kms/basesecret.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package kms
|
||||
|
||||
import (
|
||||
sdkkms "github.com/drakkan/sftpgo/v2/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
|
||||
}
|
||||
Reference in New Issue
Block a user