You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2017/06/05 15:58:39 UTC
[1/3] airavata git commit: AIRAVATA-2423 Properties file for
migration config
Repository: airavata
Updated Branches:
refs/heads/develop bd526ade0 -> eeea42eee
AIRAVATA-2423 Properties file for migration config
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/71579928
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/71579928
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/71579928
Branch: refs/heads/develop
Commit: 71579928ccb4844e66151358a4281833e7289fa1
Parents: bd526ad
Author: Marcus Christie <ma...@apache.org>
Authored: Fri Jun 2 17:59:59 2017 -0400
Committer: Marcus Christie <ma...@apache.org>
Committed: Fri Jun 2 17:59:59 2017 -0400
----------------------------------------------------------------------
modules/user-profile-migration/.gitignore | 1 +
.../org/apache/airavata/MigrationManager.java | 75 +++++++++++++++++---
.../user-profile-migration.properties.template | 19 +++++
3 files changed, 86 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/71579928/modules/user-profile-migration/.gitignore
----------------------------------------------------------------------
diff --git a/modules/user-profile-migration/.gitignore b/modules/user-profile-migration/.gitignore
new file mode 100644
index 0000000..102b6fc
--- /dev/null
+++ b/modules/user-profile-migration/.gitignore
@@ -0,0 +1 @@
+*.properties
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/71579928/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 2cfbe59..a0eaf4d 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
@@ -29,6 +29,8 @@ import org.wso2.carbon.um.ws.api.stub.ClaimValue;
import org.wso2.carbon.um.ws.api.stub.RemoteUserStoreManagerServiceStub;
import org.wso2.carbon.um.ws.api.stub.RemoteUserStoreManagerServiceUserStoreExceptionException;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.rmi.RemoteException;
import java.util.*;
import java.util.stream.Collectors;
@@ -36,10 +38,39 @@ import java.util.stream.Collectors;
public class MigrationManager {
private ArrayList<Wso2ISLoginCredentialsDAO> adminCredentials = new ArrayList<Wso2ISLoginCredentialsDAO>();
- private static AuthzToken authzToken = new AuthzToken("empy_token");
+ private static AuthzToken authzToken = new AuthzToken("empty_token");
+
+ // Default values
private String profileServiceServerHost = "localhost";
private int profileServiceServerPort = 8962;
private Map<String,String> roleConversionMap = createDefaultRoleConversionMap();
+ private String gatewayId = "gateway-id";
+ 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";
+ private String keycloakTrustStorePassword = "password";
+ private String keycloakTemporaryUserPassword = "tempPassword";
+
+ // Names of properties in user-profile-migration.properties.template
+ private final static String GATEWAY_ID = "gateway-id";
+ private final static String WSO2IS_ADMIN_USERNAME = "wso2is.admin.username";
+ private final static String WSO2IS_ADMIN_PASSWORD = "wso2is.admin.password";
+ // TODO: add role name conversions
+ private final static String WSO2IS_GATEWAY_ADMIN_ROLENAME = "";
+ 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";
+ private final static String KEYCLOAK_USER_TEMP_PASSWORD = "keycloak.user.temp.password";
+
private Map<String,String> createDefaultRoleConversionMap() {
Map<String,String> roleConversionMap = new HashMap<>();
@@ -53,7 +84,7 @@ public class MigrationManager {
/*Add the credentials for all the tenants from which the profile should be migrated to Airavata DB*/
public void setISLoginCredentials(){
- adminCredentials.add(new Wso2ISLoginCredentialsDAO("gateway-id","username","password"));
+ adminCredentials.add(new Wso2ISLoginCredentialsDAO(this.gatewayId, this.wso2ISAdminUsername, this.wso2ISAdminPassword));
// new credential records here...
}
@@ -158,17 +189,43 @@ public class MigrationManager {
}
private void migrateUserProfilesToKeycloak(List<UserProfileDAO> Wso2ISProfileList){
- KeycloakIdentityServerClient client = new KeycloakIdentityServerClient("https://iam.scigap.org/auth",
- "master",
- "SuperRealmUsername",
- "MasterRealmPassword",
- "trustStorePath",
- "trustStorePassword");
- client.migrateUserStore(Wso2ISProfileList,"keycloakTargetRealm","tempPassword", roleConversionMap);
+ KeycloakIdentityServerClient client = new KeycloakIdentityServerClient(this.keycloakServiceURL,
+ this.keycloakRealmId,
+ this.keycloakAdminUsername,
+ this.keycloakAdminPassword,
+ this.keycloakTrustStorePath,
+ this.keycloakTrustStorePassword);
+ client.migrateUserStore(Wso2ISProfileList, this.keycloakRealmId, this.keycloakTemporaryUserPassword, this.roleConversionMap);
+ }
+
+ private void loadConfigFile(String filename) {
+ Properties properties = new Properties();
+ try {
+ properties.load(new FileInputStream(filename));
+ this.gatewayId = properties.getProperty(GATEWAY_ID, this.gatewayId);
+ this.wso2ISAdminUsername = properties.getProperty(WSO2IS_ADMIN_USERNAME, this.wso2ISAdminUsername);
+ this.wso2ISAdminPassword = properties.getProperty(WSO2IS_ADMIN_PASSWORD, this.wso2ISAdminPassword);
+ 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);
+ this.keycloakTrustStorePassword = properties.getProperty(KEYCLOAK_TRUSTSTORE_PASSWORD, this.keycloakTrustStorePassword);
+ this.keycloakTemporaryUserPassword = properties.getProperty(KEYCLOAK_USER_TEMP_PASSWORD, this.keycloakTemporaryUserPassword);
+ // TODO: get custom IS role names
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
public static void main(String[] args) {
MigrationManager migrationManager = new MigrationManager();
+ if (args.length > 0) {
+ String configFilename = args[0];
+ migrationManager.loadConfigFile(configFilename);
+ }
migrationManager.setISLoginCredentials();
List<UserProfileDAO> userProfileList = migrationManager.getUserProfilesFromWso2IS();
try {
http://git-wip-us.apache.org/repos/asf/airavata/blob/71579928/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
new file mode 100644
index 0000000..dffb8b1
--- /dev/null
+++ b/modules/user-profile-migration/user-profile-migration.properties.template
@@ -0,0 +1,19 @@
+# Common settings
+gateway-id = gateway-id
+
+# WSO2 Identity Server settings
+wso2is.admin.username = username
+wso2is.admin.password = password
+
+# Profile Service settings
+profile.service.host = localhost
+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
+keycloak.user.temp.password = tempPassword
[2/3] airavata git commit: AIRAVATA-2423 Configuration of custom role
names
Posted by ma...@apache.org.
AIRAVATA-2423 Configuration of custom role names
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/1c320eb2
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/1c320eb2
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/1c320eb2
Branch: refs/heads/develop
Commit: 1c320eb2d17aa912476937aca5dac288b2b1e74c
Parents: 7157992
Author: Marcus Christie <ma...@apache.org>
Authored: Mon Jun 5 10:34:16 2017 -0400
Committer: Marcus Christie <ma...@apache.org>
Committed: Mon Jun 5 10:34:16 2017 -0400
----------------------------------------------------------------------
.../java/org/apache/airavata/MigrationManager.java | 15 ++++++++++++---
.../user-profile-migration.properties.template | 5 +++++
2 files changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/1c320eb2/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 a0eaf4d..6b808e2 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
@@ -59,8 +59,11 @@ public class MigrationManager {
private final static String GATEWAY_ID = "gateway-id";
private final static String WSO2IS_ADMIN_USERNAME = "wso2is.admin.username";
private final static String WSO2IS_ADMIN_PASSWORD = "wso2is.admin.password";
- // TODO: add role name conversions
- private final static String WSO2IS_GATEWAY_ADMIN_ROLENAME = "";
+ private final static String WSO2IS_ADMIN_ROLENAME = "wso2is.admin.rolename";
+ private final static String WSO2IS_ADMIN_READ_ONLY_ROLENAME = "wso2is.admin-read-only.rolename";
+ 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 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";
@@ -202,6 +205,7 @@ public class MigrationManager {
Properties properties = new Properties();
try {
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.wso2ISAdminUsername = properties.getProperty(WSO2IS_ADMIN_USERNAME, this.wso2ISAdminUsername);
this.wso2ISAdminPassword = properties.getProperty(WSO2IS_ADMIN_PASSWORD, this.wso2ISAdminPassword);
@@ -214,7 +218,12 @@ public class MigrationManager {
this.keycloakTrustStorePath = properties.getProperty(KEYCLOAK_TRUSTSTORE_PATH, this.keycloakTrustStorePath);
this.keycloakTrustStorePassword = properties.getProperty(KEYCLOAK_TRUSTSTORE_PASSWORD, this.keycloakTrustStorePassword);
this.keycloakTemporaryUserPassword = properties.getProperty(KEYCLOAK_USER_TEMP_PASSWORD, this.keycloakTemporaryUserPassword);
- // TODO: get custom IS role names
+ // Custom role names
+ this.roleConversionMap.put(properties.getProperty(WSO2IS_ADMIN_ROLENAME, "admin"), "admin");
+ this.roleConversionMap.put(properties.getProperty(WSO2IS_ADMIN_READ_ONLY_ROLENAME, "admin-read-only"), "admin-read-only");
+ this.roleConversionMap.put(properties.getProperty(WSO2IS_GATEWAY_USER_ROLENAME, "gateway-user"), "gateway-user");
+ this.roleConversionMap.put(properties.getProperty(WSO2IS_USER_PENDING_ROLENAME, "user-pending"), "user-pending");
+ this.roleConversionMap.put(properties.getProperty(WSO2IS_GATEWAY_PROVIDER_ROLENAME, "gateway-provider"), "gateway-provider");
} catch (IOException e) {
throw new RuntimeException(e);
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/1c320eb2/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 dffb8b1..aa751b2 100644
--- a/modules/user-profile-migration/user-profile-migration.properties.template
+++ b/modules/user-profile-migration/user-profile-migration.properties.template
@@ -4,6 +4,11 @@ gateway-id = gateway-id
# WSO2 Identity Server settings
wso2is.admin.username = username
wso2is.admin.password = password
+wso2is.admin.rolename = admin
+wso2is.admin-read-only.rolename = admin-read-only
+wso2is.gateway-user.rolename = gateway-user
+wso2is.user-pending.rolename = user-pending
+wso2is.gateway-provider.rolename = gateway-provider
# Profile Service settings
profile.service.host = localhost
[3/3] airavata git commit: AIRAVATA-2422 AIRAVATA-2427 Not migrating
locked accounts
Posted by ma...@apache.org.
AIRAVATA-2422 AIRAVATA-2427 Not migrating locked accounts
Also setting email verified flag since only unlocked accounts are
migrated.
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/eeea42ee
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/eeea42ee
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/eeea42ee
Branch: refs/heads/develop
Commit: eeea42eeed1c260bbe0ef74ab8277868eeb3abb9
Parents: 1c320eb
Author: Marcus Christie <ma...@apache.org>
Authored: Mon Jun 5 10:45:10 2017 -0400
Committer: Marcus Christie <ma...@apache.org>
Committed: Mon Jun 5 10:45:10 2017 -0400
----------------------------------------------------------------------
.../apache/airavata/KeycloakIdentityServerClient.java | 1 +
.../java/org/apache/airavata/MigrationManager.java | 13 ++++++++++---
.../main/java/org/apache/airavata/UserProfileDAO.java | 9 +++++++++
3 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/eeea42ee/modules/user-profile-migration/src/main/java/org/apache/airavata/KeycloakIdentityServerClient.java
----------------------------------------------------------------------
diff --git a/modules/user-profile-migration/src/main/java/org/apache/airavata/KeycloakIdentityServerClient.java b/modules/user-profile-migration/src/main/java/org/apache/airavata/KeycloakIdentityServerClient.java
index ed1bb8a..bb5edfe 100644
--- a/modules/user-profile-migration/src/main/java/org/apache/airavata/KeycloakIdentityServerClient.java
+++ b/modules/user-profile-migration/src/main/java/org/apache/airavata/KeycloakIdentityServerClient.java
@@ -101,6 +101,7 @@ public class KeycloakIdentityServerClient {
user.setFirstName(userProfile.getFirstName());
user.setLastName(userProfile.getLastName());
user.setEmail(userProfile.getEmail());
+ user.setEmailVerified(true);
user.setEnabled(true);
List<String> requiredActionList = new ArrayList<>();
requiredActionList.add("UPDATE_PASSWORD");
http://git-wip-us.apache.org/repos/asf/airavata/blob/eeea42ee/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 6b808e2..c9b1205 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
@@ -110,7 +110,8 @@ public class MigrationManager {
"http://wso2.org/claims/mobile",
"http://wso2.org/claims/telephone",
"http://wso2.org/claims/streetaddress",
- "http://wso2.org/claims/role"};
+ "http://wso2.org/claims/role",
+ "http://wso2.org/claims/identity/accountLocked"};
for (String user : userList) {
UserProfileDAO userProfile = new UserProfileDAO();
ClaimValue[] retrievedClaimValues = isClient.getUserClaimValuesForClaims(user, claims, null);
@@ -132,13 +133,19 @@ public class MigrationManager {
userProfile.setAddress(claim.getValue());
} else if(claim.getClaimURI().equals(claims[8])){
userProfile.setRoles(convertCommaSeparatedRolesToList(claim.getValue()));
+ } else if(claim.getClaimURI().equals(claims[9])){
+ userProfile.setAccountLocked(claim.getValue().equals("true"));
}
}
userProfile.setUserName(user);
userProfile.setGatewayID(creds.getGateway());
userProfile.setPhones(phones);
- System.out.println(userProfile.getFirstName()+"\t"+userProfile.getLastName()+"\t"+userProfile.getUserName()+"\t"+userProfile.getEmail()+"\t"+userProfile.getCountry()+"\t"+userProfile.getOrganization() + "\t" + userProfile.getAddress() + "\t" + userProfile.getRoles());
- userProfileList.add(userProfile);
+ if (!userProfile.isAccountLocked()) {
+ System.out.println(userProfile.getFirstName() + "\t" + userProfile.getLastName() + "\t" + userProfile.getUserName() + "\t" + userProfile.getEmail() + "\t" + userProfile.getCountry() + "\t" + userProfile.getOrganization() + "\t" + userProfile.getAddress() + "\t" + userProfile.getRoles());
+ userProfileList.add(userProfile);
+ } else {
+ System.out.println("Skipping locked account for user " + user + "!");
+ }
}
} catch (RemoteException e) {
System.out.println(e.getMessage());
http://git-wip-us.apache.org/repos/asf/airavata/blob/eeea42ee/modules/user-profile-migration/src/main/java/org/apache/airavata/UserProfileDAO.java
----------------------------------------------------------------------
diff --git a/modules/user-profile-migration/src/main/java/org/apache/airavata/UserProfileDAO.java b/modules/user-profile-migration/src/main/java/org/apache/airavata/UserProfileDAO.java
index 12571b2..97e4d87 100644
--- a/modules/user-profile-migration/src/main/java/org/apache/airavata/UserProfileDAO.java
+++ b/modules/user-profile-migration/src/main/java/org/apache/airavata/UserProfileDAO.java
@@ -33,6 +33,7 @@ public class UserProfileDAO {
private String gatewayID;
private String address;
private List<String> roles;
+ private boolean accountLocked;
public String getAddress() {
return address;
@@ -124,4 +125,12 @@ public class UserProfileDAO {
public void setRoles(List<String> roles) {
this.roles = roles;
}
+
+ public boolean isAccountLocked() {
+ return accountLocked;
+ }
+
+ public void setAccountLocked(boolean accountLocked) {
+ this.accountLocked = accountLocked;
+ }
}