private DBAuditMetadataLogEntity createCommonHAMLE(Configuration conf, TSentryResponseStatus responseStatus, String userName, String requestClassName) { DBAuditMetadataLogEntity hamle = new DBAuditMetadataLogEntity(); setCommAttrForAMLE(hamle, conf, responseStatus, userName, requestClassName); return hamle; }
private void assertCommon(DBAuditMetadataLogEntity amle, String allowedExcepted, String operationExcepted, String operationTextExcepted, String databaseNameExcepted, String tableNameExcepted, String resourcePathExcepted, String objectTypeExcepted) { assertEquals(ServerConfig.SENTRY_SERVICE_NAME_DEFAULT, amle.getServiceName()); assertEquals(TEST_IP, amle.getIpAddress()); assertEquals(TEST_USER_NAME, amle.getUserName()); assertEquals(TEST_IMPERSONATOR, amle.getImpersonator()); assertEquals(allowedExcepted, amle.getAllowed()); assertEquals(operationExcepted, amle.getOperation()); assertEquals(operationTextExcepted, amle.getOperationText()); assertEquals(tableNameExcepted, amle.getTableName()); assertEquals(databaseNameExcepted, amle.getDatabaseName()); assertEquals(resourcePathExcepted, amle.getResourcePath()); assertEquals(objectTypeExcepted, amle.getObjectType()); }
json = factory.createJsonGenerator(stringWriter); json.writeStartObject(); json.writeStringField(Constants.LOG_FIELD_SERVICE_NAME, getServiceName()); json.writeStringField(Constants.LOG_FIELD_USER_NAME, getUserName()); json.writeStringField(Constants.LOG_FIELD_IMPERSONATOR, getImpersonator()); json.writeStringField(Constants.LOG_FIELD_IP_ADDRESS, getIpAddress()); json.writeStringField(Constants.LOG_FIELD_OPERATION, getOperation()); json.writeStringField(Constants.LOG_FIELD_EVENT_TIME, getEventTime()); json.writeStringField(Constants.LOG_FIELD_OPERATION_TEXT, getOperationText()); json.writeStringField(Constants.LOG_FIELD_ALLOWED, getAllowed()); json.writeStringField(Constants.LOG_FIELD_DATABASE_NAME, databaseName); json.writeStringField(Constants.LOG_FIELD_TABLE_NAME, tableName); json.writeStringField(Constants.LOG_FIELD_COLUMN_NAME, columnName); json.writeStringField(Constants.LOG_FIELD_RESOURCE_PATH, resourcePath); json.writeStringField(Constants.LOG_FIELD_OBJECT_TYPE, getObjectType()); json.writeEndObject(); json.flush();
@Test public void testToJsonFormatLog() throws Throwable { DBAuditMetadataLogEntity amle = new DBAuditMetadataLogEntity("serviceName", "userName", "impersonator", "ipAddress", "operation", "eventTime", "operationText", "allowed", "objectType", "component", "databaseName", "tableName", "columnName", "resourcePath"); String jsonAuditLog = amle.toJsonFormatLog(); ContainerNode rootNode = AuditMetadataLogEntity.parse(jsonAuditLog); assertEntryEquals(rootNode, Constants.LOG_FIELD_SERVICE_NAME, "serviceName"); assertEntryEquals(rootNode, Constants.LOG_FIELD_USER_NAME, "userName"); assertEntryEquals(rootNode, Constants.LOG_FIELD_IMPERSONATOR, "impersonator"); assertEntryEquals(rootNode, Constants.LOG_FIELD_IP_ADDRESS, "ipAddress"); assertEntryEquals(rootNode, Constants.LOG_FIELD_OPERATION, "operation"); assertEntryEquals(rootNode, Constants.LOG_FIELD_EVENT_TIME, "eventTime"); assertEntryEquals(rootNode, Constants.LOG_FIELD_OPERATION_TEXT, "operationText"); assertEntryEquals(rootNode, Constants.LOG_FIELD_ALLOWED, "allowed"); assertEntryEquals(rootNode, Constants.LOG_FIELD_DATABASE_NAME, "databaseName"); assertEntryEquals(rootNode, Constants.LOG_FIELD_TABLE_NAME, "tableName"); assertEntryEquals(rootNode, Constants.LOG_FIELD_COLUMN_NAME, "columnName"); assertEntryEquals(rootNode, Constants.LOG_FIELD_RESOURCE_PATH, "resourcePath"); assertEntryEquals(rootNode, Constants.LOG_FIELD_OBJECT_TYPE, "objectType"); }
@Test public void testToJsonFormatLog() throws Throwable { DBAuditMetadataLogEntity amle = new DBAuditMetadataLogEntity("serviceName", "userName", "impersonator", "ipAddress", "operation", "eventTime", "operationText", "allowed", "objectType", "component", "databaseName", "tableName", "columnName", "resourcePath"); String jsonAuditLog = amle.toJsonFormatLog(); ContainerNode rootNode = AuditMetadataLogEntity.parse(jsonAuditLog); assertEntryEquals(rootNode, Constants.LOG_FIELD_SERVICE_NAME, "serviceName"); assertEntryEquals(rootNode, Constants.LOG_FIELD_USER_NAME, "userName"); assertEntryEquals(rootNode, Constants.LOG_FIELD_IMPERSONATOR, "impersonator"); assertEntryEquals(rootNode, Constants.LOG_FIELD_IP_ADDRESS, "ipAddress"); assertEntryEquals(rootNode, Constants.LOG_FIELD_OPERATION, "operation"); assertEntryEquals(rootNode, Constants.LOG_FIELD_EVENT_TIME, "eventTime"); assertEntryEquals(rootNode, Constants.LOG_FIELD_OPERATION_TEXT, "operationText"); assertEntryEquals(rootNode, Constants.LOG_FIELD_ALLOWED, "allowed"); assertEntryEquals(rootNode, Constants.LOG_FIELD_DATABASE_NAME, "databaseName"); assertEntryEquals(rootNode, Constants.LOG_FIELD_TABLE_NAME, "tableName"); assertEntryEquals(rootNode, Constants.LOG_FIELD_COLUMN_NAME, "columnName"); assertEntryEquals(rootNode, Constants.LOG_FIELD_RESOURCE_PATH, "resourcePath"); assertEntryEquals(rootNode, Constants.LOG_FIELD_OBJECT_TYPE, "objectType"); }
private void assertCommon(DBAuditMetadataLogEntity amle, String allowedExcepted, String operationExcepted, String operationTextExcepted, String databaseNameExcepted, String tableNameExcepted, String resourcePathExcepted, String objectTypeExcepted) { assertEquals(ServerConfig.SENTRY_SERVICE_NAME_DEFAULT, amle.getServiceName()); assertEquals(TEST_IP, amle.getIpAddress()); assertEquals(TEST_USER_NAME, amle.getUserName()); assertEquals(TEST_IMPERSONATOR, amle.getImpersonator()); assertEquals(allowedExcepted, amle.getAllowed()); assertEquals(operationExcepted, amle.getOperation()); assertEquals(operationTextExcepted, amle.getOperationText()); assertEquals(tableNameExcepted, amle.getTableName()); assertEquals(databaseNameExcepted, amle.getDatabaseName()); assertEquals(resourcePathExcepted, amle.getResourcePath()); assertEquals(objectTypeExcepted, amle.getObjectType()); }
private DBAuditMetadataLogEntity createCommonHAMLE(Configuration conf, TSentryResponseStatus responseStatus, String userName, String operationType, String objectType) { DBAuditMetadataLogEntity hamle = new DBAuditMetadataLogEntity(); setCommAttrForAMLE(hamle, conf, responseStatus, userName, operationType, objectType); return hamle; }
private DBAuditMetadataLogEntity createCommonHAMLE(Configuration conf, TSentryResponseStatus responseStatus, String userName, String requestClassName) { DBAuditMetadataLogEntity hamle = new DBAuditMetadataLogEntity(); setCommAttrForAMLE(hamle, conf, responseStatus, userName, toOperationType(requestClassName), toObjectType(requestClassName)); return hamle; }
request.setPrivileges(privileges); response.setStatus(Status.OK()); DBAuditMetadataLogEntity amle = new DBAuditMetadataLogEntity(); Set<JsonLogEntity> amles = JsonLogEntityFactory .getInstance().createJsonLogEntitys(request, response, conf);
request.setPrivileges(privileges); response.setStatus(Status.OK()); DBAuditMetadataLogEntity amle = new DBAuditMetadataLogEntity(); Set<JsonLogEntity> amles = JsonLogEntityFactory .getInstance().createJsonLogEntities(request, response, conf);
request.setPrivileges(privileges); response.setStatus(Status.OK()); DBAuditMetadataLogEntity amle = new DBAuditMetadataLogEntity(); Set<JsonLogEntity> amles = JsonLogEntityFactory .getInstance().createJsonLogEntities(request, response, conf);
request.setPrivileges(privileges); response.setStatus(Status.OK()); DBAuditMetadataLogEntity amle = new DBAuditMetadataLogEntity(); Set<JsonLogEntity> amles = JsonLogEntityFactory .getInstance().createJsonLogEntitys(request, response, conf);