After various research i came up with this:
private void removePermissions() throws PortalException {
List<String> portletList = Arrays.asList("com_liferay_users_admin_web_portlet_MyOrganizationsPortlet",
"com_liferay_my_account_web_portlet_MyAccountPortlet",
"com_liferay_portal_workflow_web_internal_portlet_UserWorkflowPortlet",
"com_liferay_portal_workflow_task_web_portlet_MyWorkflowTaskPortlet",
"com_liferay_notifications_web_portlet_NotificationsPortlet",
"com_liferay_sharing_web_portlet_SharedAssetsPortlet",
"com_liferay_oauth2_provider_web_internal_portlet_OAuth2ConnectedApplicationsPortlet"
);
String primKey = String.valueOf(company.getPrimaryKey());
for (String portlet : portletList) {
ResourcePermissionLocalServiceUtil.removeResourcePermission(
companyId,
portlet,
ResourceConstants.SCOPE_COMPANY,
primKey,
userRole.getRoleId(),
"ACCESS_IN_CONTROL_PANEL");
}
}
companyId, userRole can be achieved via RoleLocalServiceUtil and CompanyLocalServiceUtil. PrimKey is differs based on scope, this blog helped me a lot understanding it. I sniffed names of portlets through developer console when removing permissions through GUI. I haven't found cleaner solution.