private void dumpDB2Log(int numberOfEntries) {
   List<StreamingStatLogEntry> logEntries =
       ((StreamingEventLogger) StreamingEventLogger.getInstance())
           .getLogEntryLatest(numberOfEntries);
   int i = 0;
   logger.debug("Dumping " + logEntries.size() + "/" + numberOfEntries + " entries to the log");
   for (StreamingStatLogEntry logEntry : logEntries) {
     logger.debug("Log entry [" + i + "] : " + logEntry.toString());
     i++;
   }
 }
 @Before
 public void setUp() throws Exception {
   org.apache.log4j.BasicConfigurator.configure();
   logger.info("setUp()");
   MCMPortalInterfaceStatisticsImpl.createInstanceForTestPurpose(
       new MCMPortalInterfaceStatisticsMock(logger));
   IClient client = new IClientMock("sessionID=sample.mp4&objectID=643703&includeFiles=true");
   IMediaStreamMock mediaStream = new IMediaStreamMock("sample2.mp4", client);
   statLogSBMediaStreamAcitonNotify =
       new StatisticLoggingStreamListener(logger, mediaStream, streamingEventLogger);
   StreamingEventLoggerTest.createDBEventTable(logger, connection);
 }
Ejemplo n.º 3
0
  /**
   * This method checks if the ticket is given to the same IP address as the client
   *
   * @param stream the stream
   * @param streamingTicket the ticket
   * @return true if the ip is the same for the ticket and the user
   */
  private boolean isClientAllowed(IMediaStream stream, Ticket streamingTicket) {
    String ipOfClient = stream.getClient().getIp();

    boolean isAllowed = (ipOfClient != null) && (ipOfClient.equals(streamingTicket.getIpAddress()));
    logger.debug(
        "isClientAllowed - ipOfClient: "
            + ipOfClient
            + ", streamingTicket.getIpAddress(): "
            + streamingTicket.getIpAddress()
            + ", isAllowed: "
            + isAllowed);
    return isAllowed;
  }
  @Test
  public void testStatisticLoggingSBMediaStreamActionNotify2TestOnStop() throws SQLException {
    // Establish connection
    Date dateBeforeConnection = new Date();
    IClient client = new IClientMock("queryString");
    IMediaStreamMock mediaStream = new IMediaStreamMock("sample.mp4", client);
    statLogSBMediaStreamAcitonNotify.onPlay(mediaStream, mediaStream.getName(), 0.0, 0.0, 0);
    statLogSBMediaStreamAcitonNotify.onStop(mediaStream);
    // Fetch data
    StreamingStatLogEntry logEntry = StreamingEventLogger.getInstance().getLogEntryLatest();
    logger.debug("Found log entry: " + logEntry.toString());

    Assert.assertEquals("Result is:", 2, logEntry.getEventID());
    Assert.assertEquals("Result is:", mediaStream.getClientId(), logEntry.getUserID());
    Assert.assertTrue(dateBeforeConnection.getTime() <= logEntry.getTimestamp().getTime());
    Assert.assertEquals("Result is:", Event.STOP, logEntry.getEvent());
  }
Ejemplo n.º 5
0
 /**
  * Check if a stream is allowed to play
  *
  * @return true if allowed, false otherwise.
  */
 public boolean checkTicket(IMediaStream stream) {
   String name = stream.getName();
   IClient client = stream.getClient();
   if (client == null) {
     logger.debug("No client, returning ", stream);
     return false;
   }
   String clientQuery = stream.getClient().getQueryStr();
   logger.trace(
       "checkTicket(IMediaStream stream="
           + stream
           + ", String name="
           + name
           + ", String clientQuery="
           + clientQuery
           + ")");
   try {
     Ticket streamingTicket = StringAndTextUtil.getTicket(clientQuery, ticketTool);
     logger.debug(
         "Ticket received: " + (streamingTicket != null ? streamingTicket.getId() : "null"));
     if (streamingTicket != null
         && isClientAllowed(stream, streamingTicket)
         && ticketForThisPresentationType(streamingTicket)
         && doesTicketAllowThisStream(name, streamingTicket)) {
       logger.info(
           "checkTicket(IMediaStream stream="
               + stream
               + ", String name="
               + name
               + ", String clientQuery="
               + clientQuery
               + ") successful.");
       return true;
     } else {
       logger.info(
           "Client not allowed to get content streamed for IMediaStream stream="
               + stream
               + ", String name="
               + name
               + ", String clientQuery="
               + clientQuery
               + ")");
       return false;
     }
   } catch (IllegallyFormattedQueryStringException e) {
     logger.warn("Illegally formatted query string [" + clientQuery + "].");
     return false;
   }
 }