Showing with 141 additions and 158 deletions.
  1. +2 −6 .travis.yml
  2. +7 −0 CHANGELOG.md
  3. +5 −4 Gemfile
  4. +119 −121 lib/puppet/type/java_ks.rb
  5. +4 −3 metadata.json
  6. +4 −24 spec/spec_helper_acceptance.rb
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,16 @@ script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake
matrix:
fast_finish: true
include:
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.4.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
- rvm: 2.1.5
env: PUPPET_GEM_VERSION="~> 3.0"
- rvm: 2.1.5
env: PUPPET_GEM_VERSION="~> 3.4.0"
- rvm: 2.1.5
env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes"
- rvm: 2.1.6
env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0"
- rvm: 1.8.7
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
##2015-07-20 - Supported Release 1.3.1
###Summary
This release updates the metadata for the upcoming release of PE as well as an additional bugfix.

####Bugfixes
- Fixes Puppet.newtype deprecation warning

##2015-04-14 - Supported Release 1.3.0
###Summary
Remove openssl command line tool from requirements
Expand Down
9 changes: 5 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@ group :development, :unit_tests do
gem 'json', :require => false
end

beaker_version = ENV['BEAKER_VERSION']
beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
group :system_tests do
if beaker_version
if beaker_version = ENV['BEAKER_VERSION']
gem 'beaker', *location_for(beaker_version)
end
if beaker_rspec_version
if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
gem 'beaker-rspec', *location_for(beaker_rspec_version)
else
gem 'beaker-rspec', :require => false
end
gem 'serverspec', :require => false
gem 'beaker-puppet_install_helper', :require => false
end



if facterversion = ENV['FACTER_GEM_VERSION']
gem 'facter', facterversion, :require => false
else
Expand Down
240 changes: 119 additions & 121 deletions lib/puppet/type/java_ks.rb
Original file line number Diff line number Diff line change
@@ -1,167 +1,165 @@
module Puppet
newtype(:java_ks) do
@doc = 'Manages the entries in a java keystore, and uses composite namevars to
accomplish the same alias spread across multiple target keystores.'
Puppet::Type.newtype(:java_ks) do
@doc = 'Manages the entries in a java keystore, and uses composite namevars to
accomplish the same alias spread across multiple target keystores.'

ensurable do
ensurable do

desc 'Has three states: present, absent, and latest. Latest
will compare the on disk MD5 fingerprint of the certificate and to that
in keytool to determine if insync? returns true or false. We redefine
insync? for this paramerter to accomplish this.'
desc 'Has three states: present, absent, and latest. Latest
will compare the on disk MD5 fingerprint of the certificate to that
in keytool to determine if insync? returns true or false. We redefine
insync? for this paramerter to accomplish this.'

newvalue(:present) do
provider.create
end
newvalue(:present) do
provider.create
end

newvalue(:absent) do
provider.destroy
end
newvalue(:absent) do
provider.destroy
end

newvalue(:latest) do
if provider.exists?
provider.update
else
provider.create
end
newvalue(:latest) do
if provider.exists?
provider.update
else
provider.create
end
end

def insync?(is)

@should.each do |should|
case should
when :present
return true if is == :present
when :absent
return true if is == :absent
when :latest
unless is == :absent
return true if provider.latest == provider.current
end
def insync?(is)

@should.each do |should|
case should
when :present
return true if is == :present
when :absent
return true if is == :absent
when :latest
unless is == :absent
return true if provider.latest == provider.current
end
end

return false
end

defaultto :present
return false
end

newparam(:name) do
desc 'The alias that is used to identify the entry in the keystore. This will be
converted to lowercase.'
defaultto :present
end

newparam(:name) do
desc 'The alias that is used to identify the entry in the keystore. This will be
converted to lowercase.'

isnamevar
isnamevar

munge do |value|
value.downcase
end
munge do |value|
value.downcase
end
end

newparam(:target) do
desc 'Destination file for the keystore. This will autorequire the parent directory of the file.'
newparam(:target) do
desc 'Destination file for the keystore. This will autorequire the parent directory of the file.'

isnamevar
end
isnamevar
end

newparam(:certificate) do
desc 'An already signed certificate that we can place in the keystore. This will autorequire the specified file.'
newparam(:certificate) do
desc 'An already signed certificate that we can place in the keystore. This will autorequire the specified file.'

isrequired
end
isrequired
end

newparam(:private_key) do
desc 'If you want an application to be a server and encrypt traffic,
you will need a private key. Private key entries in a keystore must be
accompanied by a signed certificate for the keytool provider. This will autorequire the specified file.'
end
newparam(:private_key) do
desc 'If you want an application to be a server and encrypt traffic,
you will need a private key. Private key entries in a keystore must be
accompanied by a signed certificate for the keytool provider. This will autorequire the specified file.'
end

