wip permissions
This commit is contained in:
@@ -22,6 +22,7 @@ import org.mifosng.platform.exceptions.UnrecognizedQueryParamException;
|
|||||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||||
import org.mifosng.platform.makerchecker.service.PortfolioMakerCheckerReadPlatformService;
|
import org.mifosng.platform.makerchecker.service.PortfolioMakerCheckerReadPlatformService;
|
||||||
import org.mifosng.platform.makerchecker.service.PortfolioMakerCheckerWriteService;
|
import org.mifosng.platform.makerchecker.service.PortfolioMakerCheckerWriteService;
|
||||||
|
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -40,11 +41,17 @@ public class MakerCheckerApiResource {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||||
|
|
||||||
|
private final String entityType = "MAKERCHECKER";
|
||||||
|
@Autowired
|
||||||
|
private PlatformSecurityContext context;
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Consumes({MediaType.APPLICATION_JSON})
|
@Consumes({MediaType.APPLICATION_JSON})
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
@Produces({MediaType.APPLICATION_JSON})
|
||||||
public String retrieveCodes(@Context final UriInfo uriInfo) {
|
public String retrieveCodes(@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
|
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||||
|
|
||||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||||
|
|
||||||
|
|||||||
+9
@@ -23,6 +23,7 @@ import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService
|
|||||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||||
import org.mifosng.platform.organisation.service.OfficeWritePlatformService;
|
import org.mifosng.platform.organisation.service.OfficeWritePlatformService;
|
||||||
|
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -44,11 +45,17 @@ public class OfficeTransactionsApiResource {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||||
|
|
||||||
|
private final String entityType = "OFFICE";
|
||||||
|
@Autowired
|
||||||
|
private PlatformSecurityContext context;
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String retrieveOfficeTransactions(@Context final UriInfo uriInfo) {
|
public String retrieveOfficeTransactions(@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
|
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||||
|
|
||||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||||
Arrays.asList("id", "transactionDate", "fromOfficeId",
|
Arrays.asList("id", "transactionDate", "fromOfficeId",
|
||||||
"fromOfficeName", "toOfficeId", "toOfficeIdName",
|
"fromOfficeName", "toOfficeId", "toOfficeIdName",
|
||||||
@@ -78,6 +85,8 @@ public class OfficeTransactionsApiResource {
|
|||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String newOfficeTransactionDetails(@Context final UriInfo uriInfo) {
|
public String newOfficeTransactionDetails(@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
|
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||||
|
|
||||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||||
Arrays.asList("id", "transactionDate", "allowedOffices",
|
Arrays.asList("id", "transactionDate", "allowedOffices",
|
||||||
"currencyOptions"));
|
"currencyOptions"));
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService
|
|||||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||||
import org.mifosng.platform.organisation.service.OfficeWritePlatformService;
|
import org.mifosng.platform.organisation.service.OfficeWritePlatformService;
|
||||||
|
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -49,11 +50,17 @@ public class OfficesApiResource {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||||
|
|
||||||
|
private final String entityType = "OFFICE";
|
||||||
|
@Autowired
|
||||||
|
private PlatformSecurityContext context;
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Consumes({MediaType.APPLICATION_JSON})
|
@Consumes({MediaType.APPLICATION_JSON})
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
@Produces({MediaType.APPLICATION_JSON})
|
||||||
public String retrieveOffices(@Context final UriInfo uriInfo) {
|
public String retrieveOffices(@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
|
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||||
|
|
||||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||||
Arrays.asList("id", "name", "nameDecorated", "externalId", "openingDate",
|
Arrays.asList("id", "name", "nameDecorated", "externalId", "openingDate",
|
||||||
"hierarchy", "parentId", "parentName"));
|
"hierarchy", "parentId", "parentName"));
|
||||||
@@ -75,6 +82,8 @@ public class OfficesApiResource {
|
|||||||
@Produces({MediaType.APPLICATION_JSON})
|
@Produces({MediaType.APPLICATION_JSON})
|
||||||
public String retrieveOfficeTemplate(@Context final UriInfo uriInfo) {
|
public String retrieveOfficeTemplate(@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
|
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||||
|
|
||||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||||
Arrays.asList("id", "name", "nameDecorated", "externalId", "openingDate",
|
Arrays.asList("id", "name", "nameDecorated", "externalId", "openingDate",
|
||||||
"hierarchy", "parentId", "parentName", "allowedParents"));
|
"hierarchy", "parentId", "parentName", "allowedParents"));
|
||||||
@@ -107,6 +116,8 @@ public class OfficesApiResource {
|
|||||||
@Produces({MediaType.APPLICATION_JSON})
|
@Produces({MediaType.APPLICATION_JSON})
|
||||||
public String retreiveOffice(@PathParam("officeId") final Long officeId, @Context final UriInfo uriInfo) {
|
public String retreiveOffice(@PathParam("officeId") final Long officeId, @Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
|
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||||
|
|
||||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||||
Arrays.asList("id", "name", "nameDecorated", "externalId", "openingDate",
|
Arrays.asList("id", "name", "nameDecorated", "externalId", "openingDate",
|
||||||
"hierarchy", "parentId", "parentName"));
|
"hierarchy", "parentId", "parentName"));
|
||||||
|
|||||||
+2
@@ -1,6 +1,8 @@
|
|||||||
package org.mifosng.platform.makerchecker.service;
|
package org.mifosng.platform.makerchecker.service;
|
||||||
|
|
||||||
|
|
||||||
public interface PortfolioMakerCheckerWriteService {
|
public interface PortfolioMakerCheckerWriteService {
|
||||||
|
//TODO - permissions on this to be done after development completes
|
||||||
|
|
||||||
Long logNewEntry(String taskName, String taskJson);
|
Long logNewEntry(String taskName, String taskJson);
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -6,12 +6,13 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
|
|
||||||
public interface OfficeWritePlatformService {
|
public interface OfficeWritePlatformService {
|
||||||
|
|
||||||
@PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')")
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'ORGANISATION_ADMINISTRATION_SUPER_USER', 'CREATE_OFFICE')")
|
||||||
Long createOffice(final OfficeCommand command);
|
Long createOffice(final OfficeCommand command);
|
||||||
|
|
||||||
@PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')")
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'ORGANISATION_ADMINISTRATION_SUPER_USER', 'UPDATE_OFFICE')")
|
||||||
Long updateOffice(final OfficeCommand command);
|
Long updateOffice(final OfficeCommand command);
|
||||||
|
|
||||||
@PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')")
|
//TODO - complete permissions for office transactions when more functionality add or it is replaced by simple accounting equivalent (JPW)
|
||||||
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'ORGANISATION_ADMINISTRATION_SUPER_USER')")
|
||||||
Long externalBranchMoneyTransfer(BranchMoneyTransferCommand command);
|
Long externalBranchMoneyTransfer(BranchMoneyTransferCommand command);
|
||||||
}
|
}
|
||||||
@@ -356,6 +356,10 @@ public class AppUser extends AbstractAuditableCustom<AppUser, Long> implements
|
|||||||
higherPermission = "ORGANISATION_ADMINISTRATION_SUPER_USER";
|
higherPermission = "ORGANISATION_ADMINISTRATION_SUPER_USER";
|
||||||
} else if (entityType.equalsIgnoreCase("LOAN")) {
|
} else if (entityType.equalsIgnoreCase("LOAN")) {
|
||||||
higherPermission = "PORTFOLIO_MANAGEMENT_SUPER_USER";
|
higherPermission = "PORTFOLIO_MANAGEMENT_SUPER_USER";
|
||||||
|
} else if (entityType.equalsIgnoreCase("OFFICE")) {
|
||||||
|
higherPermission = "ORGANISATION_ADMINISTRATION_SUPER_USER";
|
||||||
|
} else if (entityType.equalsIgnoreCase("OFFICETRANSACTION")) {
|
||||||
|
higherPermission = "ORGANISATION_ADMINISTRATION_SUPER_USER";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(higherPermission.equals(""))) {
|
if (!(higherPermission.equals(""))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user