Skip to content

Commit

Permalink
add importkeystore action
Browse files Browse the repository at this point in the history
  • Loading branch information
cwjohnston committed Jul 13, 2015
1 parent 267c782 commit 62f874a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions libraries/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def importcert_keytool_manage(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:keytool_manage, :importcert, resource_name)
end

def importkeystore_keytool_manage(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:keytool_manage, :importkeystore, resource_name)
end

def deletecert_keytool_manage(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:keytool_manage, :deletecert, resource_name)
end
Expand Down
15 changes: 15 additions & 0 deletions providers/manage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ def is_current_pass?(pass)
end
end

action :importkeystore do
@keytool += " -file #{@cert_file} -importkeystore -srckeystore #{new_resource.file} -srcstoretype #{new_resource.srcstoretype} -srcstorepass #{new_resource.srcstorepass} -alias #{new_resource.cert_alias}"
@keytool.insert(0, 'echo yes | ')


if ::File.exists?(@cert_file)
unless already_in_keystore?(new_resource.cert_alias)
Mixlib::ShellOut.new(@keytool).run_command.error!
Chef::Log.info("keytool_manage[#{new_resource.cert_alias}] imported to #{new_resource.keystore}")
new_resource.updated_by_last_action(true)
end
end
end


action :deletecert do
@keytool += " -delete -alias #{new_resource.cert_alias}"

Expand Down
6 changes: 5 additions & 1 deletion resources/manage.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
actions :exportcert, :importcert, :deletecert, :storepasswd
actions :exportcert, :importcert, :deletecert, :storepasswd, :importkeystore
default_action :exportcert

attribute :additional, :kind_of => String
Expand All @@ -9,3 +9,7 @@
attribute :new_pass, :kind_of => String
attribute :storepass, :kind_of => String, :required => true
attribute :storepass_file, :kind_of => String

# these attributes are specific to the :importkeystore action
attribute :srcstoretype, :kind_of => String
attribute :srcstorepass, :kind_of => String

0 comments on commit 62f874a

Please sign in to comment.