newparam(:chain) do
desc 'Some java applications do not properly send
intermediary certificate authorities, in this case you can bundle them
with the server certificate using chain. This will autorequire the specified file.'
end
newparam(:chain) do
desc 'Some java applications do not properly send
intermediary certificate authorities, in this case you can bundle them
with the server certificate using chain. This will autorequire the specified file.'
end

newparam(:password) do
desc 'The password used to protect the keystore. If private keys are
subsequently also protected this password will be used to attempt
unlocking. Must be six or more characters in length. Cannot be used
together with :password_file, but you must pass at least one of these parameters.'
newparam(:password) do
desc 'The password used to protect the keystore. If private keys are
subsequently also protected this password will be used to attempt
unlocking. Must be six or more characters in length. Cannot be used
together with :password_file, but you must pass at least one of these parameters.'

validate do |value|
raise Puppet::Error, "password is #{value.length} characters long; must be 6 characters or greater in length" if value.length < 6
end
validate do |value|
raise Puppet::Error, "password is #{value.length} characters long; must be 6 characters or greater in length" if value.length < 6
end
end

newparam(:password_file) do
desc 'The path to a file containing the password used to protect the
keystore. This cannot be used together with :password, but you must pass at least one of these parameters.'
end
newparam(:password_file) do
desc 'The path to a file containing the password used to protect the
keystore. This cannot be used together with :password, but you must pass at least one of these parameters.'
end

newparam(:trustcacerts) do
desc "Certificate authorities aren't by default trusted so if you are adding a CA you need to set this to true.
Defaults to :false."
newparam(:trustcacerts) do
desc "Certificate authorities aren't by default trusted so if you are adding a CA you need to set this to true.
Defaults to :false."

newvalues(:true, :false)
newvalues(:true, :false)

defaultto :false
end
defaultto :false
end

newparam(:path) do
desc "The search path used for command (keytool, openssl) execution.
Paths can be specified as an array or as a '#{File::PATH_SEPARATOR}' separated list."
newparam(:path) do
desc "The search path used for command (keytool, openssl) execution.
Paths can be specified as an array or as a '#{File::PATH_SEPARATOR}' separated list."

# Support both arrays and colon-separated fields.
def value=(*values)
@value = values.flatten.collect { |val|
val.split(File::PATH_SEPARATOR)
}.flatten
end
# Support both arrays and colon-separated fields.
def value=(*values)
@value = values.flatten.collect { |val|
val.split(File::PATH_SEPARATOR)
}.flatten
end
end

# Where we setup autorequires.
autorequire(:file) do
auto_requires = []
[:private_key, :certificate, :chain].each do |param|
if @parameters.include?(param)
auto_requires << @parameters[param].value
end
# Where we setup autorequires.
autorequire(:file) do
auto_requires = []
[:private_key, :certificate, :chain].each do |param|
if @parameters.include?(param)
auto_requires << @parameters[param].value
end
if @parameters.include?(:target)
auto_requires << ::File.dirname(@parameters[:target].value)
end
auto_requires
end
if @parameters.include?(:target)
auto_requires << ::File.dirname(@parameters[:target].value)
end
auto_requires
end

# Our title_patterns method for mapping titles to namevars for supporting
# composite namevars.
def self.title_patterns
identity = lambda {|x| x}
# Our title_patterns method for mapping titles to namevars for supporting
# composite namevars.
def self.title_patterns
identity = lambda {|x| x}
[
[
/^([^:]+)$/,
[
/^([^:]+)$/,
[
[ :name, identity ]
]
],
[ :name, identity ]
]
],
[
/^(.*):(.*)$/,
[
/^(.*):(.*)$/,
[
[ :name, identity ],
[ :target, identity ]
]
[ :name, identity ],
[ :target, identity ]
]
]
end
]
end

validate do
if value(:password) and value(:password_file)
self.fail "You must pass either 'password' or 'password_file', not both."
end
validate do
if value(:password) and value(:password_file)
self.fail "You must pass either 'password' or 'password_file', not both."
end

unless value(:password) or value(:password_file)
self.fail "You must pass one of 'password' or 'password_file'."
end
unless value(:password) or value(:password_file)
self.fail "You must pass one of 'password' or 'password_file'."
end
end
end
7 changes: 4 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-java_ks",
"version": "1.3.0",
"version": "1.3.1",
"author": "puppetlabs",
"summary": "Manage arbitrary Java keystore files",
"license": "Apache-2.0",
Expand Down Expand Up @@ -93,14 +93,15 @@
"requirements": [
{
"name": "pe",
"version_requirement": "3.x"
"version_requirement": ">= 3.0.0 < 2015.3.0"
},
{
"name": "puppet",
"version_requirement": "3.x"
"version_requirement": ">= 3.0.0 < 5.0.0"
}
],
"description": "Uses a combination of keytool and Ruby openssl library to manage entries in a Java keystore.",
"dependencies": [

]
}
Loading