Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change hybrid role manager to work with V2 roles #3700

Merged
merged 9 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,33 @@
public class HybridJDBCConstants {

public static final String GET_ROLE_LIST_OF_USER = "GetRoleListOfInternalUserSQL";
public static final String GET_ROLE_V2_LIST_OF_USER = "GetRoleV2ListOfInternalUserSQL";
public static final String GET_IS_ROLE_EXIST_LIST_OF_USER = "GetIsRoleExistFromRoleListOfInternalUserSQL";
public static final String GET_IS_ROLE_V2_EXIST_LIST_OF_USER = "GetIsRoleV2ExistFromRoleListOfInternalUserSQL";

public static final String GET_ROLE_LIST_OF_USERS = "GetRoleListOfInternalUsersSQL";
public static final String GET_ROLE_V2_LIST_OF_USERS = "GetRoleListOfInternalUsersSQL";
public static final String GET_ROLE_LIST_OF_GROUPS = "GetInternalRoleListOfGroupsSQL";
public static final String GET_ROLE_V2_LIST_OF_GROUPS = "GetInternalRoleV2ListOfGroupsSQL";

public static final String ADD_ROLE_SQL = "INSERT INTO UM_HYBRID_ROLE (UM_ROLE_NAME, UM_TENANT_ID) VALUES (?, ?)";
public static final String ADD_ROLE_V2_SQL = "INSERT INTO UM_HYBRID_ROLE (UM_ROLE_NAME, UM_TENANT_ID, " +
"UM_AUDIENCE_REF_ID, UM_UUID) VALUES (?, ?, ?, ?)";
public static final String ADD_ROLE_V2_AUDIENCE_SQL = "INSERT INTO UM_HYBRID_ROLE_AUDIENCE (UM_AUDIENCE," +
"UM_AUDIENCE_ID) VALUES ('organization', ?)";
public static final String GET_ROLE_V2_AUDIENCE_SQL = "SELECT UM_ID FROM UM_HYBRID_ROLE_AUDIENCE WHERE UM_AUDIENCE " +
"='organization' AND UM_AUDIENCE_ID=?";
public static final String ADD_USER_TO_ROLE_V2_SQL= "INSERT INTO UM_HYBRID_USER_ROLE (UM_USER_NAME, UM_ROLE_ID, " +
"UM_TENANT_ID, UM_DOMAIN_ID) VALUES (?,(SELECT UM_ID FROM UM_HYBRID_ROLE WHERE UM_ROLE_NAME=? AND " +
"UM_TENANT_ID=? AND UM_AUDIENCE_REF_ID=?), ?, " +
"(SELECT UM_DOMAIN_ID FROM UM_DOMAIN WHERE UM_TENANT_ID=? AND UM_DOMAIN_NAME=?))";
public static final String ADD_USER_TO_ROLE_V2_SQL_MSSQL = "INSERT INTO UM_HYBRID_USER_ROLE (UM_USER_NAME, " +
"UM_ROLE_ID, UM_TENANT_ID, UM_DOMAIN_ID) SELECT (?),(SELECT UM_ID FROM UM_HYBRID_ROLE WHERE " +
"UM_ROLE_NAME=? AND UM_TENANT_ID=? AND UM_AUDIENCE_REF_ID=?), (?), (SELECT UM_DOMAIN_ID FROM UM_DOMAIN " +
"WHERE UM_TENANT_ID=? AND UM_DOMAIN_NAME=?)";
public static final String ADD_USER_TO_ROLE_V2_SQL_OPENEDGE = "INSERT INTO UM_HYBRID_USER_ROLE " +
"(UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID) SELECT ?, UM_ID, ? FROM UM_HYBRID_ROLE WHERE UM_ROLE_NAME=? " +
"AND UM_TENANT_ID=? AND UM_AUDIENCE_REF_ID=?";
public static final String DELETE_ROLE_SQL = "DELETE FROM UM_HYBRID_ROLE WHERE UM_ROLE_NAME = ? AND UM_TENANT_ID=?";
public static final String DELETE_ROLES_BY_TENANT_ID_SQL = "DELETE FROM UM_HYBRID_ROLE WHERE UM_TENANT_ID=?";
public static final String ON_DELETE_ROLE_REMOVE_USER_ROLE_SQL = "DELETE FROM UM_HYBRID_USER_ROLE WHERE " +
Expand Down Expand Up @@ -92,12 +113,25 @@ public class HybridJDBCConstants {

public static final String GET_ROLES =
"SELECT UM_ROLE_NAME FROM UM_HYBRID_ROLE WHERE UM_ROLE_NAME LIKE ? AND UM_TENANT_ID=?";

public static final String GET_ROLES_V2 =
"SELECT UM_ROLE_NAME FROM UM_HYBRID_ROLE INNER JOIN UM_HYBRID_ROLE_AUDIENCE ON " +
"UM_HYBRID_ROLE.UM_AUDIENCE_REF_ID = UM_HYBRID_ROLE_AUDIENCE.UM_ID WHERE UM_ROLE_NAME LIKE ? " +
"AND UM_TENANT_ID=?";
public static final String GET_INTERNAL_ROLES =
"SELECT UM_ROLE_NAME FROM UM_HYBRID_ROLE WHERE UM_ROLE_NAME LIKE ? AND NOT UM_ROLE_NAME LIKE ? AND " +
"UM_TENANT_ID=?";
public static final String GET_INTERNAL_ROLES_V2 =
"SELECT UM_ROLE_NAME FROM UM_HYBRID_ROLE INNER JOIN UM_HYBRID_ROLE_AUDIENCE ON " +
"UM_HYBRID_ROLE.UM_AUDIENCE_REF_ID = UM_HYBRID_ROLE_AUDIENCE.UM_ID WHERE UM_ROLE_NAME LIKE ? " +
"AND NOT UM_ROLE_NAME LIKE ? AND UM_TENANT_ID=?";
public static final String GET_INTERNAL_ROLES_DB2 =
"SELECT UM_ROLE_NAME FROM UM_HYBRID_ROLE WHERE UM_ROLE_NAME LIKE ? AND NOT(UM_ROLE_NAME LIKE ?) AND " +
"UM_TENANT_ID=?";
public static final String GET_INTERNAL_ROLES_V2_DB2 =
"SELECT UM_ROLE_NAME FROM UM_HYBRID_ROLE INNER JOIN UM_HYBRID_ROLE_AUDIENCE ON " +
"UM_HYBRID_ROLE.UM_AUDIENCE_REF_ID = UM_HYBRID_ROLE_AUDIENCE.UM_ID WHERE UM_ROLE_NAME LIKE ? AND " +
"NOT(UM_ROLE_NAME LIKE ?) AND UM_TENANT_ID=?";
public static final String GET_USER_LIST_OF_ROLE_SQL = "SELECT UM_USER_NAME, UM_DOMAIN_NAME FROM UM_HYBRID_USER_ROLE, UM_DOMAIN WHERE " +
"UM_ROLE_ID=(SELECT UM_ID FROM UM_HYBRID_ROLE WHERE UM_ROLE_NAME=? AND UM_TENANT_ID=?) AND UM_HYBRID_USER_ROLE.UM_TENANT_ID=? " +
"AND UM_HYBRID_USER_ROLE.UM_DOMAIN_ID=UM_DOMAIN.UM_DOMAIN_ID";
Expand All @@ -111,30 +145,62 @@ public class HybridJDBCConstants {
"UM_HYBRID_ROLE WHERE UM_USER_NAME=? AND UM_HYBRID_USER_ROLE.UM_ROLE_ID=UM_HYBRID_ROLE.UM_ID AND " +
"UM_HYBRID_USER_ROLE.UM_TENANT_ID=? AND UM_HYBRID_ROLE.UM_TENANT_ID=? AND UM_HYBRID_USER_ROLE.UM_DOMAIN_ID=(SELECT UM_DOMAIN_ID FROM UM_DOMAIN " +
"WHERE UM_TENANT_ID=? AND UM_DOMAIN_NAME=?)";

public static final String GET_ROLE_V2_LIST_OF_USER_SQL = "SELECT UM_ROLE_NAME FROM UM_HYBRID_USER_ROLE, " +
"UM_HYBRID_ROLE, UM_HYBRID_ROLE_AUDIENCE WHERE UM_USER_NAME=? AND UM_HYBRID_USER_ROLE.UM_ROLE_ID=UM_HYBRID_ROLE.UM_ID AND " +
"UM_HYBRID_USER_ROLE.UM_TENANT_ID=? AND UM_HYBRID_ROLE.UM_TENANT_ID=? AND UM_HYBRID_USER_ROLE.UM_DOMAIN_ID=(SELECT UM_DOMAIN_ID FROM UM_DOMAIN " +
"WHERE UM_TENANT_ID=? AND UM_DOMAIN_NAME=?)";

public static final String GET_ROLE_OF_USER_SQL = "SELECT UM_ROLE_NAME FROM UM_HYBRID_USER_ROLE, "
+ "UM_HYBRID_ROLE WHERE UM_USER_NAME=? AND UM_HYBRID_USER_ROLE.UM_ROLE_ID=UM_HYBRID_ROLE.UM_ID AND "
+ "UM_HYBRID_USER_ROLE.UM_TENANT_ID=? AND UM_HYBRID_ROLE.UM_TENANT_ID=? AND "
+ "UM_HYBRID_USER_ROLE.UM_DOMAIN_ID=(SELECT UM_DOMAIN_ID FROM UM_DOMAIN WHERE UM_TENANT_ID=? AND "
+ "UM_DOMAIN_NAME=?) AND UM_ROLE_NAME LIKE ?";

public static final String GET_ROLE_V2_OF_USER_SQL = "SELECT UM_ROLE_NAME FROM UM_HYBRID_USER_ROLE, "
+ "UM_HYBRID_ROLE, UM_HYBRID_ROLE_AUDIENCE WHERE UM_USER_NAME=? AND UM_HYBRID_USER_ROLE.UM_ROLE_ID=UM_HYBRID_ROLE.UM_ID AND "
+ "UM_HYBRID_USER_ROLE.UM_TENANT_ID=? AND UM_HYBRID_ROLE.UM_TENANT_ID=? AND " +
"UM_HYBRID_ROLE.UM_AUDIENCE_REF_ID = UM_HYBRID_ROLE_AUDIENCE.UM_ID AND "
+ "UM_HYBRID_USER_ROLE.UM_DOMAIN_ID=(SELECT UM_DOMAIN_ID FROM UM_DOMAIN WHERE UM_TENANT_ID=? AND "
+ "UM_DOMAIN_NAME=?) AND UM_ROLE_NAME LIKE ?";

public static final String GET_USER_ROLE_NAME_SQL = "SELECT UM_ROLE_NAME FROM UM_HYBRID_USER_ROLE, "
+ "UM_HYBRID_ROLE WHERE UM_USER_NAME=? AND UM_HYBRID_USER_ROLE.UM_ROLE_ID=UM_HYBRID_ROLE.UM_ID AND "
+ "UM_HYBRID_USER_ROLE.UM_TENANT_ID=? AND UM_HYBRID_ROLE.UM_TENANT_ID=? AND "
+ "UM_HYBRID_USER_ROLE.UM_DOMAIN_ID=(SELECT UM_DOMAIN_ID FROM UM_DOMAIN WHERE UM_TENANT_ID=? AND "
+ "UM_DOMAIN_NAME=?) AND UM_ROLE_NAME=?";

public static final String GET_USER_ROLE_V2_NAME_SQL = "SELECT UM_ROLE_NAME FROM UM_HYBRID_USER_ROLE, "
+ "UM_HYBRID_ROLE, UM_HYBRID_ROLE_AUDIENCE WHERE UM_USER_NAME=? AND UM_HYBRID_USER_ROLE.UM_ROLE_ID=UM_HYBRID_ROLE.UM_ID AND "
+ "UM_HYBRID_USER_ROLE.UM_TENANT_ID=? AND UM_HYBRID_ROLE.UM_TENANT_ID=? AND UM_HYBRID_ROLE.UM_AUDIENCE_REF_ID = UM_HYBRID_ROLE_AUDIENCE.UM_ID AND "
+ "UM_HYBRID_USER_ROLE.UM_DOMAIN_ID=(SELECT UM_DOMAIN_ID FROM UM_DOMAIN WHERE UM_TENANT_ID=? AND "
+ "UM_DOMAIN_NAME=?) AND UM_ROLE_NAME=?";

public static final String GET_INTERNAL_ROLE_LIST_OF_USERS_SQL = "SELECT UM_USER_NAME, UM_ROLE_NAME FROM "
+ "UM_HYBRID_USER_ROLE, UM_HYBRID_ROLE WHERE UM_USER_NAME IN (?) AND UM_HYBRID_USER_ROLE"
+ ".UM_ROLE_ID=UM_HYBRID_ROLE.UM_ID AND UM_HYBRID_USER_ROLE.UM_TENANT_ID=? AND UM_HYBRID_ROLE"
+ ".UM_TENANT_ID=? AND UM_HYBRID_USER_ROLE.UM_DOMAIN_ID=(SELECT UM_DOMAIN_ID FROM UM_DOMAIN WHERE "
+ "UM_TENANT_ID=? AND UM_DOMAIN_NAME=?)";

public static final String GET_INTERNAL_ROLE_V2_LIST_OF_USERS_SQL = "SELECT UM_USER_NAME FROM "
+ "UM_HYBRID_USER_ROLE, UM_HYBRID_ROLE, UM_HYBRID_ROLE_AUDIENCE WHERE UM_USER_NAME IN (?) AND UM_HYBRID_USER_ROLE"
+ ".UM_ROLE_ID=UM_HYBRID_ROLE.UM_ID AND UM_HYBRID_USER_ROLE.UM_TENANT_ID=? AND UM_HYBRID_ROLE"
+ ".UM_TENANT_ID=? AND UM_HYBRID_ROLE.UM_AUDIENCE_REF_ID = UM_HYBRID_ROLE_AUDIENCE.UM_ID AND UM_HYBRID_USER_ROLE.UM_DOMAIN_ID=(SELECT UM_DOMAIN_ID FROM UM_DOMAIN WHERE "
+ "UM_TENANT_ID=? AND UM_DOMAIN_NAME=?)";

public static final String GET_INTERNAL_ROLE_LIST_OF_GROUPS_SQL = "SELECT UM_GROUP_NAME, UM_ROLE_NAME FROM "
+ "UM_HYBRID_GROUP_ROLE, UM_HYBRID_ROLE WHERE UM_GROUP_NAME IN (?) AND UM_HYBRID_GROUP_ROLE"
+ ".UM_ROLE_ID=UM_HYBRID_ROLE.UM_ID AND UM_HYBRID_GROUP_ROLE.UM_TENANT_ID=? AND UM_HYBRID_ROLE"
+ ".UM_TENANT_ID=? AND UM_HYBRID_GROUP_ROLE.UM_DOMAIN_ID=(SELECT UM_DOMAIN_ID FROM UM_DOMAIN WHERE "
+ "UM_TENANT_ID=? AND UM_DOMAIN_NAME=?)";

public static final String GET_INTERNAL_ROLE_V2_LIST_OF_GROUPS_SQL = "SELECT UM_GROUP_NAME, UM_ROLE_NAME FROM "
+ "UM_HYBRID_GROUP_ROLE, UM_HYBRID_ROLE, UM_HYBRID_ROLE_AUDIENCE WHERE UM_GROUP_NAME IN (?) AND UM_HYBRID_GROUP_ROLE"
+ ".UM_ROLE_ID=UM_HYBRID_ROLE.UM_ID AND UM_HYBRID_GROUP_ROLE.UM_TENANT_ID=? AND UM_HYBRID_ROLE"
+ ".UM_TENANT_ID=? AND UM_HYBRID_ROLE.UM_AUDIENCE_REF_ID = UM_HYBRID_ROLE_AUDIENCE.UM_ID AND " +
"UM_HYBRID_GROUP_ROLE.UM_DOMAIN_ID=(SELECT UM_DOMAIN_ID FROM UM_DOMAIN WHERE "
+ "UM_TENANT_ID=? AND UM_DOMAIN_NAME=?)";

public static final String IS_USER_IN_ROLE_SQL = "SELECT UM_ROLE_ID FROM UM_HYBRID_USER_ROLE WHERE UM_USER_NAME=? " +
"AND UM_ROLE_ID=(SELECT UM_ID FROM UM_HYBRID_ROLE WHERE UM_ROLE_NAME=? AND UM_TENANT_ID=?) AND UM_TENANT_ID=?" +
"AND UM_DOMAIN_ID=(SELECT UM_DOMAIN_ID FROM UM_DOMAIN WHERE UM_TENANT_ID=? AND UM_DOMAIN_NAME=?)";
Expand All @@ -159,9 +225,17 @@ public class HybridJDBCConstants {
public static final String COUNT_INTERNAL_ROLES_SQL = "SELECT COUNT(UM_ID) AS RESULT FROM UM_HYBRID_ROLE WHERE " +
"UM_ROLE_NAME LIKE ? AND " + "UM_TENANT_ID = ?";

public static final String COUNT_INTERNAL_ROLES_V2_SQL = "SELECT COUNT(UM_HYBRID_ROLE.UM_ID) AS RESULT FROM " +
"UM_HYBRID_ROLE INNER JOIN UM_HYBRID_ROLE_AUDIENCE ON UM_HYBRID_ROLE.UM_AUDIENCE_REF_ID = UM_HYBRID_ROLE_AUDIENCE.UM_ID WHERE " +
"UM_ROLE_NAME LIKE ? AND " + "UM_TENANT_ID = ?";

public static final String COUNT_INTERNAL_ONLY_ROLES_SQL = "SELECT COUNT(UM_ID) AS RESULT FROM UM_HYBRID_ROLE " +
"WHERE UM_ROLE_NAME NOT LIKE 'Application%' AND UM_ROLE_NAME LIKE ? AND UM_TENANT_ID = ?";

public static final String COUNT_INTERNAL_ONLY_ROLES_V2_SQL = "SELECT COUNT(UM_HYBRID_ROLE.UM_ID) AS RESULT FROM " +
"UM_HYBRID_ROLE INNER JOIN UM_HYBRID_ROLE_AUDIENCE ON UM_HYBRID_ROLE.UM_AUDIENCE_REF_ID = UM_HYBRID_ROLE_AUDIENCE.UM_ID " +
"WHERE UM_ROLE_NAME NOT LIKE 'Application%' AND UM_ROLE_NAME LIKE ? AND UM_TENANT_ID = ?";

public static final String GET_GROUP_ROLE_MAPPING_ID = "SELECT UM_ID FROM UM_HYBRID_GROUP_ROLE WHERE UM_GROUP_NAME = ? " +
"AND UM_TENANT_ID = ?";

Expand Down
Loading