polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject [37/50] [abbrv] polygene-java git commit: Keystore issues. Fixed.
Date Mon, 17 Jul 2017 12:46:29 GMT
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 <niclas@hedhman.org>
Authored: Sat Jul 15 18:15:06 2017 +0800
Committer: niclas <niclas@hedhman.org>
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');
     }
 };
 


Mime
View raw message