Skip to content

Commit 8a15b65

Browse files
Jonathan Patchellnebhale
authored andcommitted
Luna Security Provider, Minimal Install
This change updates the Luna Security Provider to support the new Minimal Client Installer. It also updates the code to depend on the 6.+ versions of the client. [cloudfoundry#296]
1 parent c4dc3e4 commit 8a15b65

4 files changed

Lines changed: 32 additions & 128 deletions

File tree

config/components.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ frameworks:
4343
# - "JavaBuildpack::Framework::IntroscopeAgent"
4444
- "JavaBuildpack::Framework::Jmx"
4545
- "JavaBuildpack::Framework::JrebelAgent"
46-
# - "JavaBuildpack::Framework::LunaSecurityProvider"
46+
- "JavaBuildpack::Framework::LunaSecurityProvider"
4747
- "JavaBuildpack::Framework::MariaDbJDBC"
4848
- "JavaBuildpack::Framework::NewRelicAgent"
4949
- "JavaBuildpack::Framework::PlayFrameworkAutoReconfiguration"

config/luna_security_provider.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
# Configuration for the Dynatrace framework
16+
# Configuration for the Luna Security Provider framework
1717
---
18-
version: 5.+
19-
repository_root: ""
18+
version: 6.+
19+
repository_root: "http://files.cf-hsm.io/luna-installer"
2020
logging_enabled: false

lib/java_buildpack/framework/luna_security_provider.rb

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ class LunaSecurityProvider < JavaBuildpack::Component::VersionedDependencyCompon
2828

2929
# (see JavaBuildpack::Component::BaseComponent#compile)
3030
def compile
31-
download(@version, @uri) { |file| expand file }
31+
32+
download_tar
33+
setup_ext_dir
34+
3235
@droplet.copy_resources
3336

3437
credentials = @application.services.find_service(FILTER)['credentials']
@@ -63,10 +66,6 @@ def chrystoki
6366
@droplet.sandbox + 'Chrystoki.conf'
6467
end
6568

66-
def cklog(root)
67-
Dir[root + 'cklog-*.x86_64.rpm'][0]
68-
end
69-
7069
def client_certificate
7170
@droplet.sandbox + 'usr/safenet/lunaclient/cert/client/client-certificate.pem'
7271
end
@@ -75,49 +74,43 @@ def client_private_key
7574
@droplet.sandbox + 'usr/safenet/lunaclient/cert/client/client-private-key.pem'
7675
end
7776

78-
def expand(file)
79-
with_timing "Expanding Luna Client to #{@droplet.sandbox.relative_path_from(@droplet.root)}" do
80-
Dir.mktmpdir do |root|
81-
root = Pathname.new(root)
82-
83-
FileUtils.mkdir_p root
84-
shell "tar x#{compression_flag(file)}f #{file.path} -C #{root} --strip 3 2>&1"
77+
def ext_dir
78+
@droplet.sandbox + 'ext'
79+
end
8580

86-
install_client root
87-
end
88-
end
81+
def luna_provider_jar
82+
@droplet.sandbox + 'jsp/LunaProvider.jar'
8983
end
9084

91-
def ext_dirs
92-
"#{qualify_path(@droplet.java_home.root + 'lib/ext', @droplet.root)}:" \
93-
"#{qualify_path(@droplet.sandbox + 'usr/safenet/lunaclient/jsp/lib', @droplet.root)}"
85+
def luna_api_so
86+
@droplet.sandbox + 'jsp/64/libLunaAPI.so'
9487
end
9588

96-
def install_client(root)
97-
FileUtils.mkdir_p @droplet.sandbox
89+
def lib_cryptoki
90+
@droplet.sandbox + 'libs/64/libCryptoki2.so'
91+
end
9892

99-
Dir.chdir(@droplet.sandbox) do
100-
shell "#{rpm2cpio} < #{libcrpytoki root} | cpio -id ./usr/safenet/lunaclient/lib/libCryptoki2_64.so"
101-
shell "#{rpm2cpio} < #{lunajsp root} | cpio -id ./usr/safenet/lunaclient/jsp/lib/*"
93+
def lib_cklog
94+
sandbox + 'libs/64/libcklog2.so'
95+
end
10296

103-
if logging?
104-
shell "#{rpm2cpio} < #{cklog root} | cpio -id ./usr/safenet/lunaclient/lib/libcklog2.so"
105-
end
97+
def setup_ext_dir
98+
FileUtils.mkdir ext_dir
99+
files = [luna_provider_jar, luna_api_so]
100+
files.each do |file|
101+
FileUtils.ln_s file.relative_path_from(ext_dir), ext_dir, :force => true
106102
end
107103
end
108104

109-
def libcrpytoki(root)
110-
Dir[root + 'libcryptoki-*.x86_64.rpm'][0]
105+
def ext_dirs
106+
"#{qualify_path(@droplet.java_home.root + 'lib/ext', @droplet.root)}:" \
107+
"#{qualify_path(ext_dir, @droplet.root)}"
111108
end
112109

113110
def logging?
114111
@configuration['logging_enabled']
115112
end
116113

117-
def lunajsp(root)
118-
Dir[root + 'lunajsp-*.x86_64.rpm'][0]
119-
end
120-
121114
def padded_index(index)
122115
index.to_s.rjust(2, '0')
123116
end
@@ -126,10 +119,6 @@ def relative(path)
126119
path.relative_path_from(@droplet.root)
127120
end
128121

129-
def rpm2cpio
130-
Pathname.new(File.expand_path('../rpm2cpio.py', __FILE__))
131-
end
132-
133122
def server_certificates
134123
@droplet.sandbox + 'usr/safenet/lunaclient/cert/server/server-certificates.pem'
135124
end
@@ -191,20 +180,20 @@ def write_lib(f)
191180
write_logging(f)
192181
else
193182
f.write <<EOS
194-
LibUNIX64 = #{relative(@droplet.sandbox + 'usr/safenet/lunaclient/lib/libCryptoki2_64.so')};
183+
LibUNIX64 = #{relative(lib_cryptoki)};
195184
}
196185
EOS
197186
end
198187
end
199188

200189
def write_logging(f)
201190
f.write <<EOS
202-
LibUNIX64 = #{relative(@droplet.sandbox + 'usr/safenet/lunaclient/lib/libcklog2.so')};
191+
LibUNIX64 = #{relative(lib_cklog)};
203192
}
204193
205194
CkLog2 = {
206195
Enabled = 1;
207-
LibUNIX64 = #{relative(@droplet.sandbox + 'usr/safenet/lunaclient/lib/libCryptoki2_64.so')};
196+
LibUNIX64 = #{relative(lib_cryptoki)};
208197
LoggingMask = ALL_FUNC;
209198
LogToStreams = 1;
210199
NewFormat = 1;

lib/java_buildpack/framework/rpm2cpio.py

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)