-
Notifications
You must be signed in to change notification settings - Fork 13
/
credentialconfig.go
61 lines (51 loc) · 1.85 KB
/
credentialconfig.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
package config
import (
"github.com/Axway/agent-sdk/pkg/cmd/properties"
)
// SubscriptionConfig - Interface to get subscription config
type CredentialConfig interface {
ShouldDeprovisionExpired() bool
GetExpirationDays() int
}
// NotificationConfig -
type CredentialConfiguration struct {
ExpirationDays int `config:"expirationDays"`
DeprovisionOnExpire bool `config:"deprovisionOnExpire"`
}
// These constants are the paths that the settings are at in a config file
const (
pathExpirationDays = "central.credentials.expirationDays"
pathExpireAction = "central.credentials.deprovisionOnExpire"
)
// AddCredentialConfigProperties -
func AddCredentialConfigProperties(props properties.Properties) {
props.AddBoolProperty(pathExpireAction, false, "Set to true if an expired credential should be deprovisioned from the data plane")
props.AddIntProperty(pathExpirationDays, 0, "The number of days until a provisioned credential expires, enforced on data plane if possible (default: 0 = Never) ")
}
// ParseCredentialConfig -
func ParseCredentialConfig(props properties.Properties) CredentialConfig {
return &CredentialConfiguration{
ExpirationDays: props.IntPropertyValue(pathExpirationDays),
DeprovisionOnExpire: props.BoolPropertyValue(pathExpireAction),
}
}
// newCredentialConfig - Creates the default credential config
func newCredentialConfig() CredentialConfig {
return &CredentialConfiguration{
ExpirationDays: 0,
DeprovisionOnExpire: false,
}
}
// ExpireAction -
func (s *CredentialConfiguration) ShouldDeprovisionExpired() bool {
return s.DeprovisionOnExpire
}
// GetTimeToLive -
func (s *CredentialConfiguration) GetExpirationDays() int {
return s.ExpirationDays
}
// ValidateCfg - Validates the config, implementing IConfigInterface
func (s *CredentialConfiguration) ValidateCfg() error {
// TODO - validate time to live
return nil
}