@Test public void testSEValues() { SecurityEventUtil spyObject = Mockito.spy(securityEventUtil); SecurityEvent event = spyObject.createSecurityEvent("class", "Action Description", LogLevelType.TYPE_INFO, BEMessageCode.BE_SE_CODE_0001); String appId = null; Mockito.verify(spyObject, Mockito.atMost(1)).createSecurityEvent(Mockito.anyString(), Mockito.anyString(), Mockito.eq(LogLevelType.TYPE_INFO), Mockito.eq(appId), Mockito.eq(BEMessageCode.BE_SE_CODE_0001)); assertEquals("BulkExtract", event.getAppId()); String processName = ManagementFactory.getRuntimeMXBean().getName(); assertEquals(processName, event.getProcessNameOrId()); assertEquals(null, event.getTargetEdOrgList()); }
public SecurityEvent createSecurityEvent(String loggingClass, String actionDesc, LogLevelType logLevel, String appId, BEMessageCode code, Object... args) { SecurityEvent event = new SecurityEvent(); String seAppId = (appId == null) ? "BulkExtract" : "BulkExtract#" + appId; event.setTenantId(TenantContext.getTenantId()); event.setAppId(seAppId); event.setActionUri(actionDesc); event.setTimeStamp(new Date()); event.setProcessNameOrId(ManagementFactory.getRuntimeMXBean().getName()); try { event.setExecutedOn(InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException e) { LOG.info("Could not find hostname/process for SecurityEventLogging!"); event.setExecutedOn("localhost"); } event.setClassName(loggingClass); event.setLogLevel(logLevel); event.setLogMessage(messageSource.getMessage(code.getCode(), args, "#?" + code.getCode() + "?#", null)); LOG.debug(event.toString()); return event; }
SecurityEventUtil implements MessageSourceAware { public SecurityEvent createSecurityEvent(String loggingClass, String actionDesc, LogLevelType logLevel, String appId, BEMessageCode code, Object... args) { SecurityEvent event = new SecurityEvent(); String seAppId = (appId == null) ? "BulkExtract" : "BulkExtract#" + appId; event.setTenantId(TenantContext.getTenantId()); event.setAppId(seAppId); event.setActionUri(actionDesc); event.setTimeStamp(new Date()); event.setProcessNameOrId(ManagementFactory.getRuntimeMXBean().getName()); try { event.setExecutedOn(InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException e) { LOG.info("Could not find hostname/process for SecurityEventLogging!"); event.setExecutedOn("localhost"); } event.setClassName(loggingClass); event.setLogLevel(logLevel); event.setLogMessage(messageSource.getMessage(code.getCode(), args, "#?" + code.getCode() + "?#", null)); LOG.debug(event.toString()); return event; } }
SecurityEventUtil implements MessageSourceAware { public SecurityEvent createSecurityEvent(String loggingClass, String actionDesc, LogLevelType logLevel, String appId, BEMessageCode code, Object... args) { SecurityEvent event = new SecurityEvent(); String seAppId = (appId == null) ? "BulkExtract" : "BulkExtract#" + appId; event.setTenantId(TenantContext.getTenantId()); event.setAppId(seAppId); event.setActionUri(actionDesc); event.setTimeStamp(new Date()); event.setProcessNameOrId(ManagementFactory.getRuntimeMXBean().getName()); try { event.setExecutedOn(InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException e) { LOG.info("Could not find hostname/process for SecurityEventLogging!"); event.setExecutedOn("localhost"); } event.setClassName(loggingClass); event.setLogLevel(logLevel); event.setLogMessage(messageSource.getMessage(code.getCode(), args, "#?" + code.getCode() + "?#", null)); LOG.debug(event.toString()); return event; }  }
SecurityEventUtil implements MessageSourceAware { public SecurityEvent createSecurityEvent(String loggingClass, String actionDesc, LogLevelType logLevel, String appId, BEMessageCode code, Object... args) { SecurityEvent event = new SecurityEvent(); String seAppId = (appId == null) ? "BulkExtract" : "BulkExtract#" + appId; event.setTenantId(TenantContext.getTenantId()); event.setAppId(seAppId); event.setActionUri(actionDesc); event.setTimeStamp(new Date()); event.setProcessNameOrId(ManagementFactory.getRuntimeMXBean().getName()); try { event.setExecutedOn(InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException e) { LOG.info("Could not find hostname/process for SecurityEventLogging!"); event.setExecutedOn("localhost"); } event.setClassName(loggingClass); event.setLogLevel(logLevel); event.setLogMessage(messageSource.getMessage(code.getCode(), args, "#?" + code.getCode() + "?#", null)); LOG.debug(event.toString()); return event; }  SecurityEvent createSecurityEvent(String loggingClass, String actionDesc, LogLevelType logLevel, String appId, BEMessageCode code, Object... args); SecurityEvent createSecurityEvent(String loggingClass, String actionDesc, LogLevelType logLevel, BEMessageCode code, Object... args); @Override void setMessageSource(MessageSource messageSource); }
SecurityEventUtil implements MessageSourceAware { public SecurityEvent createSecurityEvent(String loggingClass, String actionDesc, LogLevelType logLevel, String appId, BEMessageCode code, Object... args) { SecurityEvent event = new SecurityEvent(); String seAppId = (appId == null) ? "BulkExtract" : "BulkExtract#" + appId; event.setTenantId(TenantContext.getTenantId()); event.setAppId(seAppId); event.setActionUri(actionDesc); event.setTimeStamp(new Date()); event.setProcessNameOrId(ManagementFactory.getRuntimeMXBean().getName()); try { event.setExecutedOn(InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException e) { LOG.info("Could not find hostname/process for SecurityEventLogging!"); event.setExecutedOn("localhost"); } event.setClassName(loggingClass); event.setLogLevel(logLevel); event.setLogMessage(messageSource.getMessage(code.getCode(), args, "#?" + code.getCode() + "?#", null)); LOG.debug(event.toString()); return event; }  SecurityEvent createSecurityEvent(String loggingClass, String actionDesc, LogLevelType logLevel, String appId, BEMessageCode code, Object... args); SecurityEvent createSecurityEvent(String loggingClass, String actionDesc, LogLevelType logLevel, BEMessageCode code, Object... args); @Override void setMessageSource(MessageSource messageSource);  }