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

Introduce application role #4873

Closed
wants to merge 21 commits into from

Conversation

shashimalcse
Copy link
Contributor

@shashimalcse shashimalcse commented Aug 28, 2023

userStoreManager = getUserStoreManager(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
return userStoreManager.isGroupExist(id);
} catch (UserStoreException e) {
throw new ApplicationRoleManagementServerException("Error occurred while retrieving the userstore manager "
Copy link
Contributor

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?

<version>${maven.surefire.plugin.version}</version>
<configuration>
<argLine>
--add-opens java.xml/jdk.xml.internal=ALL-UNNAMED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix formatting

Comment on lines 95 to 101
// 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);
}
Copy link
Contributor

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();
Copy link
Contributor

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> {
Copy link
Contributor

@ThaminduR ThaminduR Sep 7, 2023

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 {
Copy link
Contributor

@ThaminduR ThaminduR Sep 7, 2023

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 " +
Copy link
Contributor

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.

Comment on lines 132 to 133
public static final String USER_ROLE_UNIQUE_CONSTRAINT = "user_role_unique";
public static final String GROUP_ROLE_UNIQUE_CONSTRAINT = "group_role_unique";
Copy link
Contributor

@ThaminduR ThaminduR Sep 7, 2023

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

Comment on lines +48 to +57
private static final ApplicationRoleManager instance = new ApplicationRoleManagerImpl();

private ApplicationRoleManagerImpl() {

}

public static ApplicationRoleManager getInstance() {

return instance;
}
Copy link
Contributor

@sadilchamishka sadilchamishka Sep 7, 2023

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

@shashimalcse shashimalcse changed the title Introduce application role groups and users assign Introduce application role Sep 7, 2023
@shashimalcse
Copy link
Contributor Author

fixed via : wso2/product-is#16363

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants