public void Can_compare_with_guids() { var value = Guid.NewGuid(); var sessionId1 = new SessionId(value, true); var sessionId2 = new SessionId(Guid.NewGuid(), false); Assert.True(sessionId1.Equals(value)); Assert.False(sessionId2.Equals(value)); }
public InProcSession Create(SessionId sessionId, ISession wrappedSession) { if (sessionId == null) throw new ArgumentNullException("sessionId"); if (sessionId.IsEmpty) throw new ArgumentException("The session id cannot be empty", "sessionId"); if (wrappedSession == null) throw new ArgumentNullException("wrappedSession"); return new InProcSession(sessionId, wrappedSession, _systemClock.NowUtc, _configuration.SessionTimeout); }
public UserContextData(SessionId sessionId, IUser currentUser, IRights rights) { _currentUser = currentUser; _sessionId = sessionId; _rights = rights; _sessionFactory = AppliactionContext.Configuartion.BuildSessionFactory(); IsAuthenticated = true; }
private void Application_PreRequestHandlerExecute(object sender, EventArgs e) { HttpApplication app = sender as HttpApplication; if (app.Context.Session != null && app.Context.Session.SessionID != null) { SessionId sessionId = new SessionId(app.Context.Session.SessionID); UserContext.SetupThreadContext(sessionId); } }
public void Equals_other_session_with_same_id() { var sessionId = new SessionId(Guid.NewGuid(), false); var inProcSession1 = new InProcSession(sessionId, _wrappedSession, DateTime.Now, TimeSpan.FromSeconds(3)); var inProcSession2 = new InProcSession(sessionId, _wrappedSession, DateTime.Now, TimeSpan.FromSeconds(3)); var actual = inProcSession1.Equals(inProcSession2); Assert.True(actual); }
public void Supports_inequality_operator() { var value = Guid.NewGuid(); var sessionId1 = new SessionId(value, true); var sessionId2 = new SessionId(value, false); var sessionId3 = new SessionId(Guid.NewGuid(), false); Assert.False(sessionId1 != sessionId2); Assert.True(sessionId1 != sessionId3); Assert.True(sessionId2 != sessionId3); }
public InProcSession(SessionId id, ISession wrappedSession, DateTime lastSave, TimeSpan timeout) { if (id == null) throw new ArgumentNullException("id"); if (wrappedSession == null) throw new ArgumentNullException("wrappedSession"); if (id.IsEmpty) throw new ArgumentException("The specified session id cannot be empty", "id"); WrappedSession = wrappedSession; Id = id; LastSave = lastSave; Timeout = timeout; }
public UserContextData(SessionId sessionId, IUser currentUser, IRights rights) { _dbOperations = AppliactionContext.DbOperationsFactory.CreateDbOperations(); _sessionId = sessionId; _currentUser = currentUser; _rights = rights; IsAuthenticated = true; }
public SessionAction(SessionActionTag tag, long time, SessionId sessionId, string systemName, string nodeName, int timeout, string key, string value, string type) { Tag = tag; Time = time; SessionId = sessionId; SystemName = systemName; NodeName = nodeName; Timeout = timeout; Key = key; Value = value; Type = type; }
public void When_session_is_not_found_then_returns_new_empty_session() { var sessionId = new SessionId(Guid.NewGuid(), false); A.CallTo(() => _fakeSessionIdentificationMethod.GetCurrentSessionId(_nancyContext)).Returns(sessionId); A.CallTo(() => _fakeSessionCache.Get(sessionId)).Returns(null); var actual = _sessionManager.Load(_nancyContext); Assert.NotNull(actual); Assert.IsNotType<InProcSession>(actual); Assert.Equal(0, actual.Count); }
public void Loads_session_with_id_from_identification_method() { var sessionId = new SessionId(Guid.NewGuid(), false); var expectedSession = new InProcSession(sessionId, A.Fake<ISession>(), DateTime.Now, TimeSpan.FromMinutes(10)); A.CallTo(() => _fakeSessionIdentificationMethod.GetCurrentSessionId(_nancyContext)).Returns(sessionId); A.CallTo(() => _fakeSessionCache.Get(sessionId)).Returns(expectedSession); var actual = _sessionManager.Load(_nancyContext); Assert.Equal(expectedSession, actual); A.CallTo(() => _fakeSessionIdentificationMethod.GetCurrentSessionId(_nancyContext)).MustHaveHappened(); A.CallTo(() => _fakeSessionCache.Get(sessionId)).MustHaveHappened(); }
public InProcSession Get(SessionId id) { CheckDisposed(); if (id == null) throw new ArgumentNullException("id"); using (new HeldUpgradeableReadLock(_rwlock)) { var foundSession = _sessions.SingleOrDefault(session => session.Id == id); // CQS violation, for convenience if (foundSession != null && foundSession.IsExpired(_systemClock.NowUtc)) { using (new HeldWriteLock(_rwlock)) { _sessions.Remove(foundSession); foundSession = null; } } return foundSession; } }
public Load() { _context = new NancyContext {Request = new Request("GET", "http://www.google.be?_nsid=01HMAC02SessionId")}; _newSessionId = new SessionId(Guid.NewGuid(), false); A.CallTo(() => _fakeSessionIdFactory.CreateNew()).Returns(_newSessionId); }
public void Given_empty_session_id_then_throws() { var emptySessionId = new SessionId(Guid.Empty, false); Assert.Throws<ArgumentException>(() => _byQueryStringParamIdentificationMethod.SaveSessionId(emptySessionId, _context)); }
public GetBasket(SessionId sessionId) { SessionId = sessionId; }
/// <summary> /// Get an active session /// </summary> /// <param name="sessionId"></param> /// <returns></returns> public Option <SessionVector> GetSession(SessionId sessionId) => sessions.Find(sessionId);
public static SessionAction Start(SessionId sessionId, int timeoutSeconds, SystemName systemName, ProcessName nodeName) => new SessionAction(SessionActionTag.Start, 0L, sessionId, systemName.Value, nodeName.Value, timeoutSeconds, null, null, null);
public void Get_returns_null_if_id_is_not_found() { var nonExistingId = new SessionId(Guid.NewGuid(), false); var actual = _inProcSessionCache.Get(nonExistingId); Assert.Null(actual); }
public override string ToString() { StringBuilder headerTLVBuilder = new StringBuilder(); headerTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Header TLVs ({0}) : ", headerTLVs.Count.ToString(System.Globalization.CultureInfo.InvariantCulture))); if (headerTLVs.Count > 0) { foreach (KeyValuePair <byte, byte[]> keyvalue in headerTLVs) { headerTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{1:x}({0}),", keyvalue.Key.ToString(System.Globalization.CultureInfo.InvariantCulture), keyvalue.Key)); headerTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{1:x}({0}),( ", keyvalue.Value.Length.ToString(System.Globalization.CultureInfo.InvariantCulture), keyvalue.Value.Length)); foreach (byte b in keyvalue.Value) { headerTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "0x{0:x2} ", b)); } headerTLVBuilder.Append("); "); } } headerTLVBuilder.Append("\r\n"); StringBuilder bodyTLVBuilder = new StringBuilder(); bodyTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, " DataPacket TLVs ({0}): ", dataPacketTLVs.Count.ToString(System.Globalization.CultureInfo.InvariantCulture))); if (dataPacketTLVs.Count > 0) { foreach (KeyValuePair <byte, byte[]> keyvalue in dataPacketTLVs) { bodyTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{1:x}({0}),", keyvalue.Key.ToString(System.Globalization.CultureInfo.InvariantCulture), keyvalue.Key)); bodyTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{1:x}({0}),( ", keyvalue.Value.Length.ToString(System.Globalization.CultureInfo.InvariantCulture), keyvalue.Value.Length)); foreach (byte b in keyvalue.Value) { bodyTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "0x{0:x2} ", b)); } bodyTLVBuilder.Append("); "); } } bodyTLVBuilder.Append("\r\n"); int dataHeaderLen = DataPacketHeaderLength; return("[P2Pv2Header]\r\n" + String.Format(System.Globalization.CultureInfo.InvariantCulture, "HeaderLength : {1:x} ({0})\r\n", HeaderLength.ToString(System.Globalization.CultureInfo.InvariantCulture), HeaderLength) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "OperationCode : {1:x} ({0})\r\n", (byte)OperationCode, Convert.ToString(OperationCode)) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "MessageSize : {1:x} ({0})\r\n", MessageSize.ToString(System.Globalization.CultureInfo.InvariantCulture), MessageSize) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "Identifier : {1:x} ({0})\r\n", Identifier.ToString(System.Globalization.CultureInfo.InvariantCulture), Identifier) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "AckIdentifier : {1:x} ({0})\r\n", AckIdentifier.ToString(System.Globalization.CultureInfo.InvariantCulture), AckIdentifier) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "NakIdentifier : {1:x} ({0})\r\n", NakIdentifier.ToString(System.Globalization.CultureInfo.InvariantCulture), NakIdentifier) + headerTLVBuilder.ToString() + String.Format(System.Globalization.CultureInfo.InvariantCulture, " Data HeaderLength : {1:x} ({0})\r\n", dataHeaderLen.ToString(System.Globalization.CultureInfo.InvariantCulture), dataHeaderLen) + String.Format(System.Globalization.CultureInfo.InvariantCulture, " TFCombination : {1:x} ({0})\r\n", (byte)TFCombination, Convert.ToString(TFCombination)) + String.Format(System.Globalization.CultureInfo.InvariantCulture, " PackageNumber : {1:x} ({0})\r\n", PackageNumber.ToString(System.Globalization.CultureInfo.InvariantCulture), PackageNumber) + String.Format(System.Globalization.CultureInfo.InvariantCulture, " SessionId : {1:x} ({0})\r\n", SessionId.ToString(System.Globalization.CultureInfo.InvariantCulture), SessionId) + String.Format(System.Globalization.CultureInfo.InvariantCulture, " DataRemaining : {1:x} ({0})\r\n", DataRemaining.ToString(System.Globalization.CultureInfo.InvariantCulture), DataRemaining) + bodyTLVBuilder.ToString()); }
void QuestStateChange(QuestState state, SessionId agent, int index, bool isJoin = true) { try { uint flag = (uint)(0x1 << index); Status status = null; if (!PerUserStatus.TryGetValue(agent, out status)) { return; } status.Offered &= ~flag; status.Active &= ~flag; status.Completed &= ~flag; status.ObjectivesCompleted &= ~flag; status.SelectReward &= ~flag; status.None &= ~flag; switch (state) { case QuestState.Offered: status.Offered |= flag; break; case QuestState.Active: status.Active |= flag; break; case QuestState.Completed: status.Completed |= flag; break; case QuestState.ObjectivesCompleted: status.ObjectivesCompleted |= flag; break; case QuestState.SelectReward: status.SelectReward |= flag; break; case QuestState.None: status.None |= flag; break; default: break; } bool visible = false; if (ShowOnAny) { visible |= (VisibleOnOffered & status.Offered != 0); visible |= (VisibleOnActive & status.Active != 0); visible |= (VisibleOnCompleted & status.Completed != 0); visible |= (VisibleOnObjectivesCompleted & status.ObjectivesCompleted != 0); visible |= (VisibleOnSelectReward & status.SelectReward != 0); visible |= (VisibleOnNone & status.None != 0); } else if (ShowOnAll) { visible |= (VisibleOnOffered & status.Offered == All); visible |= (VisibleOnActive & status.Active == All); visible |= (VisibleOnCompleted & status.Completed == All); visible |= (VisibleOnObjectivesCompleted & status.ObjectivesCompleted == All); visible |= (VisibleOnSelectReward & status.SelectReward == All); visible |= (VisibleOnNone & status.None == All); } else { visible |= (VisibleOnOffered & status.Offered == 0); visible |= (VisibleOnActive & status.Active == 0); visible |= (VisibleOnCompleted & status.Completed == 0); visible |= (VisibleOnObjectivesCompleted & status.ObjectivesCompleted == 0); visible |= (VisibleOnSelectReward & status.SelectReward == 0); visible |= (VisibleOnNone & status.None == 0); } SetVisibility(agent, visible, isJoin); } catch { } }
public void OnRemoveUser(SessionId session) { PerUserState.Remove(session); }
public Session GetSession(SessionId sessionId) { throw new NotImplementedException(); }
public UserId?GetUserIdOfSession(SessionId sessionId) { throw new NotImplementedException(); }
/// <summary> /// The configured upper queue threshole for a client's queue has been reached. /// </summary> /// <param name="client">The client session identifier.</param> /// <param name="policy">The message queue policy.</param> public override void OnUpperThresholdCrossed(SessionId client, IMessageQueuePolicy policy) { // The SetThrottled method enables throttling and conflation. This method requires the client session // to have the MODIFY_SESSION topic permission. theClientControl.SetThrottled(client, ThrottlerType.MESSAGE_INTERVAL, 10, theClientCallback); }
public async IAsyncEnumerable <SourceFile> Load(SessionId sessionId, string[] loaded_files, [EnumeratorCancellation] CancellationToken token) { var asm_files = new List <string>(); var pdb_files = new List <string>(); foreach (string file_name in loaded_files) { if (file_name.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase)) { pdb_files.Add(file_name); } else { asm_files.Add(file_name); } } List <DebugItem> steps = new List <DebugItem>(); foreach (string url in asm_files) { try { string candidate_pdb = Path.ChangeExtension(url, "pdb"); string pdb = pdb_files.FirstOrDefault(n => n == candidate_pdb); steps.Add( new DebugItem { Url = url, Data = Task.WhenAll(client.GetByteArrayAsync(url, token), pdb != null ? client.GetByteArrayAsync(pdb, token) : Task.FromResult <byte[]>(null)) }); } catch (Exception e) { logger.LogDebug($"Failed to read {url} ({e.Message})"); } } foreach (DebugItem step in steps) { AssemblyInfo assembly = null; try { byte[][] bytes = await step.Data.ConfigureAwait(false); assembly = new AssemblyInfo(step.Url, bytes[0], bytes[1]); } catch (Exception e) { logger.LogDebug($"Failed to load {step.Url} ({e.Message})"); } if (assembly == null) { continue; } if (GetAssemblyByUnqualifiedName(assembly.AssemblyNameUnqualified) != null) { logger.LogDebug($"Skipping loading {assembly.Name} into the debug store, as it already exists"); continue; } assemblies.Add(assembly); foreach (SourceFile source in assembly.Sources) { yield return(source); } } }
/// <summary> /// Receives content sent from a session via a topic. /// </summary> /// <param name="sessionId">Identifies the client session that sent the content.</param> /// <param name="topicPath">The path of the topic that the content was sent on.</param> /// <param name="content">The content sent by the client.</param> /// <param name="context">The context associated with the content.</param> public virtual void OnMessage( SessionId sessionId, string topicPath, IContent content, IReceiveContext context ) { }
public void Objects_with_equal_values_are_equal() { var value = Guid.NewGuid(); var sessionId1 = new SessionId(value, true); var sessionId2 = new SessionId(value, false); Assert.True(sessionId1.Equals(sessionId2)); }
void ObjectiveStateChange(ObjectiveState state, SessionId agent, int index, bool isJoin = true) { try { uint setFlag = (uint)(0x1 << index); Status status = null; if (!PerUserStatus.TryGetValue(agent, out status)) { if (isJoin) { status = new Status(); PerUserStatus[agent] = status; } else { return; } } status.Active &= ~setFlag; status.Completed &= ~setFlag; status.Locked &= ~setFlag; status.None &= ~setFlag; switch (state) { case ObjectiveState.Active: status.Active |= setFlag; break; case ObjectiveState.Completed: status.Completed |= setFlag; break; case ObjectiveState.Locked: status.Locked |= setFlag; break; case ObjectiveState.None: status.None |= setFlag; break; default: break; } bool visible = false; if (ShowOnAny) { visible |= (VisibleOnActive & status.Active != 0); visible |= (VisibleOnCompleted & status.Completed != 0); visible |= (VisibleOnLocked & status.Locked != 0); visible |= (VisibleOnNone & status.None != 0); } else if (ShowOnAll) { visible |= (VisibleOnActive & status.Active == All); visible |= (VisibleOnCompleted & status.Completed == All); visible |= (VisibleOnLocked & status.Locked == All); visible |= (VisibleOnNone & status.None == All); } else { visible |= (VisibleOnActive & status.Active == 0); visible |= (VisibleOnCompleted & status.Completed == 0); visible |= (VisibleOnLocked & status.Locked == 0); visible |= (VisibleOnNone & status.None == 0); } SetVisibility(agent, visible, isJoin); } catch { } }
public void A_null_session_id_is_not_equal_to_a_non_null_session_id() { SessionId one = null; var two = new SessionId(Guid.NewGuid(), true); Assert.False(one == two); }
public string GetSessionId() { return(SessionId.ToString()); }
public override string ToString() { return("[P2Pv1Header]\r\n" + String.Format(System.Globalization.CultureInfo.InvariantCulture, "SessionId : {1:x} ({0})\r\n", SessionId.ToString(System.Globalization.CultureInfo.InvariantCulture), SessionId) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "Identifier : {1:x} ({0})\r\n", Identifier.ToString(System.Globalization.CultureInfo.InvariantCulture), Identifier) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "Offset : {1:x} ({0})\r\n", Offset.ToString(System.Globalization.CultureInfo.InvariantCulture), Offset) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "TotalSize : {1:x} ({0})\r\n", TotalSize.ToString(System.Globalization.CultureInfo.InvariantCulture), TotalSize) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "MessageSize : {1:x} ({0})\r\n", MessageSize.ToString(System.Globalization.CultureInfo.InvariantCulture), MessageSize) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "Flags : {1:x} ({0})\r\n", (uint)Flags, Convert.ToString(Flags)) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "AckSessionId : {1:x} ({0})\r\n", AckSessionId.ToString(System.Globalization.CultureInfo.InvariantCulture), AckSessionId) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "AckIdentifier : {1:x} ({0})\r\n", AckIdentifier.ToString(System.Globalization.CultureInfo.InvariantCulture), AckIdentifier) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "AckTotalSize : {1:x} ({0})\r\n", AckTotalSize.ToString(System.Globalization.CultureInfo.InvariantCulture), AckTotalSize)); }
public override int GetHashCode() { return(SessionId.GetHashCode() ^ BroadcastCallBack.GetHashCode() ^ ClientInfo.GetHashCode()); }
public static SessionAction SetData(long time, SessionId sessionId, string key, string data, SystemName systemName, ProcessName nodeName) => new SessionAction(SessionActionTag.SetData, time, sessionId, systemName.Value, nodeName.Value, 0, key, data, data.GetType().AssemblyQualifiedName);
public bool Equals(ISession other) => other != null && SessionId.Equals(other.SessionId);
public static string GetValidateCodeId() { return("validatecode_" + SessionId.GetSessionId()); }
public static SessionAction Stop(SessionId sessionId, SystemName systemName, ProcessName nodeName) => new SessionAction(SessionActionTag.Stop, 0L, sessionId, systemName.Value, nodeName.Value, 0, null, null, null);
public Save() { _validSessionId = new SessionId(Guid.NewGuid(), true); _context = new NancyContext {Request = new Request("GET", "http://www.google.be")}; }
public static SessionAction Start(SessionId sessionId, int timeoutSeconds, SystemName systemName, ProcessName nodeName) => new SessionAction(SessionActionTag.Start, 0L, sessionId, systemName.Value, nodeName.Value, timeoutSeconds, null, null, null);
public void Given_session_id_is_not_new_then_does_nothing() { var existingSessionId = new SessionId(Guid.NewGuid(), false); _byQueryStringParamIdentificationMethod.SaveSessionId(existingSessionId, _context); A.CallTo(() => _fakeResponseManipulatorForSession.ModifyResponseToRedirectToSessionAwareUrl(A<NancyContext>._, A<SessionIdentificationData>._, A<string>._)).MustNotHaveHappened(); }
public static SessionAction ClearData(long time, SessionId sessionId, string key, SystemName systemName, ProcessName nodeName) => new SessionAction(SessionActionTag.ClearData, time, sessionId, systemName.Value, nodeName.Value, 0, key, null, null);
/// <summary> /// Receives content sent from a session via a topic. /// </summary> /// <param name="sessionId">Identifies the client session that sent the content.</param> /// <param name="topicPath">The path of the topic that the content was sent on.</param> /// <param name="content">The content sent by the client.</param> /// <param name="context">The context associated with the content.</param> public override void OnMessage( SessionId sessionId, string topicPath, IContent content, IReceiveContext context ) { theMessagingControl.Send( sessionId, topicPath, content, theMessagingControl.CreateSendOptionsBuilder().SetHeaders( context.HeadersList.ToList() ).Build(), theSendCallback ); }
public static SessionAction SetData(long time, SessionId sessionId, string key, string data, SystemName systemName, ProcessName nodeName) => new SessionAction(SessionActionTag.SetData, time, sessionId, systemName.Value, nodeName.Value, 0, key, data, data.GetType().AssemblyQualifiedName);
public void Constructor_fills_properties() { var value = Guid.NewGuid(); var emptySessionId = new SessionId(value, true); Assert.Equal(emptySessionId.Value, value); Assert.Equal(emptySessionId.IsNew, true); }
/// <summary> /// Subscribe a client to topics. /// </summary> /// <param name="sessionId">The session id of the client to subscribe.</param> /// <param name="topicSelector">The topic selector expression.</param> /// <param name="callback">The callback for the subscription result.</param> public void Subscribe(SessionId sessionId, string topicSelector, ISubscriptionCallback callback) { // To subscribe a client to a topic, this client session must have the MODIFY_SESSION permission. subscriptionControl.Subscribe(sessionId, topicSelector, callback); }
public async IAsyncEnumerable <SourceFile> Load(SessionId sessionId, string [] loaded_files, [EnumeratorCancellation] CancellationToken token) {
/// <summary> /// Unsubscribe a client from topics. /// </summary> /// <param name="sessionId">The session id of the client to unsubscribe.</param> /// <param name="topicSelector">The topic selector expression.</param> /// <param name="callback">The callback for the unsubscription result.</param> public void Unsubscribe(SessionId sessionId, string topicSelector, ISubscriptionCallback callback) { subscriptionControl.Unsubscribe(sessionId, topicSelector, callback); }
public void Given_empty_value_then_isempty_returns_true() { var emptySessionId = new SessionId(Guid.Empty, false); Assert.True(emptySessionId.IsEmpty); }
/// <summary> /// Adds claims based on the UserData data /// </summary> private void AddUserDataClaims() { //This is the id that 'identity' uses to check for the user id if (HasClaim(x => x.Type == ClaimTypes.NameIdentifier) == false) { AddClaim(new Claim(ClaimTypes.NameIdentifier, UserData.Id.ToString(), ClaimValueTypes.Integer32, Issuer, Issuer, this)); } if (HasClaim(x => x.Type == ClaimTypes.Name) == false) { AddClaim(new Claim(ClaimTypes.Name, UserData.Username, ClaimValueTypes.String, Issuer, Issuer, this)); } if (HasClaim(x => x.Type == ClaimTypes.GivenName) == false) { AddClaim(new Claim(ClaimTypes.GivenName, UserData.RealName, ClaimValueTypes.String, Issuer, Issuer, this)); } if (HasClaim(x => x.Type == Constants.Security.StartContentNodeIdClaimType) == false) { AddClaim(new Claim(Constants.Security.StartContentNodeIdClaimType, JsonConvert.SerializeObject(StartContentNodes), ClaimValueTypes.Integer32, Issuer, Issuer, this)); } if (HasClaim(x => x.Type == Constants.Security.StartMediaNodeIdClaimType) == false) { AddClaim(new Claim(Constants.Security.StartMediaNodeIdClaimType, JsonConvert.SerializeObject(StartMediaNodes), ClaimValueTypes.Integer32, Issuer, Issuer, this)); } if (HasClaim(x => x.Type == ClaimTypes.Locality) == false) { AddClaim(new Claim(ClaimTypes.Locality, Culture, ClaimValueTypes.String, Issuer, Issuer, this)); } if (HasClaim(x => x.Type == Constants.Security.SessionIdClaimType) == false && SessionId.IsNullOrWhiteSpace() == false) { AddClaim(new Claim(Constants.Security.SessionIdClaimType, SessionId, ClaimValueTypes.String, Issuer, Issuer, this)); } //The security stamp claim is also required... this is because this claim type is hard coded // by the SecurityStampValidator, see: https://katanaproject.codeplex.com/workitem/444 if (HasClaim(x => x.Type == Microsoft.AspNet.Identity.Constants.DefaultSecurityStampClaimType) == false) { AddClaim(new Claim(Microsoft.AspNet.Identity.Constants.DefaultSecurityStampClaimType, SecurityStamp, ClaimValueTypes.String, Issuer, Issuer, this)); } //Add each app as a separate claim if (HasClaim(x => x.Type == Constants.Security.AllowedApplicationsClaimType) == false) { foreach (var application in AllowedApplications) { AddClaim(new Claim(Constants.Security.AllowedApplicationsClaimType, application, ClaimValueTypes.String, Issuer, Issuer, this)); } } //Claims are added by the ClaimsIdentityFactory because our UserStore supports roles, however this identity might // not be made with that factory if it was created with a FormsAuthentication ticket so perform the check if (HasClaim(x => x.Type == DefaultRoleClaimType) == false) { //manually add them based on the UserData foreach (var roleName in UserData.Roles) { AddClaim(new Claim(RoleClaimType, roleName, ClaimValueTypes.String, Issuer, Issuer, this)); } } }
public void When_disposed_then_cannot_access_Get() { var idToFind = new SessionId(Guid.NewGuid(), false); _inProcSessionCache.Dispose(); Assert.Throws<ObjectDisposedException>(() => _inProcSessionCache.Get(idToFind)); }
/// <summary> /// Initializes a new instance of the <see cref="WebDriverCommandHandler"/> class. /// </summary> /// <param name="locatorParameters">A <see cref="Dictionary{K, V}"/> containing the parameters used to match a resource in the URL.</param> /// <param name="parameters">A <see cref="Dictionary{K, V}"/> containing the parameters used to operate on the resource.</param> protected WebDriverCommandHandler(Dictionary <string, string> locatorParameters, Dictionary <string, object> parameters) : base(locatorParameters, parameters) { if (!locatorParameters.ContainsKey(CommandHandler.SessionIdParameterName)) { throw new InvalidCommandException("Command requires a session ID"); } string sessionIdValue = locatorParameters[CommandHandler.SessionIdParameterName]; this.SessionId = new SessionId(sessionIdValue); this.currentSession = SessionManager.Instance.GetSession(this.SessionId); if (this.currentSession == null) { throw new ResourceNotFoundException("Could not find active session with id '" + SessionId.ToString() + "'"); } }
public virtual bool Equals(SessionId that) { if(!Equals(this.ConnectionId, that.ConnectionId)) { return false; } if(!Equals(this.Value, that.Value)) { return false; } return true; }
public RemoveBasketItem(SessionId sessionId, ProductId productId) { SessionId = sessionId; ProductId = productId; }
public static SessionAction Stop(SessionId sessionId, SystemName systemName, ProcessName nodeName) => new SessionAction(SessionActionTag.Stop, 0L, sessionId, systemName.Value, nodeName.Value, 0, null, null, null);
public override int GetHashCode() { return(SessionId.GetHashCode() + PlayerId.GetHashCode()); }
public static SessionAction ClearData(long time, SessionId sessionId, string key, SystemName systemName, ProcessName nodeName) => new SessionAction(SessionActionTag.ClearData, time, sessionId, systemName.Value, nodeName.Value, 0, key, null, null);
public async Task CheckThat_SchedulingApprovedSession_IsSuccessAndSessionIsScheduled() { var existingSession = new Session(SessionId.New(), Array.Empty <PersonId>(), "title", "description", Array.Empty <string>(), default, SessionStatus.Approved);
public void Logout() { Debug.Assert(_originalPrincipal == null, "Context has to be detached from thread"); _sessionId = SessionId.Empty; IsAuthenticated = false; _dbOperations.Dispose(); _dbOperations = null; _originalPrincipal = null; _currentUser = null; _rights = null; }
protected bool Equals(RelaySource other) { return(string.Equals(Name, other.Name) && SourceType == other.SourceType && SessionId.Equals(other.SessionId)); }
/// <summary> /// Receives content sent from a session via a topic. /// </summary> /// <param name="sessionId">Identifies the client session that sent the content.</param> /// <param name="topicPath">The path of the topic that the content was sent on.</param> /// <param name="content">The content sent by the client.</param> /// <param name="context">The context associated with the content.</param> public virtual void OnMessage(SessionId sessionId, string topicPath, IContent content, IReceiveContext context) { }
public ServerCommandExecutor(Uri serverUri, SessionId sessionId, int commandExecutionTimeoutInSeconds = 10) { this.serverUri = serverUri; this.sessionId = sessionId; timeoutInSeconds = commandExecutionTimeoutInSeconds; }