Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 88AC9200CEE for ; Mon, 17 Jul 2017 14:45:59 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 87650164E49; Mon, 17 Jul 2017 12:45:59 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E51AF164E30 for ; Mon, 17 Jul 2017 14:45:57 +0200 (CEST) Received: (qmail 51029 invoked by uid 500); 17 Jul 2017 12:45:57 -0000 Mailing-List: contact commits-help@polygene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@polygene.apache.org Delivered-To: mailing list commits@polygene.apache.org Received: (qmail 50575 invoked by uid 99); 17 Jul 2017 12:45:56 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Jul 2017 12:45:56 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5AF06F3251; Mon, 17 Jul 2017 12:45:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: paulmerlin@apache.org To: commits@polygene.apache.org Date: Mon, 17 Jul 2017 12:46:29 -0000 Message-Id: In-Reply-To: <3fd3094d4e4342f1bf72e281f66a5cca@git.apache.org> References: <3fd3094d4e4342f1bf72e281f66a5cca@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [37/50] [abbrv] polygene-java git commit: Keystore issues. Fixed. archived-at: Mon, 17 Jul 2017 12:45:59 -0000 Keystore issues. Fixed. Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/fde12959 Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/fde12959 Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/fde12959 Branch: refs/heads/master Commit: fde12959240ce2641c35ab8decfd94176389e16c Parents: 29ecdba Author: niclas Authored: Sat Jul 15 18:15:06 2017 +0800 Committer: niclas Committed: Sat Jul 15 18:15:06 2017 +0800 ---------------------------------------------------------------------- tools/generator-polygene/app/index.js | 11 +++++++++++ .../HttpServerModule/bootstrap.tmpl | 19 ++++++++++++++----- .../app/templates/RestAPIApplication/app.js | 3 ++- .../app/templates/buildtool/build.js | 4 ++-- 4 files changed, 29 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/polygene-java/blob/fde12959/tools/generator-polygene/app/index.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/index.js b/tools/generator-polygene/app/index.js index 434e74e..9d220a7 100644 --- a/tools/generator-polygene/app/index.js +++ b/tools/generator-polygene/app/index.js @@ -312,6 +312,17 @@ function assignFunctions(polygene) { } }; + polygene.copyBinary = function (ctx, from, to) { + + try { + ctx.fs.copy( + ctx.templatePath(from), + ctx.destinationPath(to)); + } catch (exception) { + console.log("Unable to copy binary: " + from + " to " + to + "\n", exception); + } + }; + polygene.copyPolygeneBootstrap = function (ctx, layer, moduleName, condition) { if (condition) { copyTemplate(ctx, http://git-wip-us.apache.org/repos/asf/polygene-java/blob/fde12959/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/bootstrap.tmpl ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/bootstrap.tmpl b/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/bootstrap.tmpl index 744d8fd..addab42 100644 --- a/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/bootstrap.tmpl +++ b/tools/generator-polygene/app/templates/ConnectivityLayer/HttpServerModule/bootstrap.tmpl @@ -22,6 +22,7 @@ package <%= polygene.packageName %>.bootstrap.connectivity; import java.util.HashMap; <% if( hasFeature('security') ) { %> import java.io.File; +import java.net.URL; import org.apache.polygene.library.http.SecureJettyConfiguration; import org.apache.polygene.library.http.SecureJettyServiceAssembler; import org.apache.polygene.library.shiro.web.assembly.HttpShiroAssembler; @@ -46,10 +47,10 @@ public class HttpServerModule implements ModuleAssembler {<% if( hasFeature('security') ) { %> private static final int DEFAULT_PORT = 8443; - public static final String KS_PASSWORD = "1234"; // TODO: Secure the key stores - public static final String SERVER_KEYSTORE_FILENAME = "security/<%= polygene.name.toLowerCase() %>-app.p12"; + public static final String KS_PASSWORD = "123456"; // TODO: Secure the key stores + public static final String SERVER_KEYSTORE_FILENAME = "security/keystore-<%= polygene.name.toLowerCase() %>.p12"; public static final String SERVER_KEYSTORE_TYPE = "PKCS12"; - public static final String TRUSTSTORE_FILENAME = "security/<%= polygene.name.toLowerCase() %>-app.p12"; + public static final String TRUSTSTORE_FILENAME = "security/keystore-<%= polygene.name.toLowerCase() %>.p12"; public static final String TRUSTSTORE_TYPE = "PKCS12"; <% } else { %> protected static final int DEFAULT_PORT = 8080; @@ -70,10 +71,18 @@ public class HttpServerModule .visibleIn( Visibility.layer ) .assemble( module ); SecureJettyConfiguration defaults = module.forMixin( SecureJettyConfiguration.class ).declareDefaults(); - defaults.keystorePath().set( new File( SERVER_KEYSTORE_FILENAME ).getAbsolutePath() ); + URL keyStoreResource = getClass().getClassLoader().getResource( SERVER_KEYSTORE_FILENAME ); + if( keyStoreResource != null ) + { + defaults.keystorePath().set( keyStoreResource.toExternalForm() ); + } defaults.keystoreType().set( SERVER_KEYSTORE_TYPE ); defaults.keystorePassword().set( KS_PASSWORD ); - defaults.truststorePath().set( new File( TRUSTSTORE_FILENAME ).getAbsolutePath() ); + URL trustStoreResource = getClass().getClassLoader().getResource( TRUSTSTORE_FILENAME ); + if( trustStoreResource != null ) + { + defaults.truststorePath().set( trustStoreResource.toExternalForm() ); + } defaults.truststoreType().set( TRUSTSTORE_TYPE ); defaults.truststorePassword().set( KS_PASSWORD ); defaults.wantClientAuth().set( Boolean.FALSE ); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/fde12959/tools/generator-polygene/app/templates/RestAPIApplication/app.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/RestAPIApplication/app.js b/tools/generator-polygene/app/templates/RestAPIApplication/app.js index 03ddff9..106bb2d 100644 --- a/tools/generator-polygene/app/templates/RestAPIApplication/app.js +++ b/tools/generator-polygene/app/templates/RestAPIApplication/app.js @@ -34,7 +34,8 @@ module.exports = { if (p.hasFeature('security')) { p.copyToConfig(p.ctx, 'RestAPIApplication/web-shiro.ini.tmpl', 'web-shiro.ini'); - p.copyToConfig(p.ctx, 'RestAPIApplication/dev-keystore.p12', 'security/keystore-' + p.name + '.p12'); + p.copyBinary(p.ctx, 'RestAPIApplication/dev-keystore.p12', 'app/src/dist/config/development/security/keystore-' + p.name.toLowerCase() + '.p12'); + p.copyBinary(p.ctx, 'RestAPIApplication/dev-keystore.p12', 'app/src/test/resources/security/keystore-' + p.name.toLowerCase() + '.p12'); } p.copyTemplate(p.ctx, http://git-wip-us.apache.org/repos/asf/polygene-java/blob/fde12959/tools/generator-polygene/app/templates/buildtool/build.js ---------------------------------------------------------------------- diff --git a/tools/generator-polygene/app/templates/buildtool/build.js b/tools/generator-polygene/app/templates/buildtool/build.js index 17c0a68..dbd3ac3 100644 --- a/tools/generator-polygene/app/templates/buildtool/build.js +++ b/tools/generator-polygene/app/templates/buildtool/build.js @@ -30,8 +30,8 @@ module.exports = { p.copyTemplate(p.ctx, 'buildtool/wrapper/gradlew.tmpl', 'gradlew'); p.copyTemplate(p.ctx, 'buildtool/wrapper/gradlew-bat.tmpl', 'gradlew.bat'); - p.ctx.fs.copy(p.ctx.templatePath('buildtool/wrapper/gradle-wrapper.jar_'), p.ctx.destinationPath('gradle/wrapper/gradle-wrapper.jar')); - p.ctx.fs.copy(p.ctx.templatePath('buildtool/wrapper/gradle-wrapper.properties_'), p.ctx.destinationPath('gradle/wrapper/gradle-wrapper.properties')); + p.copyBinary(p.ctx, 'buildtool/wrapper/gradle-wrapper.jar_', 'gradle/wrapper/gradle-wrapper.jar'); + p.copyBinary(p.ctx, 'buildtool/wrapper/gradle-wrapper.properties_','gradle/wrapper/gradle-wrapper.properties'); } };