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 <[email protected]> Authored: Mon Jun 5 10:45:10 2017 -0400 Committer: Marcus Christie <[email protected]> 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; + } }
