Module: PuppetX::Certs::Provider::Keystore
- Defined in:
- lib/puppet_x/certs/provider/keystore.rb
Instance Method Summary collapse
- #create ⇒ Object
- #delete_keystore ⇒ Object
- #destroy ⇒ Object
- #exists? ⇒ Boolean
- #generate_keystore ⇒ Object
- #store ⇒ Object
- #type ⇒ Object
Instance Method Details
#create ⇒ Object
5 6 7 |
# File 'lib/puppet_x/certs/provider/keystore.rb', line 5 def create generate_keystore end |
#delete_keystore ⇒ Object
77 78 79 |
# File 'lib/puppet_x/certs/provider/keystore.rb', line 77 def delete_keystore File.rm(store) end |
#destroy ⇒ Object
9 10 11 |
# File 'lib/puppet_x/certs/provider/keystore.rb', line 9 def destroy delete_keystore end |
#exists? ⇒ Boolean
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/puppet_x/certs/provider/keystore.rb', line 13 def exists? return false unless File.exist?(store) begin keytool( '-list', '-keystore', store, '-storepass:file', resource[:password_file], '-J-Dcom.redhat.fips=false', ) rescue Puppet::ExecutionFailure => e if e..include?('java.security.UnrecoverableKeyException') || e..include?('keystore password was incorrect') Puppet.debug("Invalid password for #{store}") return false else Puppet.log_exception(e, "Failed to read keystore '#{store}'") end end true end |
#generate_keystore ⇒ Object
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 |
# File 'lib/puppet_x/certs/provider/keystore.rb', line 43 def generate_keystore temp_alias = 'temporary-entry' FileUtils.rm_f(store) begin keytool( '-genkey', '-storetype', 'pkcs12', '-keystore', store, '-storepass:file', resource[:password_file], '-alias', temp_alias, '-dname', "CN=#{temp_alias}", '-J-Dcom.redhat.fips=false' ) rescue Puppet::ExecutionFailure => e Puppet.err("Failed to generate new #{type} with temporary entry: #{e}") return nil end begin keytool( '-delete', '-keystore', store, '-storepass:file', resource[:password_file], '-alias', temp_alias, '-J-Dcom.redhat.fips=false' ) rescue Puppet::ExecutionFailure => e Puppet.err("Failed to delete temporary entry when generating empty #{type}: #{e}") return nil end end |
#store ⇒ Object
35 36 37 |
# File 'lib/puppet_x/certs/provider/keystore.rb', line 35 def store resource[:keystore] end |
#type ⇒ Object
39 40 41 |
# File 'lib/puppet_x/certs/provider/keystore.rb', line 39 def type 'keystore' end |