-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add Dyadic EKM buildpack #365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Cloud Foundry Java Buildpack | ||
| # Copyright 2013-2016 the original author or authors. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Configuration for the Luna Security Provider framework | ||
| --- | ||
| version: 1.+ | ||
| repository_root: https://repo.dyadicsec.com/cust/pcf | ||
| logging_enabled: false | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| # Encoding: utf-8 | ||
| # Cloud Foundry Java Buildpack | ||
| # Copyright 2013-2016 the original author or authors. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| require 'fileutils' | ||
| require 'java_buildpack/component/versioned_dependency_component' | ||
| require 'java_buildpack/framework' | ||
| require 'java_buildpack/util/qualify_path' | ||
|
|
||
| module JavaBuildpack | ||
| module Framework | ||
|
|
||
| # Encapsulates the functionality for enabling zero-touch Dyadic EKM Java Security Provider support. | ||
| class DyadicEkmSecurityProvider < JavaBuildpack::Component::VersionedDependencyComponent | ||
| include JavaBuildpack::Util | ||
|
|
||
| # (see JavaBuildpack::Component::BaseComponent#compile) | ||
| def compile | ||
| download_tar | ||
| setup_ext_dir | ||
|
|
||
| @droplet.copy_resources | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file generally needs a reformat. If you're using IntelliJ, we've checked the formatting rules into source control, so you can use the code formatter there to fix it all to our standard. |
||
|
|
||
| credentials = @application.services.find_service(FILTER)['credentials'] | ||
| write_key credentials['key'] | ||
| write_cert credentials['ca'] | ||
| write_conf credentials['servers'], credentials['send_timeout'], credentials['recv_timeout'], credentials['retries'] | ||
| end | ||
|
|
||
| # (see JavaBuildpack::Component::BaseComponent#release) | ||
| def release | ||
| @droplet | ||
| .java_opts | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the |
||
| .add_system_property('java.library.path', @droplet.sandbox + 'usr/lib') | ||
| @droplet.environment_variables.add_environment_variable 'LD_LIBRARY_PATH', @droplet.sandbox + 'usr/lib' | ||
|
|
||
| @droplet | ||
| .java_opts | ||
| .add_system_property('java.security.properties', @droplet.sandbox + 'java.security') | ||
| .add_system_property('java.ext.dirs', ext_dirs) | ||
| end | ||
|
|
||
| protected | ||
|
|
||
| # (see JavaBuildpack::Component::VersionedDependencyComponent#supports?) | ||
| def supports? | ||
| @application.services.one_service? FILTER | ||
| #true | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove commented out code. |
||
| end | ||
|
|
||
| private | ||
|
|
||
| FILTER = /dyadic/ | ||
|
|
||
| private_constant :FILTER | ||
|
|
||
| def ext_dir | ||
| @droplet.sandbox + 'ext' | ||
| end | ||
|
|
||
| def dyadic_jar | ||
| @droplet.sandbox + 'usr/lib/dsm/dsm-advapi-1.0.jar' | ||
| end | ||
|
|
||
| def setup_ext_dir | ||
| FileUtils.mkdir ext_dir | ||
| FileUtils.ln_s dyadic_jar.relative_path_from(ext_dir), ext_dir, force: true | ||
| end | ||
|
|
||
| def ext_dirs | ||
| "#{qualify_path(@droplet.java_home.root + 'lib/ext', @droplet.root)}:" \ | ||
| "#{qualify_path(ext_dir, @droplet.root)}" | ||
| end | ||
|
|
||
| def key_file | ||
| @droplet.sandbox + 'etc/dsm/key.pem' | ||
| end | ||
|
|
||
| def cert_file | ||
| @droplet.sandbox + 'etc/dsm/ca.crt' | ||
| end | ||
|
|
||
| def conf_file | ||
| @droplet.sandbox + 'etc/dsm/client.conf' | ||
| end | ||
|
|
||
| def write_key(key) | ||
| key_file.open(File::CREAT | File::WRONLY) do |f| | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to ensure that the parent directory exists before writing with |
||
| f.write key | ||
| end | ||
| end | ||
|
|
||
| def write_cert(cert) | ||
| cert_file.open(File::CREAT | File::WRONLY) do |f| | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to ensure that the parent directory exists before writing with |
||
| f.write cert | ||
| end | ||
| end | ||
|
|
||
| def write_conf(servers,send_timeout,recv_timeout,retries) | ||
| conf_file.open(File::CREAT | File::WRONLY) do |f| | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to ensure that the parent directory exists before writing with |
||
| f.write "servers = " + servers + "\n" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This multiline string can be rewritten as a single Ruby multi-line interpolation like: f.write <<EOS
servers = #{servers}
send_timeout = #{send_timeout}
recv_timeout = #{recv_timeout}
retries = #{retries}
EOS |
||
| f.write "send_timeout = " + send_timeout + "\n" | ||
| f.write "recv_timeout = " + recv_timeout + "\n" | ||
| f.write "retries = " + retries + "\n" | ||
| end | ||
| end | ||
|
|
||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| security.provider.10=com.dyadicsec.provider.DYCryptoProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe that you've added support for configuring logging, so this entry can be removed.