/** {@inheritDoc} */
  @Override
  public void importProvisioningGroup(final String requisitionName) {
    m_writeLock.lock();

    try {
      final Requisition requisition = getProvisioningGroup(requisitionName);
      saveProvisioningGroup(requisitionName, requisition);

      // then we send an event to the importer
      final EventProxy proxy = Util.createEventProxy();

      m_pendingForeignSourceRepository.flush();
      final String url =
          m_pendingForeignSourceRepository.getRequisitionURL(requisitionName).toString();
      Assert.notNull(url, "Could not find url for group " + requisitionName + ".  Does it exists?");

      final EventBuilder bldr = new EventBuilder(EventConstants.RELOAD_IMPORT_UEI, "Web");
      bldr.addParam(EventConstants.PARM_URL, url);

      try {
        proxy.send(bldr.getEvent());
      } catch (final EventProxyException e) {
        throw new DataAccessResourceFailureException(
            "Unable to send event to import group " + requisitionName, e);
      }
    } finally {
      m_writeLock.unlock();
    }
  }
 private void sendEvents(EventProxy eproxy, Events events) throws EventProxyException {
   if (events != null && events.getEventCount() > 0) {
     Log eventLog = new Log();
     eventLog.setEvents(events);
     eproxy.send(eventLog);
   }
 }
 private void sendEvent(Event demandPollEvent) {
   try {
     m_eventProxy.send(demandPollEvent);
   } catch (EventProxyException e) {
     throw new ServiceException("Exception occurred sending demandPollEvent", e);
   }
 }
  private void sendEvent(EventProxy proxy, long count) throws Exception {
    EventBuilder bldr =
        new EventBuilder(
            "uei.opennms.org/internal/authentication/successfulLogin", "MemoryLeakTest");
    bldr.addParam("user", "brozow");

    proxy.send(bldr.getEvent());

    long free = Runtime.getRuntime().freeMemory();
    long max = Runtime.getRuntime().maxMemory();

    double pct = ((double) free) / ((double) max);
    System.err.println("% Free Memory is " + pct);

    if (pct < 0.01) {
      throw new IllegalStateException("Memory Used up!");
    }
  }
  public void testAuthenticationFailureEvent() throws Exception {
    String userName = "******";
    String ip = "1.2.3.4";
    String sessionId = "it tastes just like our regular coffee";

    HttpServletRequest request = createMock(HttpServletRequest.class);
    HttpSession session = createMock(HttpSession.class);
    expect(request.getRemoteAddr()).andReturn(ip);
    expect(request.getSession(false)).andReturn(session);
    expect(session.getId()).andReturn(sessionId);

    replay(request, session);
    WebAuthenticationDetails details = new WebAuthenticationDetails(request);
    verify(request, session);

    org.springframework.security.core.Authentication authentication =
        new TestingDetailsAuthenticationToken(
            userName, "cheesiness", new GrantedAuthority[0], details);
    AuthenticationFailureBadCredentialsEvent authEvent =
        new AuthenticationFailureBadCredentialsEvent(
            authentication, new BadCredentialsException("you are bad!"));

    SecurityAuthenticationEventOnmsEventBuilder builder =
        new SecurityAuthenticationEventOnmsEventBuilder();
    builder.setEventProxy(m_eventProxy);
    builder.afterPropertiesSet();

    EventBuilder eventBuilder =
        new EventBuilder(SecurityAuthenticationEventOnmsEventBuilder.FAILURE_UEI, "OpenNMS.WebUI");
    eventBuilder.addParam("user", userName);
    eventBuilder.addParam("ip", ip);
    eventBuilder.addParam("exceptionName", authEvent.getException().getClass().getSimpleName());
    eventBuilder.addParam("exceptionMessage", authEvent.getException().getMessage());

    m_eventProxy.send(EventEquals.eqEvent(eventBuilder.getEvent()));

    m_mocks.replayAll();
    builder.onApplicationEvent(authEvent);
    m_mocks.verifyAll();
  }