Package org.apache.hadoop.gateway.audit.api

Examples of org.apache.hadoop.gateway.audit.api.CorrelationContext


    ac.setProxyUsername( proxyUsername );
    ac.setRemoteIp( remoteIp );
    ac.setRemoteHostname( remoteHostname );
    ac.setTargetServiceName( targetServiceName );
   
    CorrelationContext cc = correlationService.createContext();
    cc.setRequestId( UUID.randomUUID().toString() );
    cc.setParentRequestId( UUID.randomUUID().toString() );
    cc.setRootRequestId( UUID.randomUUID().toString() );
   
    CollectAppender.queue.clear();
    for( int i = 0; i < iterations; i++ ) {
      auditor.audit( "action" + i, "resource" + i, "resource type" + i, "outcome" + i, "message" + i );
    }
View Full Code Here


    ac.setProxyUsername( proxyUsername );
    ac.setRemoteIp( remoteIp );
    ac.setRemoteHostname( remoteHostname );
    ac.setTargetServiceName( targetServiceName );
   
    CorrelationContext cc = correlationService.createContext();
    cc.setRequestId( UUID.randomUUID().toString() );
    cc.setParentRequestId( UUID.randomUUID().toString() );
    cc.setRootRequestId( UUID.randomUUID().toString() );

    auditor.audit( "action", "resource", "resource type", "outcome", "message" );
   
    auditService.detachContext();
    correlationService.detachContext();
   
    assertThat( CollectAppender.queue.size(), is( 1 ) );
    LoggingEvent event = CollectAppender.queue.iterator().next();
    checkLogEventContexts( event, cc, ac );
   
    CollectAppender.queue.clear();
   
    ac = auditService.createContext();
    ac.setUsername( username + "1" );
    ac.setProxyUsername( proxyUsername + "1" );
    ac.setRemoteIp( remoteIp + "1" );
    ac.setRemoteHostname( remoteHostname + "1" );
    ac.setTargetServiceName( targetServiceName + "1" );
   
    cc = correlationService.createContext();
    cc.setRequestId( UUID.randomUUID().toString() );
    cc.setParentRequestId( UUID.randomUUID().toString() );
    cc.setRootRequestId( UUID.randomUUID().toString() );
   
    auditor.audit( "action", "resource", "resource type", "outcome", "message" );
   
    auditService.detachContext();
    correlationService.detachContext();
View Full Code Here

    assertThat( context.getSystemUsername(), is( expectedAuditContext.getSystemUsername() ) );
    assertThat( context.getRemoteIp(), is( expectedAuditContext.getRemoteIp() ) );
    assertThat( context.getRemoteHostname(), is( expectedAuditContext.getRemoteHostname() ) );
    assertThat( context.getTargetServiceName(), is( expectedAuditContext.getTargetServiceName() ) );
        
    CorrelationContext correlationContext =  (CorrelationContext)event.getMDC( Log4jCorrelationService.MDC_CORRELATION_CONTEXT_KEY );
    assertThat( correlationContext.getRequestId(), is( expectedCorrelationContext.getRequestId() ) );
    assertThat( correlationContext.getRootRequestId(), is( expectedCorrelationContext.getRootRequestId() ) );
    assertThat( correlationContext.getParentRequestId(), is( expectedCorrelationContext.getParentRequestId() ) );
  }
View Full Code Here

    Holder holder = new Holder( path, name, clazz, params, resourceRole );
    addHolder( holder );
  }
 
  private void assignCorrelationRequestId() {
    CorrelationContext correlationContext = CorrelationServiceFactory.getCorrelationService().createContext();
    correlationContext.setRequestId( UUID.randomUUID().toString() );
  }
View Full Code Here

  private void verifyAuditEvent( LoggingEvent event, String resourceName,
      String resourceType, String action, String outcome, String targetService,
      String message ) {
    event.getMDCCopy();
    CorrelationContext cc = (CorrelationContext) event.getMDC( Log4jCorrelationService.MDC_CORRELATION_CONTEXT_KEY );
    assertThat( cc, notNullValue() );
    assertThat( cc.getRequestId(), is( notNullValue() ) );
    AuditContext ac = (AuditContext) event.getMDC( Log4jAuditService.MDC_AUDIT_CONTEXT_KEY );
    assertThat( ac, notNullValue() );
    assertThat( ac.getRemoteIp(), is( ADDRESS ) );
    assertThat( ac.getRemoteHostname(), is( HOST ) );
    assertThat( (String) event.getMDC( AuditConstants.MDC_SERVICE_KEY ), is( AuditConstants.KNOX_SERVICE_NAME ) );
View Full Code Here

      assertThat( actual, is( expected ) );
    }
  }

  private String getRequestId( LoggingEvent event ) {
    CorrelationContext cc = (CorrelationContext) event
        .getMDC( Log4jCorrelationService.MDC_CORRELATION_CONTEXT_KEY );
    return cc == null ? null : cc.getRequestId();
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.gateway.audit.api.CorrelationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.