Beispiel #1
0
 /// <summary>
 /// Creates a new instance of the ServerSession class.
 /// </summary>
 /// <param name="sessionID">Session ID</param>
 /// <param name="timestamp">Zeitstempel der Sitzung</param>
 /// <param name="identity">Client identity</param>
 /// <param name="sessionVariableAdapter">Adapter for accessing session variables</param>
 internal ServerSession(Guid sessionID, DateTime timestamp, IIdentity identity, SessionVariableAdapter sessionVariableAdapter)
 {
     _timestamp = timestamp;
     _sessionID = sessionID;
     _identity = identity;
     _sessionVariableAdapter = sessionVariableAdapter;
 }
Beispiel #2
0
        /// <summary>
        /// Processes logon.
        /// </summary>
        /// <param name="sessionID">Unique session key (created on client side)</param>
        /// <param name="credentials">Logon credentials</param>
        public void Logon(Guid sessionID, Hashtable credentials)
        {
            if (sessionID == Guid.Empty)
                throw new ArgumentException(LanguageResource.ArgumentException_EmptySessionIDIsNotAllowed, "sessionID");

            if (!_host.SessionManager.ExistSession(sessionID))
            {
                // reset current session before authentication is complete
                ServerSession.CurrentSession = null;

                AuthResponseMessage authResponse = _host.Authenticate(new AuthRequestMessage() { Credentials = credentials });
                if (!authResponse.Success)
                {
                    var exception = authResponse.Exception ?? new SecurityException(authResponse.ErrorMessage);
                    throw exception.PreserveStackTrace();
                }

                var sessionVariableAdapter = new SessionVariableAdapter(_host.SessionManager, sessionID);
                var session = new ServerSession(sessionID, authResponse.AuthenticatedIdentity, sessionVariableAdapter);
                _host.SessionManager.StoreSession(session);
                ServerSession.CurrentSession = session;
                PutClientAddressToCurrentSession();

                _host.OnClientLoggedOn(new LoginEventArgs(LoginEventType.Logon, session.Identity, session.ClientAddress, session.Timestamp));
            }
        }
Beispiel #3
0
 /// <summary>
 /// Creates a new instance of the ServerSession class.
 /// </summary>
 /// <param name="sessionID">Session ID</param>
 /// <param name="identity">Client identity</param>
 /// <param name="sessionVariableAdapter">Adapter for accessing session variables</param>
 internal ServerSession(Guid sessionID, IIdentity identity, SessionVariableAdapter sessionVariableAdapter)
     : this(sessionID, DateTime.Now, identity, sessionVariableAdapter)
 {
 }
Beispiel #4
0
        /// <summary>
        /// Meldet einen Client am Applikationserver an.
        /// </summary>
        /// <param name="sessionID">Sitzungsschlüssel (wird vom Client erstellt)</param>
        /// <param name="credentials">Anmeldeinformationen</param>
        public void Logon(Guid sessionID, Hashtable credentials)
        {
            // Wenn kein eindeutiger Sitzungsschlüssel angegeben wurde ...
            if (sessionID == Guid.Empty)
                // Ausnahme werfen
                throw new ArgumentException(LanguageResource.ArgumentException_EmptySessionIDIsNotAllowed, "sessionID");

            // Wenn noch keine Sitzung mit dem angegebenen Sitzungsschlüssel existiert ...
            if (!_host.SessionManager.ExistSession(sessionID))
            {
                // Authentifizieren
                AuthResponseMessage authResponse = _host.Authenticate(new AuthRequestMessage() { Credentials = credentials });

                // Wenn die Authentifizierung fehlgeschlagen ist ...
                if (!authResponse.Success)
                    // Ausnahme werfen
                    throw new SecurityException(authResponse.ErrorMessage);

                // Sitzungsvariablen-Adapter erzeugen
                SessionVariableAdapter sessionVariableAdapter = new SessionVariableAdapter(_host.SessionManager, sessionID);

                // Neue Sitzung erstellen
                ServerSession session = new ServerSession(sessionID, authResponse.AuthenticatedIdentity, sessionVariableAdapter);

                // Sitzung speichern
                _host.SessionManager.StoreSession(session);

                // Aktuelle Sitzung im Threadspeicher ablegen
                ServerSession.CurrentSession = session;
            }
        }