2021-01-04 13:52:13 +00:00
|
|
|
package domain
|
2020-12-10 15:18:52 +00:00
|
|
|
|
2021-02-08 10:30:30 +00:00
|
|
|
import (
|
|
|
|
"time"
|
2021-02-22 11:27:47 +00:00
|
|
|
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/models"
|
2021-02-08 10:30:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type MachineKey struct {
|
|
|
|
models.ObjectRoot
|
|
|
|
|
|
|
|
KeyID string
|
2021-02-22 11:27:47 +00:00
|
|
|
Type AuthNKeyType
|
2021-02-08 10:30:30 +00:00
|
|
|
ExpirationDate time.Time
|
|
|
|
PrivateKey []byte
|
|
|
|
PublicKey []byte
|
|
|
|
}
|
|
|
|
|
2021-02-22 11:27:47 +00:00
|
|
|
func (key *MachineKey) setPublicKey(publicKey []byte) {
|
|
|
|
key.PublicKey = publicKey
|
|
|
|
}
|
2020-12-10 15:18:52 +00:00
|
|
|
|
2021-02-22 11:27:47 +00:00
|
|
|
func (key *MachineKey) setPrivateKey(privateKey []byte) {
|
|
|
|
key.PrivateKey = privateKey
|
|
|
|
}
|
2020-12-10 15:18:52 +00:00
|
|
|
|
2021-02-22 11:27:47 +00:00
|
|
|
func (key *MachineKey) expirationDate() time.Time {
|
|
|
|
return key.ExpirationDate
|
|
|
|
}
|
|
|
|
|
|
|
|
func (key *MachineKey) setExpirationDate(expiration time.Time) {
|
|
|
|
key.ExpirationDate = expiration
|
|
|
|
}
|
2020-12-10 15:18:52 +00:00
|
|
|
|
2021-02-08 10:30:30 +00:00
|
|
|
type MachineKeyState int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
MachineKeyStateUnspecified MachineKeyState = iota
|
|
|
|
MachineKeyStateActive
|
|
|
|
MachineKeyStateRemoved
|
|
|
|
|
|
|
|
machineKeyStateCount
|
|
|
|
)
|
|
|
|
|
|
|
|
func (f MachineKeyState) Valid() bool {
|
|
|
|
return f >= 0 && f < machineKeyStateCount
|
|
|
|
}
|