airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [1/3] airavata git commit: AIRAVATA-2431 Fix creating Keycloak admin user
Date Thu, 08 Jun 2017 16:27:46 GMT
Repository: airavata
Updated Branches:
  refs/heads/develop ff3fc16dd -> f52024fe8


AIRAVATA-2431 Fix creating Keycloak admin user

Not all legacy gateway DB entries have admin username, first name, last
name, or email address, but these are needed in order to automatically
create the admin user for the Keycloak realm.


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/de45cba1
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/de45cba1
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/de45cba1

Branch: refs/heads/develop
Commit: de45cba140cba1bc2af3f230afaa1d82e943e4dc
Parents: ff3fc16
Author: Marcus Christie <machristie@apache.org>
Authored: Wed Jun 7 16:10:49 2017 -0400
Committer: Marcus Christie <machristie@apache.org>
Committed: Wed Jun 7 16:10:49 2017 -0400

----------------------------------------------------------------------
 .../org/apache/airavata/MigrationManager.java   | 28 +++++++++++++++++++-
 .../user-profile-migration.properties.template  |  4 +++
 2 files changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/de45cba1/modules/user-profile-migration/src/main/java/org/apache/airavata/MigrationManager.java
----------------------------------------------------------------------
diff --git a/modules/user-profile-migration/src/main/java/org/apache/airavata/MigrationManager.java
b/modules/user-profile-migration/src/main/java/org/apache/airavata/MigrationManager.java
index 0f0175d..b8baeaf 100644
--- a/modules/user-profile-migration/src/main/java/org/apache/airavata/MigrationManager.java
+++ b/modules/user-profile-migration/src/main/java/org/apache/airavata/MigrationManager.java
@@ -58,7 +58,6 @@ public class MigrationManager {
     private int airavataServiceServerPort = 8930;
     private Map<String,String> roleConversionMap = createDefaultRoleConversionMap();
     private String gatewayId = "gateway-id";
-    private String gatewayURL = "http://localhost";
     private String wso2ISAdminUsername = "username";
     private String wso2ISAdminPassword = "password";
     private String keycloakServiceURL = "https://iam.scigap.org/auth";
@@ -67,10 +66,20 @@ public class MigrationManager {
     private String keycloakTrustStorePath = "../../modules/configuration/server/src/main/resources/client_truststore.jks";
     private String keycloakTrustStorePassword = "password";
     private String keycloakTemporaryUserPassword = "tempPassword";
+    // For some gateways in the legacy gateways table, the following information is missing
and needs to be provided
+    private String gatewayURL = "http://localhost";
+    private String gatewayAdminUsername = "admin";
+    private String gatewayAdminFirstName = "Admin";
+    private String gatewayAdminLastName = "User";
+    private String gatewayAdminEmailAddress = "sgg@iu.edu";
 
     // Names of properties in user-profile-migration.properties.template
     private final static String GATEWAY_ID = "gateway-id";
     private final static String GATEWAY_URL = "gateway.url";
+    private final static String GATEWAY_ADMIN_USERNAME = "gateway.admin.username";
+    private final static String GATEWAY_ADMIN_FIRST_NAME = "gateway.admin.first.name";
+    private final static String GATEWAY_ADMIN_LAST_NAME = "gateway.admin.last.name";
+    private final static String GATEWAY_ADMIN_EMAIL_ADDRESS = "gateway.admin.email.address";
     private final static String WSO2IS_ADMIN_USERNAME = "wso2is.admin.username";
     private final static String WSO2IS_ADMIN_PASSWORD = "wso2is.admin.password";
     private final static String WSO2IS_ADMIN_ROLENAME = "wso2is.admin.rolename";
@@ -233,6 +242,19 @@ public class MigrationManager {
         if (gateway.getGatewayURL() == null) {
             gateway.setGatewayURL(this.gatewayURL);
         }
+        // Following are also required by IAM Admin Services in order to create an admin
user for the realm
+        if (gateway.getIdentityServerUserName() == null) {
+            gateway.setIdentityServerUserName(this.gatewayAdminUsername);
+        }
+        if (gateway.getGatewayAdminFirstName() == null) {
+            gateway.setGatewayAdminFirstName(this.gatewayAdminFirstName);
+        }
+        if (gateway.getGatewayAdminLastName() == null) {
+            gateway.setGatewayAdminLastName(this.gatewayAdminLastName);
+        }
+        if (gateway.getGatewayAdminEmail() == null) {
+            gateway.setGatewayAdminEmail(this.gatewayAdminEmailAddress);
+        }
 
         // Add Keycloak Tenant for Gateway
         System.out.println("Creating Keycloak Tenant for gateway ...");
@@ -288,6 +310,10 @@ public class MigrationManager {
             // Load values from properties if they exist, otherwise will just use default
values
             this.gatewayId = properties.getProperty(GATEWAY_ID, this.gatewayId);
             this.gatewayURL = properties.getProperty(GATEWAY_URL, this.gatewayURL);
+            this.gatewayAdminUsername = properties.getProperty(GATEWAY_ADMIN_USERNAME, this.gatewayAdminUsername);
+            this.gatewayAdminFirstName = properties.getProperty(GATEWAY_ADMIN_FIRST_NAME,
this.gatewayAdminFirstName);
+            this.gatewayAdminLastName = properties.getProperty(GATEWAY_ADMIN_LAST_NAME, this.gatewayAdminLastName);
+            this.gatewayAdminEmailAddress = properties.getProperty(GATEWAY_ADMIN_EMAIL_ADDRESS,
this.gatewayAdminEmailAddress);
             this.wso2ISAdminUsername = properties.getProperty(WSO2IS_ADMIN_USERNAME, this.wso2ISAdminUsername);
             this.wso2ISAdminPassword = properties.getProperty(WSO2IS_ADMIN_PASSWORD, this.wso2ISAdminPassword);
             this.airavataServiceServerHost = properties.getProperty(AIRAVATA_SERVICE_HOST,
this.airavataServiceServerHost);

http://git-wip-us.apache.org/repos/asf/airavata/blob/de45cba1/modules/user-profile-migration/user-profile-migration.properties.template
----------------------------------------------------------------------
diff --git a/modules/user-profile-migration/user-profile-migration.properties.template b/modules/user-profile-migration/user-profile-migration.properties.template
index 840effe..17cef37 100644
--- a/modules/user-profile-migration/user-profile-migration.properties.template
+++ b/modules/user-profile-migration/user-profile-migration.properties.template
@@ -2,6 +2,10 @@
 # NOTE: the gateway-id will also be used for the realm id in Keycloak
 gateway-id = gateway-id
 gateway.url = http://localhost
+gateway.admin.username = admin
+gateway.admin.first.name = Admin
+gateway.admin.last.name = User
+gateway.admin.email.address = sgg@iu.edu
 
 # WSO2 Identity Server settings
 wso2is.admin.username = username


Mime
View raw message