-
Notifications
You must be signed in to change notification settings - Fork 543
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
Introduce application role #4873
Conversation
.../src/main/java/org/wso2/carbon/identity/application/role/mgt/ApplicationRoleManagerImpl.java
Outdated
Show resolved
Hide resolved
...t/src/main/java/org/wso2/carbon/identity/application/role/mgt/dao/ApplicationRoleMgtDAO.java
Show resolved
Hide resolved
...n/java/org/wso2/carbon/identity/application/role/mgt/dao/impl/ApplicationRoleMgtDAOImpl.java
Outdated
Show resolved
Hide resolved
...n/java/org/wso2/carbon/identity/application/role/mgt/dao/impl/ApplicationRoleMgtDAOImpl.java
Outdated
Show resolved
Hide resolved
...n/java/org/wso2/carbon/identity/application/role/mgt/dao/impl/ApplicationRoleMgtDAOImpl.java
Show resolved
Hide resolved
...g/wso2/carbon/identity/application/role/mgt/internal/ApplicationRoleMgtServiceComponent.java
Show resolved
Hide resolved
...le.mgt/src/main/java/org/wso2/carbon/identity/application/role/mgt/util/GroupIDResolver.java
Outdated
Show resolved
Hide resolved
...le.mgt/src/main/java/org/wso2/carbon/identity/application/role/mgt/util/GroupIDResolver.java
Outdated
Show resolved
Hide resolved
userStoreManager = getUserStoreManager(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); | ||
return userStoreManager.isGroupExist(id); | ||
} catch (UserStoreException e) { | ||
throw new ApplicationRoleManagementServerException("Error occurred while retrieving the userstore manager " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can move these to error message contants and use them right?
...on.role.mgt/src/main/java/org/wso2/carbon/identity/application/role/mgt/util/IDResolver.java
Outdated
Show resolved
Hide resolved
<version>${maven.surefire.plugin.version}</version> | ||
<configuration> | ||
<argLine> | ||
--add-opens java.xml/jdk.xml.internal=ALL-UNNAMED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix formatting
// Check whether new role name is already exists. | ||
boolean existingRole = | ||
applicationRoleMgtDAO.isExistingRole(applicationId, newName, tenantDomain); | ||
if (existingRole) { | ||
throw handleClientException(ERROR_CODE_DUPLICATE_ROLE, newName, | ||
applicationId); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we refactor this into a private method since this is being used in several places? Basically to have a method to validate the roleName
public ApplicationRole addApplicationRole(ApplicationRole applicationRole) | ||
throws ApplicationRoleManagementException { | ||
|
||
String tenantDomain = ApplicationRoleMgtUtils.getTenantDomain(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once role name validation is refactored into a private method, we won't need this variable.
/** | ||
* Cache implementation for application role cache. | ||
*/ | ||
public class ApplicationRoleCache extends BaseCache<ApplicationRoleCacheKey, ApplicationRoleCacheEntry> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is Cache By Id, let's rename appropriately. Don't we need another cache impl for Cache by Name?
/** | ||
* Cache key to lookup application role from cache. | ||
*/ | ||
public class ApplicationRoleCacheKey extends CacheKey { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is cache key by role id, et's rename accordingly.
SQLPlaceholders.DB_SCHEMA_COLUMN_NAME_ROLE_ID + "; AND SCOPE_NAME = :" + | ||
SQLPlaceholders.DB_SCHEMA_COLUMN_NAME_SCOPE_NAME + "; AND TENANT_ID = :" + | ||
SQLPlaceholders.DB_SCHEMA_COLUMN_NAME_TENANT_ID + ";"; | ||
public static final String GET_APPLICATION_ROLE_BY_ID = "SELECT ROLE_ID, ROLE_NAME, TENANT_ID, APP_ID " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a new line to keep the consistency. Check other places as well.
public static final String USER_ROLE_UNIQUE_CONSTRAINT = "user_role_unique"; | ||
public static final String GROUP_ROLE_UNIQUE_CONSTRAINT = "group_role_unique"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this to the top? or just before the inner class
private static final ApplicationRoleManager instance = new ApplicationRoleManagerImpl(); | ||
|
||
private ApplicationRoleManagerImpl() { | ||
|
||
} | ||
|
||
public static ApplicationRoleManager getInstance() { | ||
|
||
return instance; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for providing the singleton behaviour for this class. Normally these services are consumed by other modules by requesting the service objects via OSGI references. No harm, but just to know whether any practice
fixed via : wso2/product-is#16363 |
Proposed changes in this pull request
$subject
Related Issues