wip permissions
This commit is contained in:
@@ -47,12 +47,8 @@ public class ChargesApiResource {
|
|||||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||||
|
|
||||||
private final String entityType = "CHARGE";
|
private final String entityType = "CHARGE";
|
||||||
private final PlatformSecurityContext context;
|
@Autowired
|
||||||
|
private PlatformSecurityContext context;
|
||||||
@Autowired
|
|
||||||
public ChargesApiResource(final PlatformSecurityContext context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Consumes({MediaType.APPLICATION_JSON})
|
@Consumes({MediaType.APPLICATION_JSON})
|
||||||
|
|||||||
+2
-6
@@ -55,12 +55,8 @@ public class ClientIdentifiersApiResource {
|
|||||||
"documentKey", "documentTypeName"));
|
"documentKey", "documentTypeName"));
|
||||||
|
|
||||||
private final String entityType = "CLIENTIDENTIFIER";
|
private final String entityType = "CLIENTIDENTIFIER";
|
||||||
private final PlatformSecurityContext context;
|
@Autowired
|
||||||
|
private PlatformSecurityContext context;
|
||||||
@Autowired
|
|
||||||
public ClientIdentifiersApiResource(final PlatformSecurityContext context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
|
|||||||
@@ -85,12 +85,8 @@ public class ClientsApiResource {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PortfolioMakerCheckerReadPlatformService makerCheckerReadPlatformService;
|
private PortfolioMakerCheckerReadPlatformService makerCheckerReadPlatformService;
|
||||||
|
|
||||||
private final PlatformSecurityContext context;
|
@Autowired
|
||||||
|
private PlatformSecurityContext context;
|
||||||
@Autowired
|
|
||||||
public ClientsApiResource(final PlatformSecurityContext context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Consumes({MediaType.APPLICATION_JSON})
|
@Consumes({MediaType.APPLICATION_JSON})
|
||||||
|
|||||||
@@ -46,12 +46,8 @@ public class CodesApiResource {
|
|||||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||||
|
|
||||||
private final String entityType = "CODE";
|
private final String entityType = "CODE";
|
||||||
private final PlatformSecurityContext context;
|
@Autowired
|
||||||
|
private PlatformSecurityContext context;
|
||||||
@Autowired
|
|
||||||
public CodesApiResource(final PlatformSecurityContext context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Consumes({MediaType.APPLICATION_JSON})
|
@Consumes({MediaType.APPLICATION_JSON})
|
||||||
|
|||||||
+2
-5
@@ -43,12 +43,9 @@ public class ConfigurationApiResource {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||||
|
|
||||||
private final PlatformSecurityContext context;
|
@Autowired
|
||||||
|
private PlatformSecurityContext context;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public ConfigurationApiResource(final PlatformSecurityContext context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
@GET
|
@GET
|
||||||
@Path("currency")
|
@Path("currency")
|
||||||
@Consumes({MediaType.APPLICATION_JSON})
|
@Consumes({MediaType.APPLICATION_JSON})
|
||||||
|
|||||||
@@ -47,12 +47,8 @@ public class DataTableApiResource {
|
|||||||
private final static Logger logger = LoggerFactory
|
private final static Logger logger = LoggerFactory
|
||||||
.getLogger(DataTableApiResource.class);
|
.getLogger(DataTableApiResource.class);
|
||||||
|
|
||||||
private final PlatformSecurityContext context;
|
@Autowired
|
||||||
|
private PlatformSecurityContext context;
|
||||||
@Autowired
|
|
||||||
public DataTableApiResource(final PlatformSecurityContext context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private GenericDataService genericDataService;
|
private GenericDataService genericDataService;
|
||||||
|
|||||||
+11
@@ -31,6 +31,7 @@ import org.mifosng.platform.common.FileUtils;
|
|||||||
import org.mifosng.platform.documentmanagement.service.DocumentReadPlatformService;
|
import org.mifosng.platform.documentmanagement.service.DocumentReadPlatformService;
|
||||||
import org.mifosng.platform.documentmanagement.service.DocumentWritePlatformService;
|
import org.mifosng.platform.documentmanagement.service.DocumentWritePlatformService;
|
||||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||||
|
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;
|
||||||
@@ -57,6 +58,10 @@ public class DocumentManagementApiResource {
|
|||||||
Arrays.asList("id", "parentEntityType", "parentEntityId", "name",
|
Arrays.asList("id", "parentEntityType", "parentEntityId", "name",
|
||||||
"fileName", "type", "size", "description"));
|
"fileName", "type", "size", "description"));
|
||||||
|
|
||||||
|
private final String SystemEntityType = "DOCUMENT";
|
||||||
|
@Autowired
|
||||||
|
private PlatformSecurityContext context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param uriInfo
|
* @param uriInfo
|
||||||
* @param entityType
|
* @param entityType
|
||||||
@@ -70,6 +75,8 @@ public class DocumentManagementApiResource {
|
|||||||
@PathParam("entityType") String entityType,
|
@PathParam("entityType") String entityType,
|
||||||
@PathParam("entityId") Long entityId) {
|
@PathParam("entityId") Long entityId) {
|
||||||
|
|
||||||
|
context.authenticatedUser().validateHasReadPermission(SystemEntityType);
|
||||||
|
|
||||||
Set<String> responseParameters = ApiParameterHelper
|
Set<String> responseParameters = ApiParameterHelper
|
||||||
.extractFieldsForResponseIfProvided(uriInfo
|
.extractFieldsForResponseIfProvided(uriInfo
|
||||||
.getQueryParameters());
|
.getQueryParameters());
|
||||||
@@ -204,6 +211,8 @@ public class DocumentManagementApiResource {
|
|||||||
@PathParam("documentId") Long documentId,
|
@PathParam("documentId") Long documentId,
|
||||||
@Context final UriInfo uriInfo) {
|
@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
|
context.authenticatedUser().validateHasReadPermission(SystemEntityType);
|
||||||
|
|
||||||
Set<String> responseParameters = ApiParameterHelper
|
Set<String> responseParameters = ApiParameterHelper
|
||||||
.extractFieldsForResponseIfProvided(uriInfo
|
.extractFieldsForResponseIfProvided(uriInfo
|
||||||
.getQueryParameters());
|
.getQueryParameters());
|
||||||
@@ -235,6 +244,8 @@ public class DocumentManagementApiResource {
|
|||||||
@PathParam("entityId") Long entityId,
|
@PathParam("entityId") Long entityId,
|
||||||
@PathParam("documentId") Long documentId) {
|
@PathParam("documentId") Long documentId) {
|
||||||
|
|
||||||
|
context.authenticatedUser().validateHasReadPermission(SystemEntityType);
|
||||||
|
|
||||||
DocumentData documentData = this.documentReadPlatformService
|
DocumentData documentData = this.documentReadPlatformService
|
||||||
.retrieveDocument(entityType, entityId, documentId);
|
.retrieveDocument(entityType, entityId, documentId);
|
||||||
File file = new File(documentData.getLocation());
|
File file = new File(documentData.getLocation());
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService
|
|||||||
import org.mifosng.platform.fund.service.FundReadPlatformService;
|
import org.mifosng.platform.fund.service.FundReadPlatformService;
|
||||||
import org.mifosng.platform.fund.service.FundWritePlatformService;
|
import org.mifosng.platform.fund.service.FundWritePlatformService;
|
||||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||||
|
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 FundsApiResource {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||||
|
|
||||||
|
private final String entityType = "FUND";
|
||||||
|
@Autowired
|
||||||
|
private PlatformSecurityContext context;
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Consumes({MediaType.APPLICATION_JSON})
|
@Consumes({MediaType.APPLICATION_JSON})
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
@Produces({MediaType.APPLICATION_JSON})
|
||||||
public String retrieveFunds(@Context final UriInfo uriInfo) {
|
public String retrieveFunds(@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
|
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||||
|
|
||||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||||
|
|
||||||
@@ -73,7 +80,9 @@ public class FundsApiResource {
|
|||||||
@Path("{fundId}")
|
@Path("{fundId}")
|
||||||
@Consumes({MediaType.APPLICATION_JSON})
|
@Consumes({MediaType.APPLICATION_JSON})
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
@Produces({MediaType.APPLICATION_JSON})
|
||||||
public String retreiveOffice(@PathParam("fundId") final Long fundId, @Context final UriInfo uriInfo) {
|
public String retreiveFund(@PathParam("fundId") final Long fundId, @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());
|
||||||
|
|||||||
@@ -32,12 +32,8 @@ import org.springframework.stereotype.Component;
|
|||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
public class ReportsApiResource {
|
public class ReportsApiResource {
|
||||||
|
|
||||||
private final PlatformSecurityContext context;
|
@Autowired
|
||||||
|
private PlatformSecurityContext context;
|
||||||
@Autowired
|
|
||||||
public ReportsApiResource(final PlatformSecurityContext context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ReadReportingService readExtraDataAndReportingService;
|
private ReadReportingService readExtraDataAndReportingService;
|
||||||
|
|||||||
+3
-4
@@ -7,15 +7,14 @@ import org.mifosng.platform.api.data.EntityIdentifier;
|
|||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
|
||||||
public interface DocumentWritePlatformService {
|
public interface DocumentWritePlatformService {
|
||||||
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_DOCUMENT')")
|
||||||
@PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')")
|
|
||||||
Long createDocument(DocumentCommand documentCommand, InputStream inputStream);
|
Long createDocument(DocumentCommand documentCommand, InputStream inputStream);
|
||||||
|
|
||||||
@PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')")
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_DOCUMENT')")
|
||||||
EntityIdentifier updateDocument(DocumentCommand documentCommand,
|
EntityIdentifier updateDocument(DocumentCommand documentCommand,
|
||||||
InputStream inputStream);
|
InputStream inputStream);
|
||||||
|
|
||||||
@PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')")
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_DOCUMENT')")
|
||||||
EntityIdentifier deleteDocument(DocumentCommand documentCommand);
|
EntityIdentifier deleteDocument(DocumentCommand documentCommand);
|
||||||
|
|
||||||
}
|
}
|
||||||
+2
-2
@@ -5,9 +5,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
|
|
||||||
public interface FundWritePlatformService {
|
public interface FundWritePlatformService {
|
||||||
|
|
||||||
@PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')")
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'ORGANISATION_ADMINISTRATION_SUPER_USER', 'CREATE_FUND')")
|
||||||
Long createFund(final FundCommand command);
|
Long createFund(final FundCommand command);
|
||||||
|
|
||||||
@PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')")
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'ORGANISATION_ADMINISTRATION_SUPER_USER', 'UPDATE_FUND')")
|
||||||
Long updateFund(final FundCommand command);
|
Long updateFund(final FundCommand command);
|
||||||
}
|
}
|
||||||
@@ -346,6 +346,10 @@ public class AppUser extends AbstractAuditableCustom<AppUser, Long> implements
|
|||||||
higherPermission = "ORGANISATION_ADMINISTRATION_SUPER_USER";
|
higherPermission = "ORGANISATION_ADMINISTRATION_SUPER_USER";
|
||||||
} else if (entityType.equalsIgnoreCase("CURRENCY")) {
|
} else if (entityType.equalsIgnoreCase("CURRENCY")) {
|
||||||
higherPermission = "ORGANISATION_ADMINISTRATION_SUPER_USER";
|
higherPermission = "ORGANISATION_ADMINISTRATION_SUPER_USER";
|
||||||
|
} else if (entityType.equalsIgnoreCase("DOCUMENTMAN")) {
|
||||||
|
higherPermission = "PORTFOLIO_MANAGEMENT_SUPER_USER";
|
||||||
|
} else if (entityType.equalsIgnoreCase("FUND")) {
|
||||||
|
higherPermission = "ORGANISATION_ADMINISTRATION_SUPER_USER";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(higherPermission.equals(""))) {
|
if (!(higherPermission.equals(""))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user