/* (non-Javadoc)
@see javax.servlet.sip.SipSessionActivationListener#sessionWillPassivate(javax.servlet.sip.SipSessionEvent)
504909
public void sessionWillPassivate(SipSessionEvent event) {
		logger.info("Following sip session just passivated " + event.getSession().getId() + " cause " + ((SipSessionActivationEvent)event).getCause());
	}
336774
public PMSession registerSession(String sessionId) {
        synchronized (sessions) {
            if (sessionId != null) {
                if (!sessions.containsKey(sessionId)) {
                    sessions.put(sessionId, new PMSession(sessionId));
                }
                return getSession(sessionId);
            } else {
                return registerSession(newSessionId());
            }
        }
    }
211818
public void sessionDidActivate(ISession session) {
        HttpSession httpsession = (HttpSessionImpl) _adapter.adapt(session);
        HttpSessionEvent event = new HttpSessionEvent(httpsession);

        Enumeration enum1 = session.getAttributeNames();
        String attrName;
        Object attr;
        while (enum1.hasMoreElements()) {
            attrName = (String) enum1.nextElement();
            attr = session.getAttribute(attrName);
            if (attr instanceof HttpSessionActivationListener) {
                ((HttpSessionActivationListener) attr).sessionDidActivate(event);
            }
        }
    }
1220323
@Nullable
    protected final SSLSession sslSession() {
        checkState(!sessionProtocol.isTls() || sslSession != null,
                   "sslSession must be set for a TLS-enabled protocol: %s", sessionProtocol);
        return sessionProtocol.isTls() ? sslSession : null;
    }
763177
public SipApplicationSession createApplicationSession(boolean managed) {
		MobicentsSipApplicationSession sipApplicationSessionImpl = null; 
		HttpSession httpSession = threadLocalHttpSession.get();
		// make sure we don't create a new sip app session if the http session has already one associated
		if(httpSession != null) {
			ConvergedSession convergedSession = (ConvergedSession) httpSession;
			sipApplicationSessionImpl = convergedSession.getApplicationSession(false);
		}
		if(sipApplicationSessionImpl == null) {
			sipApplicationSessionImpl =
				(MobicentsSipApplicationSession)sipFactoryImpl.createApplicationSessionByAppName(sipContext.getApplicationName(), managed);
			associateHttpSession(sipApplicationSessionImpl);
		}
		return sipApplicationSessionImpl;
	}
431859
private void startSession() {
        AssumeRoleWithWebIdentityResult sessionTokenResult = securityTokenService
                .assumeRoleWithWebIdentity(new AssumeRoleWithWebIdentityRequest().withWebIdentityToken(wifToken)
                        .withProviderId(wifProvider)
                        .withRoleArn(roleArn)
                        .withRoleSessionName("ProviderSession")
                        .withDurationSeconds(this.sessionDuration));
        Credentials stsCredentials = sessionTokenResult.getCredentials();

        subjectFromWIF = sessionTokenResult.getSubjectFromWebIdentityToken();

        sessionCredentials = new BasicSessionCredentials(
                stsCredentials.getAccessKeyId(),
                stsCredentials.getSecretAccessKey(),
                stsCredentials.getSessionToken());
        sessionCredentialsExpiration = stsCredentials.getExpiration();
    }
569997
@OnOpen
    public void uiClientSessionOpen(Session session) {
        log.infoWsSessionOpened(session.getId(), endpoint);
        wsEndpoints.getUiClientSessions().addSession(session.getId(), session);
        WelcomeResponse welcomeResponse = new WelcomeResponse();
        // FIXME we should not send the true sessionIds to clients to prevent spoofing.
        welcomeResponse.setSessionId(session.getId());
        try {
            new WebSocketHelper().sendBasicMessageSync(session, welcomeResponse);
        } catch (IOException e) {
            log.warnf(e, "Could not send [%s] to UI client session [%s].", WelcomeResponse.class.getName(),
                    session.getId());
        }
    }
460102
public void init(String webAppRfsPath, String servletMapping, String defaultWebApplication) {

        try {
            // explicit set to null to overwrite exiting values from session
            m_availableModules = null;
            m_fullDatabaseKey = null;
            m_databaseKey = null;
            m_databaseKeys = null;
            m_databaseProperties = null;
            m_configuration = null;
            m_installModules = null;
            m_moduleDependencies = null;
            m_sortedDatabaseKeys = null;
            m_moduleFilenames = null;

            if (servletMapping == null) {
                servletMapping = "/opencms/*";
            }
            if (defaultWebApplication == null) {
                defaultWebApplication = "ROOT";
            }
            m_servletMapping = servletMapping;
            m_defaultWebApplication = defaultWebApplication;

            setWebAppRfsPath(webAppRfsPath);
            m_errors = new ArrayList<String>();

            if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(webAppRfsPath)) {
                m_configuration = new CmsParameterConfiguration(m_configRfsPath + CmsSystemInfo.FILE_PROPERTIES);
                readDatabaseConfig();
            }

            if (m_workplaceImportThread != null) {
                if (m_workplaceImportThread.isAlive()) {
                    m_workplaceImportThread.kill();
                }
                m_workplaceImportThread = null;
                m_newLoggingOffset = 0;
                m_oldLoggingOffset = 0;
            }
        } catch (Exception e) {
            e.printStackTrace();
            m_errors.add(e.toString());
        }
    }
90832
public void linkSipSessions(SipSession session1, SipSession session2) {
        if (session1 == null) {
            throw new NullPointerException("First argument is null");
        }
        if (session2 == null) {
            throw new NullPointerException("Second argument is null");
        }

        if (!((MobicentsSipSession) session1).isValidInternal() || !((MobicentsSipSession) session2).isValidInternal()
                || State.TERMINATED.equals(((MobicentsSipSession) session1).getState())
                || State.TERMINATED.equals(((MobicentsSipSession) session2).getState())
                || !session1.getApplicationSession().equals(session2.getApplicationSession())
                || (sessionMap.get(((MobicentsSipSession) session1).getId()) != null && !sessionMap.get(((MobicentsSipSession) session1).getId()).equals(((MobicentsSipSession) session2).getId()))
                || (sessionMap.get(((MobicentsSipSession) session2).getId()) != null
                && !sessionMap.get(((MobicentsSipSession) session2).getId()).equals(((MobicentsSipSession) session1).getId()))) {
            throw new IllegalArgumentException("either of the specified sessions has been terminated "
                    + "or the sessions do not belong to the same application session or "
                    + "one or both the sessions are already linked with some other session(s)");
        }
        this.sessionMap.put(((MobicentsSipSession) session1).getId(), ((MobicentsSipSession) session2).getId());
        this.sessionMap.put(((MobicentsSipSession) session2).getId(), ((MobicentsSipSession) session1).getId());
        if (logger.isDebugEnabled()) {
            logger.debug("sipsession " + ((MobicentsSipSession) session1).getKey() + " linked to sip session " + ((MobicentsSipSession) session2).getKey());
        }
        dumpAppSession((MobicentsSipSession) session1);
        dumpLinkedSessions();
    }
1038111
public void startupSessionTimeoutCommand() {
        if (initSessionTimeoutCommand.compareAndSet(false, true)) {
            final Long sessionTimeout = getSessionTimeout();
            if ( sessionTimeout != null && sessionTimeout > 0) {
                if ( scheduledEventslogger.isTraceEnabled() ) {
                    scheduledEventslogger.trace( "Establishing a session timeout of " + sessionTimeout + " seconds for WebSocket session (" + getId() + ").");
                }
                scheduleCommand(this.sessionTimeout, sessionTimeout);
            }
        }
    }
35852
public SipSession getSession(boolean create) {
		if(logger.isDebugEnabled()) {
			logger.debug("getSession - create=" + create);
		}

		MobicentsSipSession session = getSipSession();
		if (session == null && create) {
			MobicentsSipApplicationSession sipApplicationSessionImpl = (MobicentsSipApplicationSession)getSipApplicationSession(create);
                        if (sipApplicationSessionImpl != null) {
                            MobicentsSipSessionKey sessionKey = SessionManagerUtil.getSipSessionKey(sipApplicationSessionImpl.getKey().getId(), currentApplicationName, message, false);
                            session = sipApplicationSessionImpl.getSipContext().getSipManager().getSipSession(sessionKey, create,
                                            sipFactoryImpl, sipApplicationSessionImpl);
                            session.setSessionCreatingTransactionRequest(this);
                            session.setOrphan(isOrphan());
                            sessionKey = session.getKey();
                        }
		}

		if(session != null) {
			return session.getFacade();
		}
		if(logger.isDebugEnabled()) {
			logger.debug("getSession - returning null");
		}
		return null;
	}
907783
public void addEventListener(EventListener listener)
    throws IllegalArgumentException
    {
        
        if (listener instanceof HttpSessionAttributeListener)
            _sessionAttributeListeners.add(listener);
        if (listener instanceof HttpSessionListener)
            _sessionListeners.add(listener);
    }
465491
public void initFormForSession(
        final String sessionId,
        final Element formElement,
        final I_CmsClientCmsUgcSessionCallback onSuccess,
        final I_CmsErrorCallback onError) {

        getRpcHelper().executeRpc(SERVICE.getContent(new CmsUUID(sessionId), new AsyncCallback<CmsUgcContent>() {

            public void onFailure(Throwable caught) {

                handleError(caught, onError);
            }

            public void onSuccess(CmsUgcContent result) {

                CmsClientUgcSession session = new CmsClientUgcSession(CmsXmlContentUgcApi.this, result);
                session.initFormElement(formElement);
                onSuccess.call(session);
            }
        }));
    }
581322
@Override
    public Session createSession(int sessionMode) throws JMSException {

        Session session = null;

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createSession", new Object[] { sessionMode });
        try {
            if (sessionMode == JMSContext.SESSION_TRANSACTED)
                session = createSession(true, sessionMode);
            else
                session = createSession(false, sessionMode);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createSession");
        }
        return session;

    }
536897
@Override
    public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) throws NotConnectedException, InterruptedException {
        RTPBridge rtpBridge = RTPBridge.relaySession(lc.getConnection(), lc.getSessionId(), lc.getPassword(), rc, lc);
    }
265108
@SuppressWarnings("unchecked")
	public void sessionCreated(HttpSessionEvent se) {
		Descriptor<? extends Context> descriptor = container.contexts().get(Session.class);
		
		if (descriptor != null) {
			WebContext<HttpSession> context = (WebContext<HttpSession>) container.component(descriptor);
			context.associate(se.getSession());
		}
	}
1288376
public void sessionOpened(IoSession session) throws Exception {
        SingleSessionIoHandler handler = (SingleSessionIoHandler) session
                .getAttribute(HANDLER);
        handler.sessionOpened();
    }