private AuthenticationEvent Map(LoggedEvent loggedEvent)
        {
            var authenticationEvent = new AuthenticationEvent();
            var whatHappened        = (EventAction)Enum.Parse(typeof(EventAction), loggedEvent.Action);

            switch (whatHappened)
            {
            case EventAction.UserRegistered:
                authenticationEvent = JsonConvert.DeserializeObject <UserRegisteredEvent>(loggedEvent.Data);
                break;

            case EventAction.EmailUniqueValidationFailed:
                authenticationEvent = JsonConvert.DeserializeObject <EmailUniqueValidationFailedEvent>(loggedEvent.Data);
                break;

            case EventAction.EmailVerified:
                authenticationEvent = JsonConvert.DeserializeObject <EmailVerifiedEvent>(loggedEvent.Data);
                break;

            case EventAction.EmailChangeRequested:
                authenticationEvent = JsonConvert.DeserializeObject <EmailChangeRequestedEvent>(loggedEvent.Data);
                break;
            }

            return(authenticationEvent);
        }
示例#2
0
        async Task <HandlerReply> IRequestHandler <BindRequest> .Handle(ClientContext context, LdapEvents eventListener, BindRequest operation)
        {
            Dictionary <string, List <string> > rdn = RdnParser.ParseRdnString(operation.Name);
            AuthenticationEvent authEvent           = new AuthenticationEvent(rdn, operation.Authentication);
            bool success = await eventListener.OnAuthenticationRequest(context, authEvent);

            if (success)
            {
                context.IsAuthenticated = true;
                context.Rdn             = rdn;

                LdapResult   ldapResult   = new LdapResult(LdapResult.ResultCodeEnum.Success, null, null);
                BindResponse bindResponse = new BindResponse(ldapResult);
                return(new HandlerReply(new List <IProtocolOp> {
                    bindResponse
                }));
            }
            else
            {
                context.IsAuthenticated = false;
                context.Rdn             = new Dictionary <string, List <string> >();

                LdapResult   ldapResult   = new LdapResult(LdapResult.ResultCodeEnum.InappropriateAuthentication, null, null);
                BindResponse bindResponse = new BindResponse(ldapResult);
                return(new HandlerReply(new List <IProtocolOp> {
                    bindResponse
                }));
            }
        }
        public void Store(AuthenticationEvent authenticationEvent)
        {
            authenticationEvent.TimeStamp = DateTime.Now;

            var loggedEvent = new LoggedEvent()
            {
                Action      = authenticationEvent.EventAction,
                AggregateId = authenticationEvent.UserId,
                Data        = Newtonsoft.Json.JsonConvert.SerializeObject(authenticationEvent),
                TimeStamp   = authenticationEvent.TimeStamp
            };

            _eventDb.Save(loggedEvent);
        }
示例#4
0
 /// <summary>
 /// someone (probably the UserStoreWrapper) provides authentication info, most
 /// likely after refreshing the autentication token.
 /// </summary>
 private void authenticationHandler(AuthenticationEvent eventInfo)
 {
     this.authToken = eventInfo.AuthenticationResult.AuthenticationToken;
 }
示例#5
0
 /// <summary>
 /// (probably) UserStoreWrapper sends Authentication info to interested parties like ourselves.
 /// </summary>
 private void authenticationEventHandler(AuthenticationEvent eventInfo)
 {
     this.AuthenticationToken = eventInfo.AuthenticationResult.AuthenticationToken;
     this.ShardId             = eventInfo.AuthenticationResult.User.ShardId;
 }