Skip to content

Commit

Permalink
Merge pull request #48 from boorad/jce
Browse files Browse the repository at this point in the history
Optionally install Java Cryptography Extension (JCE)
  • Loading branch information
tylerwalts committed Jul 20, 2015
2 parents 893b9d1 + 5e867fc commit 22faf1a
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ site.pp:
* Optionally host the installer file locally instead of fetching it each time, for faster dev & test
* platform
* The platform to use
* jce
* Boolean to optionally install Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files (Java 8 only)
* default_java
* Boolean to indicate if the installed java version is linked as the default java, javac etc...
* ensure
* Boolean to disable anything from happening (absent/removal not supported yet)


92 changes: 87 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
# String. The platform to use
# Defaults to <tt>x64</tt>.
#
# [* jce *]
# Boolean. Optionally install Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files
# Defaults to <tt>false</tt>.
#
# [* default_java *]
# Boolean. If the installed java version is linked as the default java, javac etc...
# Defaults to <tt>true</tt>.
Expand All @@ -46,6 +50,7 @@
$use_cache = hiera('jdk_oracle::use_cache', false ),
$cache_source = 'puppet:///modules/jdk_oracle/',
$platform = hiera('jdk_oracle::platform', 'x64' ),
$jce = hiera('jdk_oracle::jce', false ),
$default_java = hiera('jdk_oracle::default_java', true ),
$ensure = 'installed'
) {
Expand Down Expand Up @@ -81,6 +86,7 @@
}
$javaDownloadURI = "http://download.oracle.com/otn-pub/java/jdk/${version}u${version_u}-b${version_b}/jdk-${version}u${version_u}-linux-${plat_filename}.tar.gz"
$java_home = "${install_dir}/jdk1.${version}.0_${version_u}"
$jceDownloadURI = 'http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip'
}
'7': {
if ($version_update != 'default'){
Expand Down Expand Up @@ -147,11 +153,6 @@
require => Exec['get_jdk_installer'],
}

if ! defined(Package['wget']) {
package { 'wget':
ensure => present,
}
}
}

# Java 7/8 comes in a tarball so just extract it.
Expand Down Expand Up @@ -263,5 +264,86 @@

default: { fail("Unsupported OS: ${::osfamily}. Implement me?") }
}

if ( $jce and $version == '8' ) {

$jceFilename = inline_template('<%= File.basename(@jceDownloadURI) %>')
$jce_dir = 'UnlimitedJCEPolicyJDK8'

if ( $use_cache ) {
file { "${install_dir}/${jceFilename}":
source => "${cache_source}${jceFilename}",
require => File[$install_dir],
} ->
exec { 'get_jce_package':
cwd => $install_dir,
creates => "${install_dir}/jce_from_cache",
command => 'touch jce_from_cache',
}
} else {
exec { 'get_jce_package':
cwd => $install_dir,
creates => "${install_dir}/${jceFilename}",
command => "wget -c --no-cookies --no-check-certificate --header \"Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com\" --header \"Cookie: oraclelicense=accept-securebackup-cookie\" \"${jceDownloadURI}\" -O ${jceFilename}",
timeout => 600,
require => Package['wget'],
}

file { "${install_dir}/${jceFilename}":
mode => '0755',
require => Exec['get_jce_package'],
}

}

exec { 'extract_jce':
cwd => "${install_dir}/",
command => "unzip ${jceFilename}",
creates => "${install_dir}/${jce_dir}",
require => [ Exec['get_jce_package'], Package['unzip'] ],
}

file { "${java_home}/jre/lib/security/README.txt":
ensure => 'present',
source => "${install_dir}/${jce_dir}/README.txt",
mode => '0644',
owner => 'root',
group => 'root',
require => Exec['extract_jce'],
}

file { "${java_home}/jre/lib/security/local_policy.jar":
ensure => 'present',
source => "${install_dir}/${jce_dir}/local_policy.jar",
mode => '0644',
owner => 'root',
group => 'root',
require => Exec['extract_jce'],
}

file { "${java_home}/jre/lib/security/US_export_policy.jar":
ensure => 'present',
source => "${install_dir}/${jce_dir}/US_export_policy.jar",
mode => '0644',
owner => 'root',
group => 'root',
require => Exec['extract_jce'],
}

}

}

if ! defined(Package['wget']) {
package { 'wget':
ensure => present,
}
}

if ! defined(Package['unzip']) {
package { 'unzip':
ensure => present,
}
}

}

0 comments on commit 22faf1a

Please sign in to comment.