diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/ChargesApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/ChargesApiResource.java index db25941e8..63e8bceb4 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/ChargesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/ChargesApiResource.java @@ -24,6 +24,7 @@ import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService import org.mifosng.platform.charge.service.ChargeReadPlatformService; import org.mifosng.platform.charge.service.ChargeWritePlatformService; 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; @@ -32,7 +33,7 @@ import org.springframework.stereotype.Component; @Component @Scope("singleton") public class ChargesApiResource { - + @Autowired private ChargeReadPlatformService chargeReadPlatformService; @@ -44,12 +45,22 @@ public class ChargesApiResource { @Autowired private PortfolioApiJsonSerializerService apiJsonSerializerService; + + private final String entityType = "CHARGE"; + private final PlatformSecurityContext context; + @Autowired + public ChargesApiResource(final PlatformSecurityContext context) { + this.context = context; + } + @GET @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public String retrieveAllCharges(@Context final UriInfo uriInfo){ + context.authenticatedUser().validateHasReadPermission(entityType); + final Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); @@ -63,7 +74,9 @@ public class ChargesApiResource { @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public String retrieveCharge(@PathParam("chargeId") final Long chargeId, @Context final UriInfo uriInfo){ - + + context.authenticatedUser().validateHasReadPermission(entityType); + final Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); @@ -83,7 +96,9 @@ public class ChargesApiResource { @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public String retrieveNewChargeDetails(@Context final UriInfo uriInfo) { - + + context.authenticatedUser().validateHasReadPermission(entityType); + final Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientIdentifiersApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientIdentifiersApiResource.java index d4758aa5a..2bc5cec41 100755 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientIdentifiersApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientIdentifiersApiResource.java @@ -28,6 +28,7 @@ import org.mifosng.platform.client.service.ClientReadPlatformService; import org.mifosng.platform.client.service.ClientWritePlatformService; import org.mifosng.platform.exceptions.DuplicateClientIdentifierException; 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; @@ -52,13 +53,23 @@ public class ClientIdentifiersApiResource { private static final Set typicalResponseParameters = new HashSet( Arrays.asList("id", "clientId", "documentTypeId", "description", "documentKey", "documentTypeName")); + + private final String entityType = "CLIENTIDENTIFIER"; + private final PlatformSecurityContext context; + @Autowired + public ClientIdentifiersApiResource(final PlatformSecurityContext context) { + this.context = context; + } + @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) public String retrieveAllClientIdentifiers(@Context final UriInfo uriInfo, @PathParam("clientId") final Long clientId) { + context.authenticatedUser().validateHasReadPermission(entityType); + Set responseParameters = ApiParameterHelper .extractFieldsForResponseIfProvided(uriInfo .getQueryParameters()); @@ -82,6 +93,8 @@ public class ClientIdentifiersApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String newClientDetails(@Context final UriInfo uriInfo) { + context.authenticatedUser().validateHasReadPermission(entityType); + Set responseParameters = ApiParameterHelper .extractFieldsForResponseIfProvided(uriInfo .getQueryParameters()); @@ -132,6 +145,8 @@ public class ClientIdentifiersApiResource { @PathParam("identifierId") final Long clientIdentifierId, @Context final UriInfo uriInfo) { + context.authenticatedUser().validateHasReadPermission(entityType); + final Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); if (responseParameters.isEmpty()) { responseParameters.addAll(typicalResponseParameters); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientsApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientsApiResource.java index 81c28ae16..d469948c5 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientsApiResource.java @@ -45,6 +45,7 @@ import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosng.platform.makerchecker.service.PortfolioMakerCheckerReadPlatformService; import org.mifosng.platform.makerchecker.service.PortfolioMakerCheckerWriteService; import org.mifosng.platform.organisation.service.OfficeReadPlatformService; +import org.mifosng.platform.security.PlatformSecurityContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -84,6 +85,13 @@ public class ClientsApiResource { @Autowired private PortfolioMakerCheckerReadPlatformService makerCheckerReadPlatformService; + private final PlatformSecurityContext context; + + @Autowired + public ClientsApiResource(final PlatformSecurityContext context) { + this.context = context; + } + @GET @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) @@ -96,6 +104,8 @@ public class ClientsApiResource { @QueryParam("lastName") final String lastName, @QueryParam("underHierarchy") final String hierarchy) { + context.authenticatedUser().validateHasReadPermission("CLIENT"); + final String extraCriteria = getClientCriteria(sqlSearch, officeId, externalId, displayName, firstName, lastName, hierarchy); final Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); @@ -157,6 +167,8 @@ public class ClientsApiResource { public String retrieveClientData( @PathParam("clientId") final Long clientId, @Context final UriInfo uriInfo) { + + context.authenticatedUser().validateHasReadPermission("CLIENT"); final Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); @@ -176,6 +188,8 @@ public class ClientsApiResource { @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public String newClientDetails(@Context final UriInfo uriInfo) { + + context.authenticatedUser().validateHasReadPermission("CLIENT"); final Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); @@ -246,6 +260,8 @@ public class ClientsApiResource { public String retrieveClientAccount(@PathParam("clientId") final Long clientId, @Context final UriInfo uriInfo) { + context.authenticatedUser().validateHasReadPermission("CLIENT"); + Set typicalResponseParameters = new HashSet( Arrays.asList("pendingApprovalLoans", "awaitingDisbursalLoans", "openLoans", "closedLoans", "anyLoanCount", "pendingApprovalLoanCount", "awaitingDisbursalLoanCount", "activeLoanCount", "closedLoanCount", @@ -271,6 +287,8 @@ public class ClientsApiResource { @Produces({MediaType.APPLICATION_JSON}) public String retrieveAllClientNotes(@PathParam("clientId") final Long clientId, @Context final UriInfo uriInfo) { + context.authenticatedUser().validateHasReadPermission("CLIENTNOTE"); + Set typicalResponseParameters = new HashSet( Arrays.asList("id", "clientId", "loanId", "loanTransactionId", "noteType", "note", "createdById", "createdByUsername", "createdOn", "updatedById", "updatedByUsername", "updatedOn") @@ -308,6 +326,8 @@ public class ClientsApiResource { @PathParam("clientId") final Long clientId, @PathParam("noteId") final Long noteId, @Context final UriInfo uriInfo) { + + context.authenticatedUser().validateHasReadPermission("CLIENTNOTE"); Set typicalResponseParameters = new HashSet( Arrays.asList("id", "clientId", "loanId", "loanTransactionId", "noteType", "note", "createdById", "createdByUsername", @@ -414,6 +434,8 @@ public class ClientsApiResource { @Produces({MediaType.APPLICATION_JSON}) public Response retrieveClientImage( @PathParam("clientId") final Long clientId) { + + context.authenticatedUser().validateHasReadPermission("CLIENTIMAGE"); final ClientData clientData = this.clientReadPlatformService.retrieveIndividualClient(clientId); //validate if client does not exist or image key is null diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/charge/service/ChargeReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/charge/service/ChargeReadPlatformService.java index 72e6d588d..3b3db6bfd 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/charge/service/ChargeReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/charge/service/ChargeReadPlatformService.java @@ -1,18 +1,18 @@ package org.mifosng.platform.charge.service; +import java.util.Collection; + import org.mifosng.platform.api.data.ChargeData; import org.mifosng.platform.api.data.LoanChargeData; -import java.util.Collection; - public interface ChargeReadPlatformService { Collection retrieveAllCharges(); - + ChargeData retrieveCharge(Long chargeId); - + ChargeData retrieveNewChargeDetails(); - + Collection retrieveLoanApplicableCharges(boolean feeChargesOnly); Collection retrieveLoanProductCharges(Long loanProductId); @@ -20,6 +20,6 @@ public interface ChargeReadPlatformService { Collection retrieveLoanCharges(Long loanId); LoanChargeData retrieveLoanChargeDetails(Long loanChargeId, Long loanId); - + ChargeData retrieveLoanChargeTemplate(); } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/charge/service/ChargeWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/charge/service/ChargeWritePlatformService.java index a6e3157ea..8f1ba48a0 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/charge/service/ChargeWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/charge/service/ChargeWritePlatformService.java @@ -5,12 +5,12 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface ChargeWritePlatformService { - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('ORGANISATION_ADMINISTRATION_SUPER_USER', 'CREATE_CHARGE')") Long createCharge(final ChargeCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('ORGANISATION_ADMINISTRATION_SUPER_USER', 'UPDATE_CHARGE')") Long updateCharge(final ChargeCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('ORGANISATION_ADMINISTRATION_SUPER_USER', 'DELETE_CHARGE')") Long deleteCharge(final Long chargeId); } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformService.java index 363731369..330d0b9f3 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformService.java @@ -11,36 +11,36 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface ClientWritePlatformService { - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_ENROLL_NEW_CLIENT_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENT')") Long enrollClient(ClientCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENT')") EntityIdentifier updateClientDetails(ClientCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") - EntityIdentifier saveOrUpdateClientImage(Long clientId, String imageName, InputStream inputStream); - - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") - EntityIdentifier saveOrUpdateClientImage(Long clientId, Base64EncodedImage encodedImage); - - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") - EntityIdentifier deleteClientImage(Long clientId); - - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") - EntityIdentifier addClientNote(NoteCommand command); - - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") - EntityIdentifier updateNote(NoteCommand command); - - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_DELETE_CLIENT_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENT')") EntityIdentifier deleteClient(Long clientId); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIMAGE')") + EntityIdentifier saveOrUpdateClientImage(Long clientId, String imageName, InputStream inputStream); + + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIMAGE')") + EntityIdentifier saveOrUpdateClientImage(Long clientId, Base64EncodedImage encodedImage); + + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENTIMAGE')") + EntityIdentifier deleteClientImage(Long clientId); + + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTNOTE')") + EntityIdentifier addClientNote(NoteCommand command); + + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENTNOTE')") + EntityIdentifier updateNote(NoteCommand command); + + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIDENTIFIER')") Long addClientIdentifier(ClientIdentifierCommand clientIdentifierCommand); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENTIDENTIFIER')") EntityIdentifier updateClientIdentifier(ClientIdentifierCommand clientIdentifierCommand); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENTIDENTIFIER')") EntityIdentifier deleteClientIdentifier(Long clientIdentifierId); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentWritePlatformService.java index 2ee0f3e7e..d3a358895 100755 --- a/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentWritePlatformService.java @@ -8,14 +8,14 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface DocumentWritePlatformService { - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')") Long createDocument(DocumentCommand documentCommand, InputStream inputStream); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')") EntityIdentifier updateDocument(DocumentCommand documentCommand, InputStream inputStream); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')") EntityIdentifier deleteDocument(DocumentCommand documentCommand); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/fund/service/FundWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/fund/service/FundWritePlatformService.java index faa91a1c9..17c924aab 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/fund/service/FundWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/fund/service/FundWritePlatformService.java @@ -5,9 +5,9 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface FundWritePlatformService { - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") Long createFund(final FundCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") Long updateFund(final FundCommand command); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformService.java index ba0367cfe..b6abab054 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformService.java @@ -6,13 +6,13 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface GroupWritePlatformService { - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')") EntityIdentifier createGroup(GroupCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')") EntityIdentifier updateGroup(GroupCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')") EntityIdentifier deleteGroup(Long groupId); } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformService.java index a7b359290..4aa9ff9c6 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformService.java @@ -12,63 +12,63 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface LoanWritePlatformService { - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_SUBMIT_NEW_LOAN_APPLICATION_ROLE', 'CAN_SUBMIT_HISTORIC_LOAN_APPLICATION_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_LOAN', 'CREATEHISTORIC_LOAN')") EntityIdentifier submitLoanApplication(LoanApplicationCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_SUBMIT_NEW_LOAN_APPLICATION_ROLE', 'CAN_SUBMIT_HISTORIC_LOAN_APPLICATION_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_LOAN', 'CREATEHISTORIC_LOAN')") EntityIdentifier modifyLoanApplication(LoanApplicationCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_DELETE_LOAN_THAT_IS_SUBMITTED_AND_NOT_APPROVED')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_LOAN')") EntityIdentifier deleteLoan(Long loanId); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_APPROVE_LOAN_ROLE', 'CAN_APPROVE_LOAN_IN_THE_PAST_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'APPROVE_LOAN', 'APPROVEINPAST_LOAN')") EntityIdentifier approveLoanApplication(LoanStateTransitionCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_UNDO_LOAN_APPROVAL_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'APPROVALUNDO_LOAN')") EntityIdentifier undoLoanApproval(UndoStateTransitionCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_REJECT_LOAN_ROLE', 'CAN_REJECT_LOAN_IN_THE_PAST_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'REJECT_LOAN', 'REJECTINPAST_LOAN')") EntityIdentifier rejectLoan(LoanStateTransitionCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_WITHDRAW_LOAN_ROLE', 'CAN_WITHDRAW_LOAN_IN_THE_PAST_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'WITHDRAW_LOAN', 'WITHDRAWINPAST_LOAN')") EntityIdentifier withdrawLoan(LoanStateTransitionCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_DISBURSE_LOAN_ROLE', 'CAN_DISBURSE_LOAN_IN_THE_PAST_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'DISBURSE_LOAN', 'DISBURSEINPAST_LOAN')") EntityIdentifier disburseLoan(LoanStateTransitionCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_UNDO_LOAN_DISBURSAL_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'DISBURSALUNDO_LOAN')") public EntityIdentifier undoLoanDisbursal(UndoStateTransitionCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_MAKE_LOAN_REPAYMENT_ROLE', 'CAN_MAKE_LOAN_REPAYMENT_IN_THE_PAST_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'REPAYMENT_LOAN', 'REPAYMENTINPAST_LOAN')") public EntityIdentifier makeLoanRepayment(LoanTransactionCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')") EntityIdentifier adjustLoanTransaction(AdjustLoanTransactionCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')") EntityIdentifier waiveInterestOnLoan(LoanTransactionCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')") EntityIdentifier writeOff(LoanTransactionCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')") EntityIdentifier closeLoan(LoanTransactionCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')") EntityIdentifier closeAsRescheduled(LoanTransactionCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')") EntityIdentifier addLoanCharge(LoanChargeCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')") EntityIdentifier updateLoanCharge(LoanChargeCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')") EntityIdentifier deleteLoanCharge(final Long loanId, final Long loanChargeId); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')") EntityIdentifier waiveLoanCharge(LoanChargeCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER')") EntityIdentifier bulkLoanReassignment(final BulkLoanReassignmentCommand command); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformServiceJpaRepositoryImpl.java index 4a924b7b0..5b525353f 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformServiceJpaRepositoryImpl.java @@ -116,7 +116,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf validator.validate(); LocalDate submittedOn = command.getSubmittedOnDate(); - if (this.isBeforeToday(submittedOn) && currentUser.hasNotPermissionForAnyOf("CAN_SUBMIT_HISTORIC_LOAN_APPLICATION_ROLE", "PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE")) { + if (this.isBeforeToday(submittedOn) && currentUser.hasNotPermissionForAnyOf("CREATEHISTORIC_LOAN", "PORTFOLIO_MANAGEMENT_SUPER_USER")) { throw new NoAuthorizationException("Cannot add backdated loan."); } @@ -142,7 +142,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf // TODO - fix up permissions for loan modification final LocalDate submittedOn = command.getSubmittedOnDate(); - if (this.isBeforeToday(submittedOn) && currentUser.hasNotPermissionForAnyOf("CAN_SUBMIT_HISTORIC_LOAN_APPLICATION_ROLE", "PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE")) { + if (this.isBeforeToday(submittedOn) && currentUser.hasNotPermissionForAnyOf("CREATEHISTORIC_LOAN", "PORTFOLIO_MANAGEMENT_SUPER_USER")) { throw new NoAuthorizationException("Cannot modify backdated loan."); } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loanproduct/service/LoanProductWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/loanproduct/service/LoanProductWritePlatformService.java index 32db27e33..0688114c6 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loanproduct/service/LoanProductWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loanproduct/service/LoanProductWritePlatformService.java @@ -6,9 +6,9 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface LoanProductWritePlatformService { - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") EntityIdentifier createLoanProduct(LoanProductCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") EntityIdentifier updateLoanProduct(LoanProductCommand command); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/organisation/service/CodeWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/organisation/service/CodeWritePlatformService.java index 50b28d57f..e56f3071e 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/organisation/service/CodeWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/organisation/service/CodeWritePlatformService.java @@ -5,9 +5,9 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface CodeWritePlatformService { - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") Long createCode(final CodeCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") Long updateCode(final CodeCommand command); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/organisation/service/OfficeWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/organisation/service/OfficeWritePlatformService.java index 00dac201c..8a9d295f3 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/organisation/service/OfficeWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/organisation/service/OfficeWritePlatformService.java @@ -6,12 +6,12 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface OfficeWritePlatformService { - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") Long createOffice(final OfficeCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") Long updateOffice(final OfficeCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") Long externalBranchMoneyTransfer(BranchMoneyTransferCommand command); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformService.java index 175a553ce..66a948529 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformService.java @@ -11,36 +11,36 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface DepositAccountWritePlatformService { - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") EntityIdentifier createDepositAccount(DepositAccountCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") EntityIdentifier deleteDepositAccount(Long productId); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_APPROVE_DEPOSIT_ROLE', 'CAN_APPROVE_DEPOSIT_IN_THE_PAST_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'CAN_APPROVE_DEPOSIT_ROLE', 'CAN_APPROVE_DEPOSIT_IN_THE_PAST_ROLE')") EntityIdentifier approveDepositApplication(DepositStateTransitionApprovalCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_APPROVE_DEPOSIT_ROLE', 'CAN_APPROVE_DEPOSIT_IN_THE_PAST_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'CAN_APPROVE_DEPOSIT_ROLE', 'CAN_APPROVE_DEPOSIT_IN_THE_PAST_ROLE')") EntityIdentifier rejectDepositApplication(DepositStateTransitionCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_APPROVE_DEPOSIT_ROLE', 'CAN_APPROVE_DEPOSIT_IN_THE_PAST_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'CAN_APPROVE_DEPOSIT_ROLE', 'CAN_APPROVE_DEPOSIT_IN_THE_PAST_ROLE')") EntityIdentifier withdrawDepositApplication(DepositStateTransitionCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_APPROVE_DEPOSIT_ROLE', 'CAN_APPROVE_DEPOSIT_IN_THE_PAST_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'CAN_APPROVE_DEPOSIT_ROLE', 'CAN_APPROVE_DEPOSIT_IN_THE_PAST_ROLE')") EntityIdentifier undoDepositApproval(UndoStateTransitionCommand undoCommand); - /*@PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_APPROVE_DEPOSIT_ROLE', 'CAN_APPROVE_DEPOSIT_IN_THE_PAST_ROLE')") + /*@PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'CAN_APPROVE_DEPOSIT_ROLE', 'CAN_APPROVE_DEPOSIT_IN_THE_PAST_ROLE')") EntityIdentifier matureDepositApplication(DepositStateTransitionCommand command);*/ - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_APPROVE_DEPOSIT_ROLE', 'CAN_APPROVE_DEPOSIT_IN_THE_PAST_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'CAN_APPROVE_DEPOSIT_ROLE', 'CAN_APPROVE_DEPOSIT_IN_THE_PAST_ROLE')") EntityIdentifier withdrawDepositAccountMoney(DepositAccountWithdrawalCommand command); - @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_APPROVE_DEPOSIT_ROLE', 'CAN_APPROVE_DEPOSIT_IN_THE_PAST_ROLE')") + @PreAuthorize(value = "hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER', 'CAN_APPROVE_DEPOSIT_ROLE', 'CAN_APPROVE_DEPOSIT_IN_THE_PAST_ROLE')") EntityIdentifier withdrawDepositAccountInterestMoney(DepositAccountWithdrawInterestCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") EntityIdentifier renewDepositAccount(DepositAccountCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") EntityIdentifier updateDepositAccount(DepositAccountCommand command); } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountWritePlatformService.java index 89389d298..3e84784c9 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountWritePlatformService.java @@ -6,9 +6,9 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface SavingAccountWritePlatformService { - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") EntityIdentifier createSavingAccount(SavingAccountCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") EntityIdentifier updateSavingAccount(SavingAccountCommand command); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductWritePlatformService.java index c8a42b78c..eb15d6b0f 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductWritePlatformService.java @@ -6,13 +6,13 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface DepositProductWritePlatformService { - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") EntityIdentifier createDepositProduct(DepositProductCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") EntityIdentifier updateDepositProduct(DepositProductCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") EntityIdentifier deleteDepositProduct(Long productId); } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductWritePlatformService.java index 9e05a91a1..c6653f418 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductWritePlatformService.java @@ -5,12 +5,12 @@ import org.mifosng.platform.api.data.EntityIdentifier; import org.springframework.security.access.prepost.PreAuthorize; public interface SavingProductWritePlatformService { - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") EntityIdentifier createSavingProduct(SavingProductCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") EntityIdentifier updateSavingProduct(SavingProductCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") EntityIdentifier deleteSavingProduct(Long productId); } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/staff/service/StaffWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/staff/service/StaffWritePlatformService.java index 5dc8db524..e33fab8d0 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/staff/service/StaffWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/staff/service/StaffWritePlatformService.java @@ -1,13 +1,13 @@ -package org.mifosng.platform.staff.service; - -import org.mifosng.platform.api.commands.StaffCommand; -import org.springframework.security.access.prepost.PreAuthorize; - -public interface StaffWritePlatformService { - - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") - Long createStaff(final StaffCommand command); - - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") - Long updateStaff(final StaffCommand command); +package org.mifosng.platform.staff.service; + +import org.mifosng.platform.api.commands.StaffCommand; +import org.springframework.security.access.prepost.PreAuthorize; + +public interface StaffWritePlatformService { + + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") + Long createStaff(final StaffCommand command); + + @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER')") + Long updateStaff(final StaffCommand command); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/user/domain/AppUser.java b/mifosng-provider/src/main/java/org/mifosng/platform/user/domain/AppUser.java index 19bee3c0e..440d6ef07 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/user/domain/AppUser.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/user/domain/AppUser.java @@ -17,6 +17,7 @@ import javax.persistence.Table; import javax.persistence.UniqueConstraint; import org.mifosng.platform.api.commands.UserCommand; +import org.mifosng.platform.exceptions.NoAuthorizationException; import org.mifosng.platform.infrastructure.AbstractAuditableCustom; import org.mifosng.platform.infrastructure.PlatformUser; import org.mifosng.platform.organisation.domain.Office; @@ -235,29 +236,28 @@ public class AppUser extends AbstractAuditableCustom implements } public boolean canNotApproveLoanInPast() { - return hasNotPermissionForAnyOf("CAN_APPROVE_LOAN_IN_THE_PAST_ROLE", - "PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE"); + return hasNotPermissionForAnyOf("APPROVEINPAST_LOAN", + "PORTFOLIO_MANAGEMENT_SUPER_USER"); } public boolean canNotRejectLoanInPast() { - return hasNotPermissionForAnyOf("CAN_REJECT_LOAN_IN_THE_PAST_ROLE", - "PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE"); + return hasNotPermissionForAnyOf("REJECTINPAST_LOAN", + "PORTFOLIO_MANAGEMENT_SUPER_USER"); } public boolean canNotWithdrawByClientLoanInPast() { - return hasNotPermissionForAnyOf("CAN_WITHDRAW_LOAN_IN_THE_PAST_ROLE", - "PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE"); + return hasNotPermissionForAnyOf("WITHDRAWINPAST_LOAN", + "PORTFOLIO_MANAGEMENT_SUPER_USER"); } public boolean canNotDisburseLoanInPast() { - return hasNotPermissionForAnyOf("CAN_DISBURSE_LOAN_IN_THE_PAST_ROLE", - "PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE"); + return hasNotPermissionForAnyOf("DISBURSEINPAST_LOAN", + "PORTFOLIO_MANAGEMENT_SUPER_USER"); } public boolean canNotMakeRepaymentOnLoanInPast() { - return hasNotPermissionForAnyOf( - "CAN_MAKE_LOAN_REPAYMENT_IN_THE_PAST_ROLE", - "PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE"); + return hasNotPermissionForAnyOf("REPAYMENTINPAST_LOAN", + "PORTFOLIO_MANAGEMENT_SUPER_USER"); } public boolean hasNotPermissionForReport(String reportName) { @@ -321,6 +321,35 @@ public class AppUser extends AbstractAuditableCustom implements return hasNotPermission; } + public void validateHasReadPermission(final String entityType) { + + String authorizationMessage = "User has no authority to view " + + entityType.toLowerCase() + "s"; + String matchPermission = "READ_" + entityType.toUpperCase(); + + if (hasNotPermissionForAnyOf("ALL_FUNCTIONS_READ", matchPermission)) + throw new NoAuthorizationException(authorizationMessage); + + String higherPermission = ""; + if (entityType.equalsIgnoreCase("CHARGE")) { + higherPermission = "ORGANISATION_ADMINISTRATION_SUPER_USER"; + } else if (entityType.equalsIgnoreCase("CLIENT")) { + higherPermission = "PORTFOLIO_MANAGEMENT_SUPER_USER"; + } else if (entityType.equalsIgnoreCase("CLIENTNOTE")) { + higherPermission = "PORTFOLIO_MANAGEMENT_SUPER_USER"; + } else if (entityType.equalsIgnoreCase("CLIENTIDENTIFIER")) { + higherPermission = "PORTFOLIO_MANAGEMENT_SUPER_USER"; + } else if (entityType.equalsIgnoreCase("CLIENTIMAGE")) { + higherPermission = "PORTFOLIO_MANAGEMENT_SUPER_USER"; + } + + if (!(higherPermission.equals(""))) { + if (hasNotPermissionForAnyOf(higherPermission)) + throw new NoAuthorizationException(authorizationMessage); + } + + } + private boolean hasPermissionTo(final String permissionCode) { boolean match = false; for (Role role : this.roles) { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/user/service/AppUserWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/user/service/AppUserWritePlatformService.java index 66e274a3f..3e96ba1ef 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/user/service/AppUserWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/user/service/AppUserWritePlatformService.java @@ -5,13 +5,13 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface AppUserWritePlatformService { - @PreAuthorize(value = "hasRole('USER_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('USER_ADMINISTRATION_SUPER_USER')") Long createUser(final UserCommand command); - @PreAuthorize(value = "hasRole('USER_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('USER_ADMINISTRATION_SUPER_USER')") Long updateUser(final UserCommand command); - @PreAuthorize(value = "hasRole('USER_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('USER_ADMINISTRATION_SUPER_USER')") void deleteUser(final Long userId); // we dont put any permissions on this e.g. a user with no admin rights can change their own details (email, username, password etc). diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/user/service/RoleWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/user/service/RoleWritePlatformService.java index 470f4872c..e07fa6d8b 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/user/service/RoleWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/user/service/RoleWritePlatformService.java @@ -5,9 +5,9 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface RoleWritePlatformService { - @PreAuthorize(value = "hasRole('USER_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('USER_ADMINISTRATION_SUPER_USER')") Long createRole(RoleCommand command); - @PreAuthorize(value = "hasRole('USER_ADMINISTRATION_SUPER_USER_ROLE')") + @PreAuthorize(value = "hasRole('USER_ADMINISTRATION_SUPER_USER')") Long updateRole(RoleCommand command); } \ No newline at end of file