/* (non-Javadoc)
@see org.jdiameter.api.auth.ServerAuthSessionListener#
doAbortSessionAnswerEvent(org.jdiameter.api.auth.ServerAuthSession, org.jdiameter.api.auth.events.AbortSessionAnswer)
774933
@Override
  public void doAbortSessionAnswerEvent(ServerAuthSession appSession, AbortSessionAnswer asa)
      throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
    logger.info("Diameter Gq AuthorizationSessionFactory :: doAbortSessionAnswerEvent :: appSession[{}], ASA[{}]", appSession, asa);
  }
235222
public void fireHttpSessionUpdated(final HttpSession session) {
		if (View.isInitialised() && !EventQueue.isDispatchThread()) {
			EventQueue.invokeLater(new Runnable() {

				@Override
				public void run() {
					fireHttpSessionUpdated(session);
				}
			});

			return;
		}

		int index = sessions.indexOf(session);
		fireTableRowsUpdated(index, index);
	}
370146
@Override
  public void doAuthRequestEvent(ServerAuthSession appSession, AppRequestEvent request)
      throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
    logger.info("Diameter Gq AuthorizationSessionFactory :: doAuthRequestEvent :: appSession[{}], Request[{}]", appSession, request);
  }
986653
@SuppressWarnings("checkstyle:npathcomplexity")
    @Override
    public int doFilter(EventFilter filter, Data dataKey, Object oldValue, Object dataValue, EntryEventType eventType,
                        String mapNameOrNull) {
        if (filter instanceof MapPartitionLostEventFilter) {
            return FILTER_DOES_NOT_MATCH;
        }

        // the order of the following ifs is important!
        // QueryEventFilter is instance of EntryEventFilter
        if (filter instanceof EventListenerFilter) {
            if (!filter.eval(eventType.getType())) {
                return FILTER_DOES_NOT_MATCH;
            } else {
                filter = ((EventListenerFilter) filter).getEventFilter();
            }
        }
        if (filter instanceof TrueEventFilter) {
            return eventType.getType();
        }
        if (filter instanceof QueryEventFilter) {
            return processQueryEventFilter(filter, eventType, dataKey, oldValue, dataValue, mapNameOrNull)
                    ? eventType.getType() : FILTER_DOES_NOT_MATCH;
        }
        if (filter instanceof EntryEventFilter) {
            return processEntryEventFilter(filter, dataKey) ? eventType.getType() : FILTER_DOES_NOT_MATCH;
        }
        throw new IllegalArgumentException("Unknown EventFilter type = [" + filter.getClass().getCanonicalName() + "]");
    }
1055308
@Override
  public void sendServerAssignmentAnswer(JServerAssignmentAnswer answer) throws InternalException, IllegalDiameterStateException, RouteException,
      OverloadException {
    send(Event.Type.SEND_MESSAGE, null, answer);
  }
893290
@Override
  public void doUserAuthorizationAnswer(ClientCxDxSession appSession, JUserAuthorizationRequest request, JUserAuthorizationAnswer answer)
      throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
    logger.info("Diameter Cx/Dx Session Factory :: doUserAuthorizationAnswer :: appSession[{}], Request[{}], Answer[{}]",
        new Object[]{appSession, request, answer});
  }
356851
@Override
  public void doAuthAnswerEvent(ClientAuthSession appSession, AppRequestEvent request, AppAnswerEvent answer)
      throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
    logger.info("Diameter Gq AuthorizationSessionFactory :: doAuthAnswerEvent :: appSession[{}], Request[{}], Answer[{}]",
        new Object[]{appSession, request, answer});
  }
186000
boolean handleCommonMethods(Object delegate, Method method, Object[] args) throws Throwable {
    if ("abort".equals(method.getName()) || "close".equals(method.getName())) {
      try {
        Reflection.invoke(delegate, method, args);
        return true;
      } finally {
        closed = true;
        afterClosure();
        interruptWaiters();
      }
    } else if ("addShutdownListener".equals(method.getName()) && args[0] != null)
      shutdownListeners.add((ShutdownListener) args[0]);
    else if ("removeShutdownListener".equals(method.getName()) && args[0] != null)
      shutdownListeners.remove((ShutdownListener) args[0]);
    return false;
  }
1188196
function abortSuite() {
    var event,
        me = this,
        resetting = calledBy.resetSuite;

    if (me.running) {
      event = Event('abort');
      me.emit(event);
      if (!event.cancelled || resetting) {
        // avoid infinite recursion
        calledBy.abortSuite = true;
        me.reset();
        delete calledBy.abortSuite;

        if (!resetting) {
          me.aborted = true;
          invoke(me, 'abort');
        }
      }
    }
    return me;
  }
907783
public void addEventListener(EventListener listener)
    throws IllegalArgumentException
    {
        
        if (listener instanceof HttpSessionAttributeListener)
            _sessionAttributeListeners.add(listener);
        if (listener instanceof HttpSessionListener)
            _sessionListeners.add(listener);
    }
1346746
public void abort() {
        URL abortURL = this.sessionInfo.getSessionEndpoints().getAbortEndpoint();
        BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), abortURL, HttpMethod.DELETE);
        request.send();
    }
283602
@Override
  public void doAbortSessionRequestEvent(ClientAuthSession appSession, AbortSessionRequest asr)
      throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
    logger.info("Diameter Gq AuthorizationSessionFactory :: doAbortSessionRequestEvent :: appSession[{}], ASR[{}]", appSession, asr);
  }
1259246
public void fireSessionCreated(IoSession session) {
        boolean firstSession = false;
        if (session.getService() instanceof IoConnector) {
            synchronized (managedSessions) {
                firstSession = managedSessions.isEmpty();
            }
        }

        // If already registered, ignore.
        if (managedSessions.putIfAbsent(session.getId(), session) != null) {
            return;
        }

        // If the first connector session, fire a virtual service activation event.
        if (firstSession) {
            fireServiceActivated();
        }

        // Fire session events.
        IoFilterChain filterChain = session.getFilterChain(); 
        filterChain.fireSessionCreated();
        filterChain.fireSessionOpened();

        int managedSessionCount = managedSessions.size();
        if (managedSessionCount > largestManagedSessionCount) {
            largestManagedSessionCount = managedSessionCount;
        }
        cumulativeManagedSessionCount ++;

        // Fire listener events.
        for (IoServiceListener l : listeners) {
            try {
                l.sessionCreated(session);
            } catch (Throwable e) {
                ExceptionMonitor.getInstance().exceptionCaught(e);
            }
        }
    }
434931
@SuppressWarnings("unchecked")
    @EventMapping(SearchConstants.SEARCH_REQUEST_QNAME_STRING)
    public void handleSearchRequest(EventRequest request, EventResponse response) {
        // UP-3887 Design flaw.  Both the searchLauncher portlet instance and the search portlet
        // instance receive
        // searchRequest and searchResult events because they are in the same portlet code base (to
        // share
        // autosuggest_handler.jsp and because we have to calculate the search portlet url for the
        // ajax call)
        // and share the portlet.xml which defines the event handling behavior.
        // If this instance is the searchLauncher, ignore the searchResult. The search was submitted
        // to the search
        // portlet instance.
        final String searchLaunchFname =
                request.getPreferences().getValue(SEARCH_LAUNCH_FNAME, null);
        if (searchLaunchFname != null) {
            // Noisy in debug mode so commented out log statement
            // logger.debug("SearchLauncher does not participate in SearchRequest events so
            // discarding message");
            return;
        }

        final Event event = request.getEvent();
        final SearchRequest searchQuery = (SearchRequest) event.getValue();

        // Map used to track searches that have been handled, used so that one search doesn't get
        // duplicate results
        ConcurrentMap<String, Boolean> searchHandledCache;
        final PortletSession session = request.getPortletSession();
        synchronized (org.springframework.web.portlet.util.PortletUtils.getSessionMutex(session)) {
            searchHandledCache =
                    (ConcurrentMap<String, Boolean>)
                            session.getAttribute(
                                    SEARCH_HANDLED_CACHE_NAME, PortletSession.APPLICATION_SCOPE);
            if (searchHandledCache == null) {
                searchHandledCache =
                        CacheBuilder.newBuilder()
                                .maximumSize(20)
                                .expireAfterAccess(5, TimeUnit.MINUTES)
                                .<String, Boolean>build()
                                .asMap();
                session.setAttribute(
                        SEARCH_HANDLED_CACHE_NAME,
                        searchHandledCache,
                        PortletSession.APPLICATION_SCOPE);
            }
        }

        final String queryId = searchQuery.getQueryId();
        if (searchHandledCache.putIfAbsent(queryId, Boolean.TRUE) != null) {
            // Already handled this search request
            return;
        }

        // Create the results
        final SearchResults results = new SearchResults();
        results.setQueryId(queryId);
        results.setWindowId(request.getWindowID());
        final List<SearchResult> searchResultList = results.getSearchResult();

        // Run the search for each service appending the results
        for (IPortalSearchService searchService : searchServices) {
            try {
                logger.debug(
                        "For queryId {}, query '{}', searching search service {}",
                        queryId,
                        searchQuery.getSearchTerms(),
                        searchService.getClass().toString());
                final SearchResults serviceResults =
                        searchService.getSearchResults(request, searchQuery);
                logger.debug(
                        "For queryId {}, obtained {} results from search service {}",
                        queryId,
                        serviceResults.getSearchResult().size(),
                        searchService.getClass().toString());
                searchResultList.addAll(serviceResults.getSearchResult());
            } catch (Exception e) {
                logger.warn(
                        searchService.getClass()
                                + " threw an exception when searching, it will be ignored. "
                                + searchQuery,
                        e);
            }
        }

        // Respond with a results event if results were found
        if (!searchResultList.isEmpty()) {
            response.setEvent(SearchConstants.SEARCH_RESULTS_QNAME, results);
        }
    }
65787
@Override
  public RetryDecision onRequestAborted(
      @NonNull Request request, @NonNull Throwable error, int retryCount) {

    RetryDecision decision =
        (error instanceof ClosedConnectionException || error instanceof HeartbeatException)
            ? RetryDecision.RETRY_NEXT
            : RetryDecision.RETHROW;

    if (decision == RetryDecision.RETRY_NEXT && LOG.isTraceEnabled()) {
      LOG.trace(RETRYING_ON_ABORTED, logPrefix, retryCount, error);
    }

    return decision;
  }
843694
@SneakyThrows
    public Event terminate(final RequestContext context) {
        val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(context);
        val response = WebUtils.getHttpServletResponseFromExternalWebflowContext(context);

        val tgtId = getTicketGrantingTicket(context);
        if (StringUtils.isNotBlank(tgtId)) {
            LOGGER.trace("Destroying SSO session linked to ticket-granting ticket [{}]", tgtId);
            val logoutRequests = this.centralAuthenticationService.destroyTicketGrantingTicket(tgtId);
            WebUtils.putLogoutRequests(context, logoutRequests);
        }
        LOGGER.trace("Removing CAS cookies");
        this.ticketGrantingTicketCookieGenerator.removeCookie(response);
        this.warnCookieGenerator.removeCookie(response);

        destroyApplicationSession(request, response);
        LOGGER.debug("Terminated all CAS sessions successfully.");

        if (StringUtils.isNotBlank(logoutProperties.getRedirectUrl())) {
            WebUtils.putLogoutRedirectUrl(context, logoutProperties.getRedirectUrl());
            return this.eventFactorySupport.event(this, CasWebflowConstants.STATE_ID_REDIRECT);
        }

        return this.eventFactorySupport.success(this);
    }
820010
public void onConnected(int serverSessionTimeout, String sessionId, byte[] sessionPassword, int serverId) {

        if (serverSessionTimeout <= 0) {
            closeSession();
            LOGGER.error("Unable to reconnect to Directory Server, session 0x" + sessionId + " has expired");
            return;
        }

        boolean reopen = session.id == null || session.id.equals("") ? false : true;
        session.timeOut = serverSessionTimeout;
        session.id = sessionId;
        session.password = sessionPassword;
        session.serverId = serverId;
        if(getStatus().isAlive()){
            setStatus(ConnectionStatus.CONNECTED);
        }
        if(reopen){
            eventThread.queueClientEvent(new ClientSessionEvent(SessionEvent.REOPEN));
        } else {
            eventThread.queueClientEvent(new ClientSessionEvent(SessionEvent.CREATED));
        }

        LOGGER.info("Session establishment complete on server " + this.clientSocket.getRemoteSocketAddress()
                + ", sessionid = 0x" + sessionId + ", session timeout = " + session.timeOut
                + ", serverId=" + session.serverId);

    }