protected override void OnInit(EventArgs e) { base.OnInit(e); if (DaemonHttpContext.LoggedInParticipant == null) { RelyingPartyLogic.User user = Database.LoggedInUser; if (user != null) { foreach (AuthenticationToken token in from t in Database.DataContext.AuthenticationTokens where t.User.UserId == user.UserId select t) { if (token.ClaimedIdentifier != null) { Participant participant = ParticipantLogic.AttachParticipantProfileToOpenIdIdentity(user.UserId, token.ClaimedIdentifier); DaemonHttpContext.LoggedInParticipant = participant; } } } } if (DaemonHttpContext.LoggedInParticipant != null) { Participant participant = DaemonHttpContext.LoggedInParticipant; ParticipantLogic.GetLoginSecret(participant); Page.Items["goto"] = Request["goto"]; Page.Items["participantIdentifier"] = participant.ParticipantId.ToString("N"); Page.Items["loginSecret"] = participant.LoginSecret; } Response.Cache.SetCacheability(HttpCacheability.NoCache); }
protected void Page_Load(object sender, EventArgs e) { if (DaemonHttpContext.LoggedInParticipant == null) { User user = Database.LoggedInUser; if (user != null) { foreach (AuthenticationToken token in from t in Database.DataContext.AuthenticationTokens where t.User.UserId == user.UserId select t) { if (token.ClaimedIdentifier != null) { Participant participant = ParticipantLogic.AttachParticipantProfileToOpenIdIdentity(user.UserId, token.ClaimedIdentifier); DaemonHttpContext.LoggedInParticipant = participant; } } } } }
private bool OnParticipantConnectAuthorize(Session session, JoinRequestMessage message, out Guid participantId, out Guid avatarId) { try { string idString = message.ParticipantIdentifier; idString = idString.Insert(8, "-"); idString = idString.Insert(13, "-"); idString = idString.Insert(18, "-"); idString = idString.Insert(23, "-"); participantId = new Guid(idString); avatarId = message.AvatarId; } catch (Exception) { LogUtil.Warn("Participant login id was not guid (without dashes): " + message.ParticipantIdentifier); participantId = Guid.Empty; avatarId = Guid.Empty; return(false); } foreach (CloudBubble bubble in service.Bubbles) { if (message.BubbleId == bubble.BubbleId && bubble.GetParticipant(participantId) != null) { LogUtil.Warn("Participant already connected " + participantId + "."); return(false); } } foreach (DaemonParticipant daemonParticipant in bubbleDaemons.Values) { if (message.ParticipantIdentifier.Equals(daemonParticipant.DaemonIdentifier) && message.ParticipantSecret.Equals(daemonParticipant.DaemonSecret)) { LogUtil.Info("Login secret match for daemon participant " + participantId + "."); return(true); } } Participant participant = ParticipantLogic.GetParticipant(participantId); if (participant.LoginSecret == null) { LogUtil.Warn("No login secret defined for participant " + participantId + " in database."); return(false); } if (DateTime.Now > participant.LoginSecretExpires) { LogUtil.Warn("Login secret expired for participant " + participantId + " in database."); return(false); } if (participant.LoginSecret.Equals(message.ParticipantSecret)) { LogUtil.Info("Login secret match for participant " + participantId + "."); ParticipantLogic.ClearLoginSecret(participant); return(true); } else { LogUtil.Warn("Login secret mismatch for participant " + participantId + "."); return(false); } }