@Transactional @Test(expected = CmdbAccessDeniedException.class) public void givenNoPermissionSetupForEnquiryActionWhenPerformingEnquiryThenShouldBeDenied() throws CmdbAccessDeniedException { int ciTypeId = 1007; Map ciData = ImmutableMap.of("guid", "1007_1000000001", "subsys_design", "1002_1000000013", "env", 99); authorizationService.authorizeCiData(ciTypeId, ciData, ACTION_ENQUIRY); }
@Override public void authorizeCiData(int ciTypeId, Object ciData, String action) { if (!securityProperties.isEnabled()) { log.warn("Security authorization is disabled."); return; } String username = getCurrentUsername(); if (!isCiDataPermitted(ciTypeId, ciData, action)) { throw new CmdbAccessDeniedException(String.format("Access denied. No %s permission on ci-type[%d] found for %s", action, ciTypeId, username)); } else { log.info(String.format("Access granted. %s on ci-type[%d] permitted for %s", action, ciTypeId, username)); } }
AuthorizationServiceImpl implements AuthorizationService { @Override public void authorizeCiData(int ciTypeId, Object ciData, String action) { if (!securityProperties.isEnabled()) { log.warn("Security authorization is disabled."); return; } String username = getCurrentUsername(); if (!isCiDataPermitted(ciTypeId, ciData, action)) { throw new CmdbAccessDeniedException(String.format("Access denied. No %s permission on ci-type[%d] found for %s", action, ciTypeId, username)); } else { log.info(String.format("Access granted. %s on ci-type[%d] permitted for %s", action, ciTypeId, username)); } } }
AuthorizationServiceImpl implements AuthorizationService { @Override public void authorizeCiData(int ciTypeId, Object ciData, String action) { if (!securityProperties.isEnabled()) { log.warn("Security authorization is disabled."); return; } String username = getCurrentUsername(); if (!isCiDataPermitted(ciTypeId, ciData, action)) { throw new CmdbAccessDeniedException(String.format("Access denied. No %s permission on ci-type[%d] found for %s", action, ciTypeId, username)); } else { log.info(String.format("Access granted. %s on ci-type[%d] permitted for %s", action, ciTypeId, username)); } }  }
AuthorizationServiceImpl implements AuthorizationService { @Override public void authorizeCiData(int ciTypeId, Object ciData, String action) { if (!securityProperties.isEnabled()) { log.warn("Security authorization is disabled."); return; } String username = getCurrentUsername(); if (!isCiDataPermitted(ciTypeId, ciData, action)) { throw new CmdbAccessDeniedException(String.format("Access denied. No %s permission on ci-type[%d] found for %s", action, ciTypeId, username)); } else { log.info(String.format("Access granted. %s on ci-type[%d] permitted for %s", action, ciTypeId, username)); } }  @Override void authorizeCiData(int ciTypeId, Object ciData, String action); @Override boolean isCiDataPermitted(int ciTypeId, Object ciData, String action); @Cacheable("authorizationService-isCiTypePermitted") @Override boolean isCiTypePermitted(int ciTypeId, String action); @Cacheable("authorizationService-getPermittedData") @Override List<Map<String, Set<?>>> getPermittedData(int ciTypeId, String action); void setSecurityEnabled(boolean securityEnabled); }
AuthorizationServiceImpl implements AuthorizationService { @Override public void authorizeCiData(int ciTypeId, Object ciData, String action) { if (!securityProperties.isEnabled()) { log.warn("Security authorization is disabled."); return; } String username = getCurrentUsername(); if (!isCiDataPermitted(ciTypeId, ciData, action)) { throw new CmdbAccessDeniedException(String.format("Access denied. No %s permission on ci-type[%d] found for %s", action, ciTypeId, username)); } else { log.info(String.format("Access granted. %s on ci-type[%d] permitted for %s", action, ciTypeId, username)); } }  @Override void authorizeCiData(int ciTypeId, Object ciData, String action); @Override boolean isCiDataPermitted(int ciTypeId, Object ciData, String action); @Cacheable("authorizationService-isCiTypePermitted") @Override boolean isCiTypePermitted(int ciTypeId, String action); @Cacheable("authorizationService-getPermittedData") @Override List<Map<String, Set<?>>> getPermittedData(int ciTypeId, String action); void setSecurityEnabled(boolean securityEnabled);  }