WIP audit view
This commit is contained in:
@@ -130,11 +130,11 @@ public class AuditApiResource {
|
|||||||
String extraCriteria = "";
|
String extraCriteria = "";
|
||||||
|
|
||||||
if (apiOperation != null) {
|
if (apiOperation != null) {
|
||||||
extraCriteria += " and aud.api_operation like "
|
extraCriteria += " and aud.api_operation = "
|
||||||
+ ApiParameterHelper.sqlEncodeString(apiOperation);
|
+ ApiParameterHelper.sqlEncodeString(apiOperation);
|
||||||
}
|
}
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
extraCriteria += " and aud.api_resource like "
|
extraCriteria += " and aud.api_resource = "
|
||||||
+ ApiParameterHelper.sqlEncodeString(resource);
|
+ ApiParameterHelper.sqlEncodeString(resource);
|
||||||
}
|
}
|
||||||
if (resourceId != null) {
|
if (resourceId != null) {
|
||||||
|
|||||||
+49
-6
@@ -23,9 +23,11 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
|||||||
private final JdbcTemplate jdbcTemplate;
|
private final JdbcTemplate jdbcTemplate;
|
||||||
private final PlatformSecurityContext context;
|
private final PlatformSecurityContext context;
|
||||||
private final AppUserReadPlatformService appUserReadPlatformService;
|
private final AppUserReadPlatformService appUserReadPlatformService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public AuditReadPlatformServiceImpl(final PlatformSecurityContext context,
|
public AuditReadPlatformServiceImpl(final PlatformSecurityContext context,
|
||||||
final TenantAwareRoutingDataSource dataSource, final AppUserReadPlatformService appUserReadPlatformService) {
|
final TenantAwareRoutingDataSource dataSource,
|
||||||
|
final AppUserReadPlatformService appUserReadPlatformService) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
this.appUserReadPlatformService = appUserReadPlatformService;
|
this.appUserReadPlatformService = appUserReadPlatformService;
|
||||||
@@ -74,8 +76,6 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<AuditData> retrieveAuditEntries(String extraCriteria,
|
public Collection<AuditData> retrieveAuditEntries(String extraCriteria,
|
||||||
boolean includeJson) {
|
boolean includeJson) {
|
||||||
@@ -105,10 +105,53 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AuditSearchData retrieveSearchTemplate() {
|
public AuditSearchData retrieveSearchTemplate() {
|
||||||
Collection<AppUserLookup> appUsers = appUserReadPlatformService.retrieveSearchTemplate();
|
Collection<AppUserLookup> appUsers = appUserReadPlatformService
|
||||||
List<String> apiOperations = null;
|
.retrieveSearchTemplate();
|
||||||
List<String> resources = null;
|
|
||||||
|
ApiOperationsMapper mapper = new ApiOperationsMapper();
|
||||||
|
List<String> apiOperations = this.jdbcTemplate.query(mapper.schema(),
|
||||||
|
mapper, new Object[] {});
|
||||||
|
|
||||||
|
ApiResourcesMapper mapper2 = new ApiResourcesMapper();
|
||||||
|
List<String> resources = this.jdbcTemplate.query(mapper2.schema(),
|
||||||
|
mapper2, new Object[] {});
|
||||||
|
|
||||||
return new AuditSearchData(appUsers, apiOperations, resources);
|
return new AuditSearchData(appUsers, apiOperations, resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class ApiOperationsMapper implements RowMapper<String> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String mapRow(final ResultSet rs,
|
||||||
|
@SuppressWarnings("unused") final int rowNum)
|
||||||
|
throws SQLException {
|
||||||
|
|
||||||
|
return rs.getString("apiOperation");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String schema() {
|
||||||
|
|
||||||
|
return " SELECT distinct(action_name) as apiOperation FROM m_permission "
|
||||||
|
+ " where action_name is not null and action_name <> 'READ' "
|
||||||
|
+ " order by if(action_name in ('CREATE', 'DELETE', 'UPDATE'), action_name, 'ZZZ'), action_name";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class ApiResourcesMapper implements RowMapper<String> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String mapRow(final ResultSet rs,
|
||||||
|
@SuppressWarnings("unused") final int rowNum)
|
||||||
|
throws SQLException {
|
||||||
|
|
||||||
|
return rs.getString("resource");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String schema() {
|
||||||
|
|
||||||
|
return " select distinct(api_resource) as resource from m_portfolio_command_source order by api_resource";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user