-
Notifications
You must be signed in to change notification settings - Fork 20
/
keytoolgenkeypair.go
45 lines (39 loc) · 1.4 KB
/
keytoolgenkeypair.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
package generator
import (
"github.com/ForgeRock/secret-agent/api/v1alpha1"
"github.com/pkg/errors"
)
// KeyToolGenKeyPair alias password manager
type KeyToolGenKeyPair struct {
v1aliasConfig *v1alpha1.KeytoolAliasConfig
}
// NewKeyToolGenKeyPair create a new password alias manager
func NewKeyToolGenKeyPair(alias *v1alpha1.KeytoolAliasConfig) *KeyToolGenKeyPair {
return &KeyToolGenKeyPair{
v1aliasConfig: alias,
}
}
// References get list of refences needed for generated a alias
func (kp *KeyToolGenKeyPair) References() ([]string, []string) {
return []string{}, []string{}
}
// LoadReferenceData loads data from references
func (kp *KeyToolGenKeyPair) LoadReferenceData(data map[string][]byte) error {
return nil
}
// Generate creates keytool password alias entry
func (kp *KeyToolGenKeyPair) Generate(baseDir string, baseCmd cmdRunner) error {
//++ keytool -genkeypair -alias rsajwtsigningkey -dname CN=rsajwtsigningkey,O=ForgeRock,L=Bristol,ST=Bristol,C=UK -keyalg RSA -keysize 2048 -sigalg SHA256WITHRSA --validity 3650
// KS_PROPS="-keystore ${KEYSTORE} -storetype ${STORE_TYPE} -storepass ${STORE_PASS} -keypass ${KEY_PASS}"
cmd := "-genkeypair"
args := []string{
"-alias", kp.v1aliasConfig.Name,
}
args = append(args, kp.v1aliasConfig.Args...)
keyToolCmd := baseCmd(cmd, args)
output, err := keyToolCmd.CombinedOutput()
if err != nil {
return errors.Wrap(err, string(output))
}
return nil
}