-
Notifications
You must be signed in to change notification settings - Fork 20
/
keytoolgenseckey.go
45 lines (39 loc) · 1.29 KB
/
keytoolgenseckey.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"
)
// KeyToolGenSecKey alias password manager
type KeyToolGenSecKey struct {
v1aliasConfig *v1alpha1.KeytoolAliasConfig
}
// NewKeyToolGenSecKey create a new password alias manager
func NewKeyToolGenSecKey(alias *v1alpha1.KeytoolAliasConfig) *KeyToolGenSecKey {
return &KeyToolGenSecKey{
v1aliasConfig: alias,
}
}
// References get list of refences needed for generated a alias
func (kp *KeyToolGenSecKey) References() ([]string, []string) {
return []string{}, []string{}
}
// LoadReferenceData loads data from references
func (kp *KeyToolGenSecKey) LoadReferenceData(data map[string][]byte) error {
return nil
}
// Generate creates keytool password alias entry
func (kp *KeyToolGenSecKey) Generate(baseDir string, baseCmd cmdRunner) error {
// keytool -genseckey -alias selfservicesigntest -keyalg HmacSHA256 -keysize 256
// KS_PROPS="-keystore ${KEYSTORE} -storetype ${STORE_TYPE} -storepass ${STORE_PASS} -keypass ${KEY_PASS}"
cmd := "-genseckey"
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
}