-
Notifications
You must be signed in to change notification settings - Fork 30
/
pki_export_encryption_key.go
108 lines (98 loc) · 5.22 KB
/
pki_export_encryption_key.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const (
DnpkiExportEncryptionKey = "uni/exportcryptkey"
RnpkiExportEncryptionKey = "exportcryptkey"
ParentDnpkiExportEncryptionKey = "uni"
PkiexportencryptionkeyClassName = "pkiExportEncryptionKey"
)
type AESEncryptionPassphraseandKeysforConfigExportImport struct {
BaseAttributes
NameAliasAttribute
AESEncryptionPassphraseandKeysforConfigExportImportAttributes
}
type AESEncryptionPassphraseandKeysforConfigExportImportAttributes struct {
Annotation string `json:",omitempty"`
ClearEncryptionKey string `json:",omitempty"`
Name string `json:",omitempty"`
Passphrase string `json:",omitempty"`
PassphraseKeyDerivationVersion string `json:",omitempty"`
StrongEncryptionEnabled string `json:",omitempty"`
KeyConfigured string `json:",omitempty"`
}
func NewAESEncryptionPassphraseandKeysforConfigExportImport(pkiExportEncryptionKeyRn, parentDn, description, nameAlias string, pkiExportEncryptionKeyAttr AESEncryptionPassphraseandKeysforConfigExportImportAttributes) *AESEncryptionPassphraseandKeysforConfigExportImport {
dn := fmt.Sprintf("%s/%s", parentDn, pkiExportEncryptionKeyRn)
return &AESEncryptionPassphraseandKeysforConfigExportImport{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: PkiexportencryptionkeyClassName,
Rn: pkiExportEncryptionKeyRn,
},
NameAliasAttribute: NameAliasAttribute{
NameAlias: nameAlias,
},
AESEncryptionPassphraseandKeysforConfigExportImportAttributes: pkiExportEncryptionKeyAttr,
}
}
func (pkiExportEncryptionKey *AESEncryptionPassphraseandKeysforConfigExportImport) ToMap() (map[string]string, error) {
pkiExportEncryptionKeyMap, err := pkiExportEncryptionKey.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
alias, err := pkiExportEncryptionKey.NameAliasAttribute.ToMap()
if err != nil {
return nil, err
}
for key, value := range alias {
A(pkiExportEncryptionKeyMap, key, value)
}
A(pkiExportEncryptionKeyMap, "annotation", pkiExportEncryptionKey.Annotation)
A(pkiExportEncryptionKeyMap, "clearEncryptionKey", pkiExportEncryptionKey.ClearEncryptionKey)
A(pkiExportEncryptionKeyMap, "name", pkiExportEncryptionKey.Name)
A(pkiExportEncryptionKeyMap, "passphrase", pkiExportEncryptionKey.Passphrase)
A(pkiExportEncryptionKeyMap, "passphraseKeyDerivationVersion", pkiExportEncryptionKey.PassphraseKeyDerivationVersion)
A(pkiExportEncryptionKeyMap, "strongEncryptionEnabled", pkiExportEncryptionKey.StrongEncryptionEnabled)
A(pkiExportEncryptionKeyMap, "keyConfigured", pkiExportEncryptionKey.KeyConfigured)
return pkiExportEncryptionKeyMap, err
}
func AESEncryptionPassphraseandKeysforConfigExportImportFromContainerList(cont *container.Container, index int) *AESEncryptionPassphraseandKeysforConfigExportImport {
AESEncryptionPassphraseandKeysforConfigExportImportCont := cont.S("imdata").Index(index).S(PkiexportencryptionkeyClassName, "attributes")
return &AESEncryptionPassphraseandKeysforConfigExportImport{
BaseAttributes{
DistinguishedName: G(AESEncryptionPassphraseandKeysforConfigExportImportCont, "dn"),
Description: G(AESEncryptionPassphraseandKeysforConfigExportImportCont, "descr"),
Status: G(AESEncryptionPassphraseandKeysforConfigExportImportCont, "status"),
ClassName: PkiexportencryptionkeyClassName,
Rn: G(AESEncryptionPassphraseandKeysforConfigExportImportCont, "rn"),
},
NameAliasAttribute{
NameAlias: G(AESEncryptionPassphraseandKeysforConfigExportImportCont, "nameAlias"),
},
AESEncryptionPassphraseandKeysforConfigExportImportAttributes{
Annotation: G(AESEncryptionPassphraseandKeysforConfigExportImportCont, "annotation"),
ClearEncryptionKey: G(AESEncryptionPassphraseandKeysforConfigExportImportCont, "clearEncryptionKey"),
Name: G(AESEncryptionPassphraseandKeysforConfigExportImportCont, "name"),
Passphrase: G(AESEncryptionPassphraseandKeysforConfigExportImportCont, "passphrase"),
PassphraseKeyDerivationVersion: G(AESEncryptionPassphraseandKeysforConfigExportImportCont, "passphraseKeyDerivationVersion"),
StrongEncryptionEnabled: G(AESEncryptionPassphraseandKeysforConfigExportImportCont, "strongEncryptionEnabled"),
KeyConfigured: G(AESEncryptionPassphraseandKeysforConfigExportImportCont, "keyConfigured"),
},
}
}
func AESEncryptionPassphraseandKeysforConfigExportImportFromContainer(cont *container.Container) *AESEncryptionPassphraseandKeysforConfigExportImport {
return AESEncryptionPassphraseandKeysforConfigExportImportFromContainerList(cont, 0)
}
func AESEncryptionPassphraseandKeysforConfigExportImportListFromContainer(cont *container.Container) []*AESEncryptionPassphraseandKeysforConfigExportImport {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*AESEncryptionPassphraseandKeysforConfigExportImport, length)
for i := 0; i < length; i++ {
arr[i] = AESEncryptionPassphraseandKeysforConfigExportImportFromContainerList(cont, i)
}
return arr
}