Updated Branches:
  refs/heads/master 02d111432 -> 3d27c14d4

applying patch gitven by Chanaka for STRATOS-422


Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/3d27c14d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/3d27c14d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/3d27c14d

Branch: refs/heads/master
Commit: 3d27c14d4ace29b5d5492923bdd752f3be76bf51
Parents: 02d1114
Author: rekathiru <[email protected]>
Authored: Mon Feb 10 15:26:40 2014 +0530
Committer: rekathiru <[email protected]>
Committed: Mon Feb 10 15:26:40 2014 +0530

----------------------------------------------------------------------
 .../console/config/console.js                   | 23 +++++++++++++++-----
 .../console/config/console.json                 |  8 +++----
 .../console/controllers/login.jag               |  2 +-
 .../console/controllers/logout.jag              |  5 +++--
 .../console/controllers/router.jag              | 19 +++++++++++++++-
 5 files changed, 43 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3d27c14d/components/org.apache.stratos.manager.console/console/config/console.js
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/config/console.js 
b/components/org.apache.stratos.manager.console/console/config/console.js
index 7f72b0a..cc86d9a 100644
--- a/components/org.apache.stratos.manager.console/console/config/console.js
+++ b/components/org.apache.stratos.manager.console/console/config/console.js
@@ -1,8 +1,19 @@
-var config;
-(function () {
-    config = function () {
-        var config = require('/config/console.json'),
-            process = require('process');
+var config = function () {
+        var log = new Log(),
+            pinch = require('/modules/pinch.min.js').pinch,
+            config = require('/config/console.json'),
+            process = require('process'),
+            localIP = process.getProperty('server.host'),
+            httpPort = process.getProperty('http.port'),
+            httpsPort = process.getProperty('https.port');
+
+        pinch(config, /^/, function (path, key, value) {
+            if ((typeof value === 'string') && value.indexOf('%https.host%') > 
-1) {
+                return value.replace('%https.host%', 'https://' + localIP + 
':' + httpsPort);
+            } else if ((typeof value === 'string') && 
value.indexOf('%http.host%') > -1) {
+                return value.replace('%http.host%', 'http://' + localIP + ':' 
+ httpPort);
+            }
+            return  value;
+        });
         return config;
     };
-})();

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3d27c14d/components/org.apache.stratos.manager.console/console/config/console.json
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/config/console.json 
b/components/org.apache.stratos.manager.console/console/config/console.json
index 049fa30..1d415b8 100644
--- a/components/org.apache.stratos.manager.console/console/config/console.json
+++ b/components/org.apache.stratos.manager.console/console/config/console.json
@@ -1,22 +1,22 @@
 {
     "backendServerConfiguration":{
-        "url":"https://localhost:9445/stratos/admin";
+        "url":"%https.host%/stratos/admin"
     },
 
     "oauthConfiguration":{
         "clientId":"",
         "clientSecret":"",
-        "tokenEndpoint":"https://localhost:9445/oauth2/token";
+        "tokenEndpoint":"%https.host%/oauth2/token"
     },
 
     "ssoConfiguration": {
         "enabled": false,
         "issuer": "console",
-        "identityProviderURL": "https://localhost:9446/sso/samlsso.jag";,
+        "identityProviderURL": "%https.host%/sso/samlsso.jag",
         "keyStorePassword": "wso2carbon",
         "identityAlias": "wso2carbon",
         "responseSigningEnabled": "true",
-        "storeAcs" : "https://localhost:9443/console/controllers/acs";,
+        "storeAcs" : "%https.host%/console/controllers/acs",
         "keyStoreName": "/repository/resources/security/wso2carbon.jks"
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3d27c14d/components/org.apache.stratos.manager.console/console/controllers/login.jag
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/controllers/login.jag 
b/components/org.apache.stratos.manager.console/console/controllers/login.jag
index ca4d54c..c74b368 100755
--- 
a/components/org.apache.stratos.manager.console/console/controllers/login.jag
+++ 
b/components/org.apache.stratos.manager.console/console/controllers/login.jag
@@ -1,7 +1,7 @@
 <%
 (function(){
     var log = new Log("controllers.login.jag");
-    var dataConfig = require('/config/console.json');
+    var dataConfig = require('/config/console.js').config();
     if(!dataConfig.ssoConfiguration.enabled){
         request.getMappedPath = function() {
             return '/login.jag'; // setting path for caramel framework

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3d27c14d/components/org.apache.stratos.manager.console/console/controllers/logout.jag
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/controllers/logout.jag 
b/components/org.apache.stratos.manager.console/console/controllers/logout.jag
index 67ecfc9..10ca8af 100755
--- 
a/components/org.apache.stratos.manager.console/console/controllers/logout.jag
+++ 
b/components/org.apache.stratos.manager.console/console/controllers/logout.jag
@@ -2,7 +2,8 @@
 (function(){
     var log = new Log('controllers.logout');
     var user = 
require('console').server.current(session).username;//session.get("LOGGED_IN_USER");
-    var dataConfig = require('/config/console.json');
+    var dataConfig = require('/config/console.js').config();
+
     if(user === null) {
         response.sendRedirect('/portal');
     } else if(!dataConfig.ssoConfiguration.enabled){
@@ -10,7 +11,7 @@
         session.invalidate();
         response.sendRedirect(request.getContextPath());
     }else{
-        var config = require('/console.json'),
+        var config = require('/config/console.js').config(),
                 sso = require('sso'),
                 sso_sessions = application.get('sso_sessions'),
                 sessionId = session.getId(),

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/3d27c14d/components/org.apache.stratos.manager.console/console/controllers/router.jag
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager.console/console/controllers/router.jag 
b/components/org.apache.stratos.manager.console/console/controllers/router.jag
index 04a4153..7d2cdb4 100755
--- 
a/components/org.apache.stratos.manager.console/console/controllers/router.jag
+++ 
b/components/org.apache.stratos.manager.console/console/controllers/router.jag
@@ -1,7 +1,24 @@
 <%
 
 (function(){
-    var config=require('/config/console.json');
+    var carbon = require('carbon');
+    var conf = carbon.server.loadConfig('carbon.xml');
+    var offset = conf.*::['Ports'].*::['Offset'].text();
+    var hostName = conf.*::['HostName'].text().toString();
+
+    if (hostName === null || hostName === '') {
+        hostName = 'localhost';
+    }
+
+    var httpPort = 9763 + parseInt(offset, 10);
+    var httpsPort = 9443 + parseInt(offset, 10);
+
+    var process = require('process');
+    process.setProperty('server.host', hostName);
+    process.setProperty('http.port', httpPort.toString());
+    process.setProperty('https.port', httpsPort.toString());
+
+    var config=require('/config/console.js').config();
     var log = new Log("controller.router");
     var acl = require('/util/acl.jag');
 

Reply via email to