From commits-return-17219-apmail-airavata-commits-archive=airavata.apache.org@airavata.apache.org Wed Jun 7 18:52:34 2017 Return-Path: X-Original-To: apmail-airavata-commits-archive@www.apache.org Delivered-To: apmail-airavata-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D241219176 for ; Wed, 7 Jun 2017 18:52:34 +0000 (UTC) Received: (qmail 19457 invoked by uid 500); 7 Jun 2017 18:52:34 -0000 Delivered-To: apmail-airavata-commits-archive@airavata.apache.org Received: (qmail 19340 invoked by uid 500); 7 Jun 2017 18:52:34 -0000 Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airavata.apache.org Delivered-To: mailing list commits@airavata.apache.org Received: (qmail 19307 invoked by uid 99); 7 Jun 2017 18:52:34 -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; Wed, 07 Jun 2017 18:52:34 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 55F0BE027A; Wed, 7 Jun 2017 18:52:34 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: machristie@apache.org To: commits@airavata.apache.org Date: Wed, 07 Jun 2017 18:52:35 -0000 Message-Id: <88db9feba159457f8e05bf53c7640dc9@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/2] airavata git commit: AIRAVATA-2431 Migrating Gateway and IAM Tenant also AIRAVATA-2431 Migrating Gateway and IAM Tenant also Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/83102ed6 Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/83102ed6 Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/83102ed6 Branch: refs/heads/develop Commit: 83102ed625c5a7a754100a98e653e6f572353270 Parents: 9a31410 Author: Marcus Christie Authored: Wed Jun 7 12:56:32 2017 -0400 Committer: Marcus Christie Committed: Wed Jun 7 14:51:59 2017 -0400 ---------------------------------------------------------------------- .../core/impl/TenantManagementKeycloakImpl.java | 6 +- .../commons/tenant/entities/GatewayEntity.java | 24 ++--- .../repositories/TenantProfileRepository.java | 1 - modules/user-profile-migration/pom.xml | 5 ++ .../airavata/KeycloakTenantCreationManager.java | 92 ------------------- .../org/apache/airavata/MigrationManager.java | 95 +++++++++++++++++--- .../UserProfileAiravataThriftClient.java | 37 -------- .../user-profile-migration.properties.template | 7 +- 8 files changed, 113 insertions(+), 154 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/83102ed6/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java ---------------------------------------------------------------------- diff --git a/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java b/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java index e3aa6e5..c457bc0 100644 --- a/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java +++ b/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java @@ -150,6 +150,10 @@ public class TenantManagementKeycloakImpl implements TenantManagementInterface { pendingUserRole.setName("user-pending"); pendingUserRole.setDescription("role for newly registered PGA users"); defaultRoles.add(pendingUserRole); + RoleRepresentation gatewayProviderRole = new RoleRepresentation(); + gatewayProviderRole.setName("gateway-provider"); + gatewayProviderRole.setDescription("role for gateway providers in the super-admin PGA"); + defaultRoles.add(gatewayProviderRole); RolesRepresentation rolesRepresentation = new RolesRepresentation(); rolesRepresentation.setRealm(defaultRoles); realmDetails.setRoles(rolesRepresentation); @@ -237,7 +241,7 @@ public class TenantManagementKeycloakImpl implements TenantManagementInterface { } else { logger.error("Request for Realm Client Creation failed, callback URL not present"); IamAdminServicesException ex = new IamAdminServicesException(); - ex.setMessage("Gateway Url field in GatewayProfile cannot be empty, Relam Client creation failed"); + ex.setMessage("Gateway Url field in GatewayProfile cannot be empty, Realm Client creation failed"); throw ex; } pgaClient.setRedirectUris(redirectUris); http://git-wip-us.apache.org/repos/asf/airavata/blob/83102ed6/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/tenant/entities/GatewayEntity.java ---------------------------------------------------------------------- diff --git a/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/tenant/entities/GatewayEntity.java b/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/tenant/entities/GatewayEntity.java index 0d6f5a2..876d12f 100644 --- a/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/tenant/entities/GatewayEntity.java +++ b/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/tenant/entities/GatewayEntity.java @@ -42,13 +42,13 @@ public class GatewayEntity { private String gatewayPublicAbstract; private String reviewProposalDescription; private String gatewayAdminFirstName; - private String getGatewayAdminLastName; + private String gatewayAdminLastName; private String gatewayAdminEmail; private String identityServerUserName; private String identityServerPasswordToken; private String declinedReason; private String oauthClientId; - private String getOauthClientSecret; + private String oauthClientSecret; private long requestCreationTime; private String requesterUsername; @@ -158,12 +158,12 @@ public class GatewayEntity { } @Column(name = "GATEWAY_ADMIN_LAST_NAME") - public String getGetGatewayAdminLastName() { - return getGatewayAdminLastName; + public String getGatewayAdminLastName() { + return gatewayAdminLastName; } - public void setGetGatewayAdminLastName(String getGatewayAdminLastName) { - this.getGatewayAdminLastName = getGatewayAdminLastName; + public void setGatewayAdminLastName(String gatewayAdminLastName) { + this.gatewayAdminLastName = gatewayAdminLastName; } @Column(name = "GATEWAY_ADMIN_EMAIL") @@ -230,12 +230,12 @@ public class GatewayEntity { } @Column(name = "OAUTH_CLIENT_SECRET") - public String getGetOauthClientSecret() { - return getOauthClientSecret; + public String getOauthClientSecret() { + return oauthClientSecret; } - public void setGetOauthClientSecret(String oauthClientSecret) { - this.getOauthClientSecret = oauthClientSecret; + public void setOauthClientSecret(String oauthClientSecret) { + this.oauthClientSecret = oauthClientSecret; } @PrePersist @@ -272,13 +272,13 @@ public class GatewayEntity { ", gatewayPublicAbstract='" + gatewayPublicAbstract + '\'' + ", reviewProposalDescription='" + reviewProposalDescription + '\'' + ", gatewayAdminFirstName='" + gatewayAdminFirstName + '\'' + - ", getGatewayAdminLastName='" + getGatewayAdminLastName + '\'' + + ", gatewayAdminLastName='" + gatewayAdminLastName + '\'' + ", gatewayAdminEmail='" + gatewayAdminEmail + '\'' + ", identityServerUserName='" + identityServerUserName + '\'' + ", identityServerPasswordToken='" + identityServerPasswordToken + '\'' + ", declinedReason='" + declinedReason + '\'' + ", oauthClientId='" + oauthClientId + '\'' + - ", getOauthClientSecret='" + getOauthClientSecret + '\'' + + ", oauthClientSecret='" + oauthClientSecret + '\'' + ", requestCreationTime=" + requestCreationTime + ", requesterUsername='" + requesterUsername + '\'' + '}'; http://git-wip-us.apache.org/repos/asf/airavata/blob/83102ed6/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java ---------------------------------------------------------------------- diff --git a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java index ebc5fee..13e89e7 100644 --- a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java +++ b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java @@ -27,7 +27,6 @@ import org.apache.airavata.service.profile.commons.utils.QueryConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; http://git-wip-us.apache.org/repos/asf/airavata/blob/83102ed6/modules/user-profile-migration/pom.xml ---------------------------------------------------------------------- diff --git a/modules/user-profile-migration/pom.xml b/modules/user-profile-migration/pom.xml index 1baa85b..ee002c6 100755 --- a/modules/user-profile-migration/pom.xml +++ b/modules/user-profile-migration/pom.xml @@ -74,6 +74,11 @@ org.apache.airavata + airavata-api-stubs + ${project.version} + + + org.apache.airavata airavata-commons 0.17-SNAPSHOT http://git-wip-us.apache.org/repos/asf/airavata/blob/83102ed6/modules/user-profile-migration/src/main/java/org/apache/airavata/KeycloakTenantCreationManager.java ---------------------------------------------------------------------- diff --git a/modules/user-profile-migration/src/main/java/org/apache/airavata/KeycloakTenantCreationManager.java b/modules/user-profile-migration/src/main/java/org/apache/airavata/KeycloakTenantCreationManager.java deleted file mode 100644 index b166a27..0000000 --- a/modules/user-profile-migration/src/main/java/org/apache/airavata/KeycloakTenantCreationManager.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.apache.airavata; - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - * - */ - -import org.apache.airavata.model.credential.store.PasswordCredential; -import org.apache.airavata.model.security.AuthzToken; -import org.apache.airavata.model.workspace.Gateway; -import org.apache.airavata.model.workspace.GatewayApprovalStatus; -import org.apache.airavata.service.profile.client.ProfileServiceClientFactory; -import org.apache.airavata.service.profile.iam.admin.services.cpi.IamAdminServices; -import org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException; -import org.apache.thrift.TException; - -public class KeycloakTenantCreationManager { - - private String profileServiceServerHost = "localhost"; - private int profileServiceServerPort = 8962; - private String masterAdminUsername = "admin"; - private String masterAdminPassword = "password"; - - private IamAdminServices.Client iamAdminServiceClient = null; - - public void createTenant(Gateway gateway) { - PasswordCredential passwordCredential = getPasswordCredential(); - try { - // TODO: replace with real authz token? - getIamAdminServiceClient().setUpGateway(new AuthzToken("empty"), gateway, passwordCredential); - } catch (TException e) { - throw new RuntimeException(e); - } - } - - private IamAdminServices.Client getIamAdminServiceClient() { - if (iamAdminServiceClient == null) { - try { - iamAdminServiceClient = ProfileServiceClientFactory.createIamAdminServiceClient(this.profileServiceServerHost, this.profileServiceServerPort); - } catch (IamAdminServicesException e) { - throw new RuntimeException(e); - } - } - return iamAdminServiceClient; - } - - private PasswordCredential getPasswordCredential() { - PasswordCredential passwordCredential = new PasswordCredential(); - passwordCredential.setGatewayId("dummy"); - passwordCredential.setPortalUserName("dummy"); - passwordCredential.setLoginUserName(masterAdminUsername); - passwordCredential.setPassword(masterAdminPassword); - return passwordCredential; - } - - public static void main(String[] args) { - - // Configuration ... - KeycloakTenantCreationManager keycloakTenantCreationManager = new KeycloakTenantCreationManager(); - keycloakTenantCreationManager.masterAdminUsername = ""; - keycloakTenantCreationManager.masterAdminPassword = ""; - keycloakTenantCreationManager.profileServiceServerHost = ""; - - Gateway gateway = new Gateway(); - gateway.setGatewayId(""); - gateway.setGatewayApprovalStatus(GatewayApprovalStatus.CREATED); - gateway.setGatewayName(""); - gateway.setIdentityServerUserName(""); - gateway.setGatewayAdminFirstName(""); - gateway.setGatewayAdminLastName(""); - gateway.setGatewayAdminEmail(""); - gateway.setGatewayURL(""); - - keycloakTenantCreationManager.createTenant(gateway); - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/83102ed6/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 a44b173..b197c70 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 @@ -19,10 +19,21 @@ */ package org.apache.airavata; +import org.apache.airavata.api.Airavata; +import org.apache.airavata.api.client.AiravataClientFactory; import org.apache.airavata.common.exception.ApplicationSettingsException; +import org.apache.airavata.model.credential.store.PasswordCredential; +import org.apache.airavata.model.error.AiravataClientException; import org.apache.airavata.model.security.AuthzToken; import org.apache.airavata.model.user.Status; import org.apache.airavata.model.user.UserProfile; +import org.apache.airavata.model.workspace.Gateway; +import org.apache.airavata.model.workspace.GatewayApprovalStatus; +import org.apache.airavata.service.profile.client.ProfileServiceClientFactory; +import org.apache.airavata.service.profile.iam.admin.services.cpi.IamAdminServices; +import org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException; +import org.apache.airavata.service.profile.tenant.cpi.TenantProfileService; +import org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException; import org.apache.airavata.service.profile.user.cpi.UserProfileService; import org.apache.thrift.TException; import org.wso2.carbon.um.ws.api.stub.ClaimValue; @@ -43,12 +54,14 @@ public class MigrationManager { // Default values private String profileServiceServerHost = "localhost"; private int profileServiceServerPort = 8962; + private String airavataServiceServerHost = "localhost"; + private int airavataServiceServerPort = 8930; private Map 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"; - private String keycloakRealmId = "keycloak-realm"; private String keycloakAdminUsername = "username"; private String keycloakAdminPassword = "password"; private String keycloakTrustStorePath = "../../modules/configuration/server/src/main/resources/client_truststore.jks"; @@ -57,6 +70,7 @@ public class MigrationManager { // 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 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"; @@ -64,11 +78,12 @@ public class MigrationManager { private final static String WSO2IS_GATEWAY_USER_ROLENAME = "wso2is.gateway-user.rolename"; private final static String WSO2IS_USER_PENDING_ROLENAME = "wso2is.user-pending.rolename"; private final static String WSO2IS_GATEWAY_PROVIDER_ROLENAME = "wso2is.gateway-provider.rolename"; + private final static String AIRAVATA_SERVICE_HOST = "airavata.service.host"; + private final static String AIRAVATA_SERVICE_PORT = "airavata.service.port"; private final static String PROFILE_SERVICE_HOST = "profile.service.host"; private final static String PROFILE_SERVICE_PORT = "profile.service.port"; private final static String KEYCLOAK_ADMIN_USERNAME = "keycloak.admin.username"; private final static String KEYCLOAK_ADMIN_PASSWORD = "keycloak.admin.password"; - private final static String KEYCLOAK_REALM_ID = "keycloak.realm-id"; private final static String KEYCLOAK_SERVICE_URL = "keycloak.service-url"; private final static String KEYCLOAK_TRUSTSTORE_PATH = "keycloak.truststore.path"; private final static String KEYCLOAK_TRUSTSTORE_PASSWORD = "keycloak.truststore.password"; @@ -169,11 +184,70 @@ public class MigrationManager { .collect(Collectors.toList()); } + private TenantProfileService.Client getTenantProfileServiceClient() throws TenantProfileServiceException { + + return ProfileServiceClientFactory.createTenantProfileServiceClient(profileServiceServerHost, profileServiceServerPort); + } + + private Airavata.Client getAiravataClient() throws AiravataClientException { + return AiravataClientFactory.createAiravataClient(airavataServiceServerHost, airavataServiceServerPort); + } + + private IamAdminServices.Client getIamAdminServicesClient() throws IamAdminServicesException { + return ProfileServiceClientFactory.createIamAdminServiceClient(profileServiceServerHost, profileServiceServerPort); + } + + private PasswordCredential getPasswordCredential() { + PasswordCredential passwordCredential = new PasswordCredential(); + passwordCredential.setGatewayId("dummy"); + passwordCredential.setPortalUserName("dummy"); + passwordCredential.setLoginUserName(keycloakAdminUsername); + passwordCredential.setPassword(keycloakAdminPassword); + return passwordCredential; + } + + private boolean migrateGatewayProfileToAiravata() throws TException { + + TenantProfileService.Client tenantProfileServiceClient = getTenantProfileServiceClient(); + Airavata.Client airavataClient = getAiravataClient(); + IamAdminServices.Client iamAdminServicesClient = getIamAdminServicesClient(); + + // Get Gateway from Airavata API + Gateway gateway = airavataClient.getGateway(authzToken, gatewayId); + + if (!GatewayApprovalStatus.APPROVED.equals(gateway.getGatewayApprovalStatus())) { + throw new RuntimeException("Gateway " + gatewayId + " is not APPROVED! Status is " + gateway.getGatewayApprovalStatus()); + } + // Add Gateway through TenantProfileService + if (!tenantProfileServiceClient.isGatewayExist(authzToken, gatewayId)) { + + System.out.println("Gateway [" + gatewayId + "] doesn't exist, adding in Profile Service..."); + tenantProfileServiceClient.addGateway(authzToken, gateway); + } else { + + System.out.println("Gateway [" + gatewayId + "] already exists in Profile Service"); + gateway = tenantProfileServiceClient.getGateway(authzToken, gatewayId); + } + + // Gateway URL is required by IAM Admin Services + if (gateway.getGatewayURL() == null) { + gateway.setGatewayURL(this.gatewayURL); + } + + // Add Keycloak Tenant for Gateway + System.out.println("Creating Keycloak Tenant for gateway ...") + Gateway gatewayWithIdAndSecret = iamAdminServicesClient.setUpGateway(authzToken, gateway, getPasswordCredential()); + + // Update Gateway profile with the client id and secret + System.out.println("Updating gateway with OAuth client id and secret ..."); + tenantProfileServiceClient.updateGateway(authzToken, gatewayWithIdAndSecret); + return true; + } + /* Method used to migrate User profiles to Airavata DB by making a call to User profile thrift Service */ private boolean migrateUserProfilesToAiravata(List ISProfileList) throws TException, ApplicationSettingsException { System.out.println("Initiating migration to Airavata internal DB ..."); - UserProfileAiravataThriftClient objFactory = new UserProfileAiravataThriftClient(); - UserProfileService.Client client = objFactory.getUserProfileServiceClient(profileServiceServerHost, profileServiceServerPort); + UserProfileService.Client client = ProfileServiceClientFactory.createUserProfileServiceClient(profileServiceServerHost, profileServiceServerPort); UserProfile airavataUserProfile = new UserProfile(); // Here are the data associations... for(UserProfileDAO ISProfile : ISProfileList){ @@ -204,7 +278,7 @@ public class MigrationManager { this.keycloakAdminPassword, this.keycloakTrustStorePath, this.keycloakTrustStorePassword); - client.migrateUserStore(Wso2ISProfileList, this.keycloakRealmId, this.keycloakTemporaryUserPassword, this.roleConversionMap); + client.migrateUserStore(Wso2ISProfileList, this.gatewayId, this.keycloakTemporaryUserPassword, this.roleConversionMap); } private void loadConfigFile(String filename) { @@ -213,12 +287,14 @@ public class MigrationManager { properties.load(new FileInputStream(filename)); // 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.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); + this.airavataServiceServerPort = Integer.valueOf(properties.getProperty(AIRAVATA_SERVICE_PORT, Integer.toString(this.airavataServiceServerPort))); this.profileServiceServerHost = properties.getProperty(PROFILE_SERVICE_HOST, this.profileServiceServerHost); this.profileServiceServerPort = Integer.valueOf(properties.getProperty(PROFILE_SERVICE_PORT, Integer.toString(this.profileServiceServerPort))); this.keycloakServiceURL = properties.getProperty(KEYCLOAK_SERVICE_URL, this.keycloakServiceURL); - this.keycloakRealmId = properties.getProperty(KEYCLOAK_REALM_ID, this.keycloakRealmId); this.keycloakAdminUsername = properties.getProperty(KEYCLOAK_ADMIN_USERNAME, this.keycloakAdminUsername); this.keycloakAdminPassword = properties.getProperty(KEYCLOAK_ADMIN_PASSWORD, this.keycloakAdminPassword); this.keycloakTrustStorePath = properties.getProperty(KEYCLOAK_TRUSTSTORE_PATH, this.keycloakTrustStorePath); @@ -244,12 +320,11 @@ public class MigrationManager { migrationManager.setISLoginCredentials(); List userProfileList = migrationManager.getUserProfilesFromWso2IS(); try { + migrationManager.migrateGatewayProfileToAiravata(); migrationManager.migrateUserProfilesToAiravata(userProfileList); migrationManager.migrateUserProfilesToKeycloak(userProfileList); - } catch (TException e) { - e.printStackTrace(); - } catch (ApplicationSettingsException e) { - e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/83102ed6/modules/user-profile-migration/src/main/java/org/apache/airavata/UserProfileAiravataThriftClient.java ---------------------------------------------------------------------- diff --git a/modules/user-profile-migration/src/main/java/org/apache/airavata/UserProfileAiravataThriftClient.java b/modules/user-profile-migration/src/main/java/org/apache/airavata/UserProfileAiravataThriftClient.java deleted file mode 100644 index 3bea905..0000000 --- a/modules/user-profile-migration/src/main/java/org/apache/airavata/UserProfileAiravataThriftClient.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.airavata; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.airavata.service.profile.client.ProfileServiceClientFactory; -import org.apache.airavata.service.profile.user.cpi.UserProfileService; -import org.apache.airavata.service.profile.user.cpi.exception.UserProfileServiceException; -import org.apache.thrift.TException; - -public class UserProfileAiravataThriftClient { - - public UserProfileService.Client getUserProfileServiceClient(String serverHost, int serverPort) throws TException, ApplicationSettingsException { - try { - return ProfileServiceClientFactory.createUserProfileServiceClient(serverHost, serverPort); - } catch (UserProfileServiceException e) { - throw new TException("Unable to create user profile service client...", e); - } - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/83102ed6/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 aa751b2..840effe 100644 --- a/modules/user-profile-migration/user-profile-migration.properties.template +++ b/modules/user-profile-migration/user-profile-migration.properties.template @@ -1,5 +1,7 @@ # Common settings +# NOTE: the gateway-id will also be used for the realm id in Keycloak gateway-id = gateway-id +gateway.url = http://localhost # WSO2 Identity Server settings wso2is.admin.username = username @@ -10,6 +12,10 @@ wso2is.gateway-user.rolename = gateway-user wso2is.user-pending.rolename = user-pending wso2is.gateway-provider.rolename = gateway-provider +# Airavata Service settings +airavata.service.host = localhost +airavata.service.port = 8930 + # Profile Service settings profile.service.host = localhost profile.service.port = 8962 @@ -17,7 +23,6 @@ profile.service.port = 8962 # Keycloak settings keycloak.admin.username = username keycloak.admin.password = password -keycloak.realm-id = keycloak-realm keycloak.service-url = https://iam.scigap.org/auth keycloak.truststore.path = ../../modules/configuration/server/src/main/resources/client_truststore.jks keycloak.truststore.password = password