Skip to content

Commit b4d232d

Browse files
FINERACT-1430: Fix social status access restriction implementation
1 parent 2fb764c commit b4d232d

7 files changed

Lines changed: 67 additions & 27 deletions

File tree

fineract-core/src/main/java/org/apache/fineract/infrastructure/security/service/PermissionConstants.java

Lines changed: 0 additions & 8 deletions
This file was deleted.

fineract-core/src/main/java/org/apache/fineract/portfolio/client/domain/Client.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,9 @@ public class Client extends AbstractAuditableWithUTCDateTimeCustom<Long> {
195195
@JoinColumn(name = "client_classification_cv_id")
196196
private CodeValue clientClassification;
197197

198-
@Column(name = "social_status_cv_id")
199-
private Long socialStatus;
198+
@ManyToOne(fetch = FetchType.LAZY)
199+
@JoinColumn(name = "social_status_cv_id")
200+
private CodeValue socialStatus;
200201

201202
@Column(name = "legal_form_enum")
202203
private Integer legalForm;

fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientReadPlatformServiceImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import org.apache.fineract.infrastructure.core.service.PaginationHelper;
4343
import org.apache.fineract.infrastructure.core.service.SearchParameters;
4444
import org.apache.fineract.infrastructure.core.service.database.DatabaseSpecificSQLGenerator;
45-
import org.apache.fineract.infrastructure.security.service.PermissionConstants;
4645
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
4746
import org.apache.fineract.infrastructure.security.utils.ColumnValidator;
4847
import org.apache.fineract.portfolio.client.data.ClientCollateralManagementData;
@@ -68,6 +67,8 @@
6867
@RequiredArgsConstructor
6968
public class ClientReadPlatformServiceImpl implements ClientReadPlatformService {
7069

70+
private static final String READ_HIGH_PROFILE_CLIENT = "READ_HIGH_PROFILE_CLIENT";
71+
7172
private final JdbcTemplate jdbcTemplate;
7273
private final PlatformSecurityContext context;
7374
private final CodeValueReadPlatformService codeValueReadPlatformService;
@@ -215,7 +216,7 @@ public ClientData retrieveOne(final Long clientId) {
215216

216217
final Client client = clientRepositoryWrapper.getClientByClientIdAndHierarchy(clientId, hierarchySearchString);
217218
if (client.getSocialStatus() != null) {
218-
context.authenticatedUser().validateHasPermissionTo(PermissionConstants.CAN_VIEW_HIGH_PROFILE_CLIENT);
219+
context.authenticatedUser().validateHasPermissionTo(READ_HIGH_PROFILE_CLIENT);
219220
}
220221
final ClientData clientData = clientMapper.map(client);
221222

fineract-provider/src/main/resources/db/changelog/FINERACT-1430-add-social-status.xml

Lines changed: 0 additions & 14 deletions
This file was deleted.

fineract-provider/src/main/resources/db/changelog/db.changelog-master.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
<include file="tenant-store/changelog-tenant-store.xml" relativeToChangelogFile="true" context="tenant_store_db AND !initial_switch"/>
3232
<include file="tenant/initial-switch-changelog-tenant.xml" relativeToChangelogFile="true" context="tenant_db AND initial_switch"/>
3333
<include file="tenant/changelog-tenant.xml" relativeToChangelogFile="true" context="tenant_db AND !initial_switch"/>
34-
<include file="FINERACT-1430-add-social-status.xml" relativeToChangelogFile="true" context="tenant_db AND !initial_switch"/>
3534
<!-- Add new module to the end of this modules list (to keep the existing auto-increment identifiers) -->
3635
<include file="db/changelog/tenant/module/loan/module-changelog-master.xml" context="tenant_db AND !initial_switch"/>
3736
<include file="db/changelog/tenant/module/investor/module-changelog-master.xml" context="tenant_db AND !initial_switch"/>

fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,5 @@
227227
<include file="parts/0206_transaction_summary_with_asset_owner_classification_name_bug_fix.xml" relativeToChangelogFile="true" />
228228
<include file="parts/0207_add_allow_full_term_for_tranche.xml" relativeToChangelogFile="true" />
229229
<include file="parts/0208_trial_balance_summary_with_asset_owner_journal_entry_aggregation_fix.xml" relativeToChangelogFile="true" />
230+
<include file="parts/0209_add_social_status_restriction.xml" relativeToChangelogFile="true" />
230231
</databaseChangeLog>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
21+
-->
22+
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
23+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
24+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.3.xsd">
25+
<changeSet id="1" author="fineract">
26+
<preConditions onFail="MARK_RAN">
27+
<not>
28+
<columnExists tableName="m_client" columnName="social_status_cv_id"/>
29+
</not>
30+
</preConditions>
31+
<addColumn tableName="m_client">
32+
<column name="social_status_cv_id" type="INT"/>
33+
</addColumn>
34+
</changeSet>
35+
36+
<changeSet id="2" author="fineract">
37+
<preConditions onFail="MARK_RAN">
38+
<not>
39+
<foreignKeyConstraintExists foreignKeyName="fk_client_social_status"/>
40+
</not>
41+
</preConditions>
42+
<addForeignKeyConstraint baseTableName="m_client" baseColumnNames="social_status_cv_id" referencedTableName="m_code_value"
43+
referencedColumnNames="id" constraintName="fk_client_social_status"/>
44+
</changeSet>
45+
46+
<changeSet id="3" author="fineract">
47+
<preConditions onFail="MARK_RAN">
48+
<sqlCheck expectedResult="0">
49+
SELECT COUNT(1) FROM m_permission WHERE code = 'READ_HIGH_PROFILE_CLIENT'
50+
</sqlCheck>
51+
</preConditions>
52+
<insert tableName="m_permission">
53+
<column name="grouping" value="portfolio"/>
54+
<column name="code" value="READ_HIGH_PROFILE_CLIENT"/>
55+
<column name="entity_name" value="HIGH_PROFILE_CLIENT"/>
56+
<column name="action_name" value="READ"/>
57+
<column name="can_maker_checker" valueBoolean="false"/>
58+
</insert>
59+
</changeSet>
60+
</databaseChangeLog>

0 commit comments

Comments
 (0)