wip permissions

This commit is contained in:
John Woodlock
2012-11-15 13:26:36 +00:00
parent 0f2b5fd05d
commit ac353ec28e
12 changed files with 46 additions and 50 deletions
@@ -47,12 +47,8 @@ public class ChargesApiResource {
private PortfolioApiJsonSerializerService apiJsonSerializerService;
private final String entityType = "CHARGE";
private final PlatformSecurityContext context;
@Autowired
public ChargesApiResource(final PlatformSecurityContext context) {
this.context = context;
}
@Autowired
private PlatformSecurityContext context;
@GET
@Consumes({MediaType.APPLICATION_JSON})
@@ -55,12 +55,8 @@ public class ClientIdentifiersApiResource {
"documentKey", "documentTypeName"));
private final String entityType = "CLIENTIDENTIFIER";
private final PlatformSecurityContext context;
@Autowired
public ClientIdentifiersApiResource(final PlatformSecurityContext context) {
this.context = context;
}
@Autowired
private PlatformSecurityContext context;
@GET
@Consumes({ MediaType.APPLICATION_JSON })
@@ -85,12 +85,8 @@ public class ClientsApiResource {
@Autowired
private PortfolioMakerCheckerReadPlatformService makerCheckerReadPlatformService;
private final PlatformSecurityContext context;
@Autowired
public ClientsApiResource(final PlatformSecurityContext context) {
this.context = context;
}
@Autowired
private PlatformSecurityContext context;
@GET
@Consumes({MediaType.APPLICATION_JSON})
@@ -46,12 +46,8 @@ public class CodesApiResource {
private PortfolioApiJsonSerializerService apiJsonSerializerService;
private final String entityType = "CODE";
private final PlatformSecurityContext context;
@Autowired
public CodesApiResource(final PlatformSecurityContext context) {
this.context = context;
}
@Autowired
private PlatformSecurityContext context;
@GET
@Consumes({MediaType.APPLICATION_JSON})
@@ -43,12 +43,9 @@ public class ConfigurationApiResource {
@Autowired
private PortfolioApiJsonSerializerService apiJsonSerializerService;
private final PlatformSecurityContext context;
@Autowired
public ConfigurationApiResource(final PlatformSecurityContext context) {
this.context = context;
}
@Autowired
private PlatformSecurityContext context;
@GET
@Path("currency")
@Consumes({MediaType.APPLICATION_JSON})
@@ -47,12 +47,8 @@ public class DataTableApiResource {
private final static Logger logger = LoggerFactory
.getLogger(DataTableApiResource.class);
private final PlatformSecurityContext context;
@Autowired
public DataTableApiResource(final PlatformSecurityContext context) {
this.context = context;
}
@Autowired
private PlatformSecurityContext context;
@Autowired
private GenericDataService genericDataService;
@@ -31,6 +31,7 @@ import org.mifosng.platform.common.FileUtils;
import org.mifosng.platform.documentmanagement.service.DocumentReadPlatformService;
import org.mifosng.platform.documentmanagement.service.DocumentWritePlatformService;
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
import org.mifosng.platform.security.PlatformSecurityContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@@ -57,6 +58,10 @@ public class DocumentManagementApiResource {
Arrays.asList("id", "parentEntityType", "parentEntityId", "name",
"fileName", "type", "size", "description"));
private final String SystemEntityType = "DOCUMENT";
@Autowired
private PlatformSecurityContext context;
/**
* @param uriInfo
* @param entityType
@@ -70,6 +75,8 @@ public class DocumentManagementApiResource {
@PathParam("entityType") String entityType,
@PathParam("entityId") Long entityId) {
context.authenticatedUser().validateHasReadPermission(SystemEntityType);
Set<String> responseParameters = ApiParameterHelper
.extractFieldsForResponseIfProvided(uriInfo
.getQueryParameters());
@@ -204,6 +211,8 @@ public class DocumentManagementApiResource {
@PathParam("documentId") Long documentId,
@Context final UriInfo uriInfo) {
context.authenticatedUser().validateHasReadPermission(SystemEntityType);
Set<String> responseParameters = ApiParameterHelper
.extractFieldsForResponseIfProvided(uriInfo
.getQueryParameters());
@@ -235,6 +244,8 @@ public class DocumentManagementApiResource {
@PathParam("entityId") Long entityId,
@PathParam("documentId") Long documentId) {
context.authenticatedUser().validateHasReadPermission(SystemEntityType);
DocumentData documentData = this.documentReadPlatformService
.retrieveDocument(entityType, entityId, documentId);
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.FundWritePlatformService;
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
import org.mifosng.platform.security.PlatformSecurityContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@@ -43,12 +44,18 @@ public class FundsApiResource {
@Autowired
private PortfolioApiJsonSerializerService apiJsonSerializerService;
private final String entityType = "FUND";
@Autowired
private PlatformSecurityContext context;
@GET
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
public String retrieveFunds(@Context final UriInfo uriInfo) {
context.authenticatedUser().validateHasReadPermission(entityType);
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
@@ -73,8 +80,10 @@ public class FundsApiResource {
@Path("{fundId}")
@Consumes({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 boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
@@ -32,12 +32,8 @@ import org.springframework.stereotype.Component;
@Scope("singleton")
public class ReportsApiResource {
private final PlatformSecurityContext context;
@Autowired
public ReportsApiResource(final PlatformSecurityContext context) {
this.context = context;
}
@Autowired
private PlatformSecurityContext context;
@Autowired
private ReadReportingService readExtraDataAndReportingService;
@@ -7,15 +7,14 @@ import org.mifosng.platform.api.data.EntityIdentifier;
import org.springframework.security.access.prepost.PreAuthorize;
public interface DocumentWritePlatformService {
@PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')")
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_DOCUMENT')")
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,
InputStream inputStream);
@PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')")
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_DOCUMENT')")
EntityIdentifier deleteDocument(DocumentCommand documentCommand);
}
@@ -5,9 +5,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
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);
@PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')")
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'ORGANISATION_ADMINISTRATION_SUPER_USER', 'UPDATE_FUND')")
Long updateFund(final FundCommand command);
}
@@ -346,6 +346,10 @@ public class AppUser extends AbstractAuditableCustom<AppUser, Long> implements
higherPermission = "ORGANISATION_ADMINISTRATION_SUPER_USER";
} else if (entityType.equalsIgnoreCase("CURRENCY")) {
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(""))) {