public void audit( final List auditList ) { if ( ( auditList == null ) || ( auditList.size() == 0 ) ) { return; } // TODO pass in a list of parameter objects instead of parameter names Iterator it = auditList.iterator(); while ( it.hasNext() ) { Element auditNode = (Element) it.next(); String name = auditNode.getText(); String value = getStringParameter( name, "" ); //$NON-NLS-1$ AuditHelper.audit( this, session, MessageTypes.INSTANCE_ATTRIBUTE, name, value, 0, this ); } }
protected void makeAuditRecord( final float time, final String messageType, final JobExecutionContext jobExecutionContext ) { if ( jobExecutionContext != null && jobExecutionContext.getJobDetail() != null ) { final JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap(); if ( null == jobDataMap || null == jobDataMap.get( QuartzScheduler.RESERVEDMAPKEY_STREAMPROVIDER ) || null == jobDataMap.get( QuartzScheduler.RESERVEDMAPKEY_ACTIONID ) ) { //it's an action, no need to log return; } AuditHelper.audit( PentahoSessionHolder.getSession() != null ? PentahoSessionHolder.getSession().getId() : "", jobDataMap.get( QuartzScheduler.RESERVEDMAPKEY_ACTIONUSER ) != null ? jobDataMap.get( QuartzScheduler.RESERVEDMAPKEY_ACTIONUSER ).toString() : "", jobDataMap.get( QuartzScheduler.RESERVEDMAPKEY_STREAMPROVIDER ) != null ? jobDataMap.get( QuartzScheduler.RESERVEDMAPKEY_STREAMPROVIDER ).toString() : "", jobExecutionContext.getJobDetail().getJobClass() != null ? jobExecutionContext.getJobDetail().getJobClass().getName() : "", jobDataMap.get( QuartzScheduler.RESERVEDMAPKEY_ACTIONID ) != null ? jobDataMap.get( QuartzScheduler.RESERVEDMAPKEY_ACTIONID ).toString() : "", messageType, jobDataMap.get( "lineage-id" ) != null ? jobDataMap.get( "lineage-id" ).toString() : "", null, time, null ); //$NON-NLS-1$ } } }
public void onApplicationEvent( final ApplicationEvent event ) { if ( event instanceof AuthenticationSuccessEvent ) { logger.debug( "received " + event.getClass().getSimpleName() ); //$NON-NLS-1$ logger.debug( "synchronizing current IPentahoSession with SecurityContext" ); //$NON-NLS-1$ try { Authentication authentication = ( (AbstractAuthenticationEvent) event ).getAuthentication(); IPentahoSession pentahoSession = PentahoSessionHolder.getSession(); Assert.notNull( pentahoSession, "PentahoSessionHolder doesn't have a session" ); pentahoSession.setAuthenticated( authentication.getName() ); pentahoSession.setAttribute( IPentahoSession.SESSION_ROLES, authentication.getAuthorities() ); // audit session creation AuditHelper.audit( pentahoSession.getId(), pentahoSession.getName(), pentahoSession.getActionName(), pentahoSession.getObjectName(), "", MessageTypes.SESSION_START, "", "", 0, null ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ logger.info( "The user \"" + pentahoSession.getName() + "\"" + " connected to server with session ID " + pentahoSession.getId() ); } catch ( Exception e ) { logger.error( e.getLocalizedMessage(), e ); } } }
public void audit( final String messageType, final String message, final String value, final long duration ) { if ( !audit ) { return; } if ( RuntimeContext.debug ) { debug( Messages.getInstance().getString( "RuntimeContext.DEBUG_AUDIT", instanceId, getCurrentComponentName(), messageType ) ); //$NON-NLS-1$ } AuditHelper.audit( this, session, messageType, message, value, (float) duration / 1000, this ); }
public static void audit( final IRuntimeContext runtimeContext, final IPentahoSession session, final String messageType, final String message, final String value, final float duration, final ILogger logger ) { String instanceId = ( runtimeContext == null ) ? "" : runtimeContext.getInstanceId(); //$NON-NLS-1$ String userId = session.getName(); String actionName = ( runtimeContext == null ) ? null : runtimeContext.getActionName(); String objectType = ( runtimeContext == null ) ? "" : runtimeContext.getCurrentComponentName(); //$NON-NLS-1$ String processId = ( runtimeContext == null ) ? null : runtimeContext.getProcessId(); AuditHelper.audit( instanceId, userId, actionName, objectType, processId, messageType, message, value, duration, logger ); }
public void testAuditFailures4() { startTest(); AuditHelper.audit( "342323", "admin", "ViewAction", "String", null, "Type", "This is a message", "Values", 34, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ this ); assertTrue( true ); finishTest(); }
public void testAuditFailures2() { startTest(); AuditHelper.audit( null, "admin", "ViewAction", "String", "334234", "Type", "This is a message", "Values", 34, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ this ); assertTrue( true ); finishTest(); }
public void testAuditFailures3() { startTest(); AuditHelper.audit( "342323", "admin", null, "String", "334234", "Type", "This is a message", "Values", 34, this ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ assertTrue( true ); finishTest(); }
private IRuntimeElement createChild( boolean persisted ) { IRuntimeElement childRuntimeData = null; IRuntimeRepository runtimeRepository = PentahoSystem.get( IRuntimeRepository.class, session ); // the runtime repository is optional if ( runtimeRepository != null ) { runtimeRepository.setLoggingLevel( loggingLevel ); childRuntimeData = runtimeRepository.newRuntimeElement( instanceId, "instance", !persisted ); //$NON-NLS-1$ String childInstanceId = childRuntimeData.getInstanceId(); // audit the creation of this against the parent instance AuditHelper.audit( instanceId, session.getName(), getActionName(), getObjectName(), processId, MessageTypes.INSTANCE_START, childInstanceId, "", 0, this ); //$NON-NLS-1$ } return childRuntimeData; }
status = IRuntimeContext.RUNTIME_STATUS_FAILURE; long end = System.currentTimeMillis(); AuditHelper.audit( session.getId(), session.getName(), sequencePath, getObjectName(), processId, MessageTypes.INSTANCE_FAILED, runtime.getInstanceId(), Messages.getInstance().getErrorString( "SolutionEngine.ERROR_0007_ACTION_EXECUTION_FAILED" ), ( (float) ( end - start ) / 1000 ), this ); //$NON-NLS-1$ if ( instanceEnds ) { long end = System.currentTimeMillis(); AuditHelper.audit( session.getId(), session.getName(), sequencePath, getObjectName(), processId, MessageTypes.INSTANCE_END, runtime.getInstanceId(), "", ( (float) ( end - start ) / 1000 ), this ); //$NON-NLS-1$ AuditHelper.audit( session.getId(), session.getName(), sequencePath, getObjectName(), processId, MessageTypes.INSTANCE_FAILED, runtime.getInstanceId(), errorMsg, ( (float) ( end - start ) / 1000 ), this ); // $NON-NLS-1$
@Test public void testAuditHelper() throws Exception { when( context.getActionName() ).thenReturn( "testActionName" ); when( context.getInstanceId() ).thenReturn( "testInstanceId" ); when( context.getCurrentComponentName() ).thenReturn( "testCurrentComponentName" ); when( context.getProcessId() ).thenReturn( "testProcessId" ); AuditHelper.audit( context, session, TEST_TYPE, TEST_NAME, TEST_TEXT, TEST_DURATION, null ); TestAuditEntry entry = (TestAuditEntry) factory.get( IAuditEntry.class, null ); assertNotNull( "AuditEntry should not be null", entry ); entry.auditAll( "testProcessId", "testInstanceId", "testActionName", "testCurrentComponentName", "testuser", null, null, "testtext", null, 0 ); assertEquals( context.getInstanceId(), entry.instId ); assertEquals( context.getProcessId(), entry.jobId ); assertEquals( context.getActionName(), entry.objId ); assertEquals( context.getCurrentComponentName(), entry.objType ); assertEquals( SESSION_NAME, entry.actor ); assertEquals( TEST_TEXT, entry.messageTxtValue ); assertEquals( Long.valueOf( 1 ), AuditEntry.getCounts().get( TEST_TYPE ) ); }
@Test public void testAuditHelperNotValid() throws Exception { AuditHelper.audit( null, session, TEST_TYPE, TEST_NAME, TEST_TEXT, TEST_DURATION, null ); TestAuditEntry entry = (TestAuditEntry) factory.get( IAuditEntry.class, null ); assertNotNull( "AuditEntry should not be null", entry ); entry.auditAll( "", "", "", "", "testuser", null, null, "testtext", null, 0 ); assertEquals( StringUtils.EMPTY, entry.instId ); assertEquals( StringUtils.EMPTY, entry.jobId ); assertEquals( StringUtils.EMPTY, entry.objId ); assertEquals( StringUtils.EMPTY, entry.objType ); assertEquals( SESSION_NAME, entry.actor ); assertEquals( TEST_TEXT, entry.messageTxtValue ); assertEquals( Long.valueOf( 1 ), AuditEntry.getCounts().get( TEST_TYPE ) ); } }
public void testAuditFailures() { startTest(); OutputStream outputStream = getOutputStream( "testAudit", ".html" ); //$NON-NLS-1$ //$NON-NLS-2$ SimpleOutputHandler outputHandler = new SimpleOutputHandler( outputStream, true ); outputHandler.setOutputPreference( IOutputHandler.OUTPUT_TYPE_PARAMETERS ); StandaloneSession session = new StandaloneSession( Messages.getInstance().getString( "BaseTest.DEBUG_JUNIT_SESSION" ) ); //$NON-NLS-1$ AuditHelper.audit( null, session, "Type", "This is a message", "Values", 34, this ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertTrue( true ); finishTest(); }
AuditHelper.audit( session.getId(), session.getName(), actionPath, getObjectName(), processId, MessageTypes.INSTANCE_START, instanceId, "", 0, this ); //$NON-NLS-1$