Ejemplo n.º 1
0
 public UserController(ILandlordService landlordService, ISessionDetails session, ISessionHelper sessionHelper, IHttpContextHelper httpContextHelper)
 {
     _session = session;
     _sessionHelper = sessionHelper;
     _httpContextHelper = httpContextHelper;
     _landlordService = landlordService;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Request authentication.
        ///
        /// The server calls this to authenticate new sessions, and when a client requests the session principal is
        /// changed.
        ///
        /// For each call to Authenticate, the authentication handler should respond by calling one of the methods of
        /// the provided callback.  The handler may return immediately and process the authentication request
        /// asynchronously.  The client session will be blocked until a callback method is called.
        /// </summary>
        /// <param name="principal"></param>
        /// <param name="credentials"></param>
        /// <param name="sessionDetails"></param>
        /// <param name="callback"></param>
        public void Authenticate(
            string principal,
            ICredentials credentials,
            ISessionDetails sessionDetails,
            IAuthenticationHandlerCallback callback)
        {
            if (credentials.Type == CredentialsType.PLAIN_PASSWORD)
            {
                if (AuthUser.Equals(principal))
                {
                    if (AuthPassword.Equals(System.Text.Encoding.UTF8.GetString(credentials.ToBytes())))
                    {
                        callback.Allow();

                        return;
                    }

                    callback.Deny();

                    return;
                }
            }

            callback.Abstain();
        }
Ejemplo n.º 3
0
 public UserController(ITenantService tenantService, ISessionDetails session, ISessionHelper sessionHelper, IHttpContextHelper httpContextHelper)
 {
     _session = session;
     _sessionHelper = sessionHelper;
     _httpContextHelper = httpContextHelper;
     _tenantService = tenantService;
 }
 public static ISpecification <TherapySession> ByDetails(ISessionDetails details)
 {
     // get latest by date always
     return(new TherapySessionSpecification(HasDetails(details))
            .Where(therapySession =>
                   therapySession.DateTime == details.DateTime &&
                   therapySession.Status == TherapySessionStatus.Default));
 }
        /// <summary>
        /// Request authentication.
        ///
        /// The server calls this to authenticate new sessions, and when a client requests the session principal is
        /// changed.
        ///
        /// For each call to Authenticate, the authentication handler should respond by calling one of the methods of
        /// the provided callback. The handler may return immediately and process the authentication request
        /// asynchronously. The client session will be blocked until a callback method is called.
        /// </summary>
        /// <param name="principal"></param>
        /// <param name="credentials"></param>
        /// <param name="sessionDetails"></param>
        /// <param name="callback"></param>
        public void Authenticate( string principal, ICredentials credentials, ISessionDetails sessionDetails,
            IAuthenticationHandlerCallback callback )
        {
            var output = string.Format( "ExampleControlAuthenticationHandler asked to authenticate: Principal {0}," +
                "Credentials {1} -> {2}, SessionDetails {3}: ", principal, credentials,
                System.Text.Encoding.UTF8.GetString( credentials.ToBytes() ), sessionDetails );

            Console.WriteLine( output );

            callback.Abstain();
        }
        /// <summary>
        /// Request authentication.
        ///
        /// The server calls this to authenticate new sessions, and when a client requests the session principal is
        /// changed.
        ///
        /// For each call to Authenticate, the authentication handler should respond by calling one of the methods of
        /// the provided callback. The handler may return immediately and process the authentication request
        /// asynchronously. The client session will be blocked until a callback method is called.
        /// </summary>
        /// <param name="principal"></param>
        /// <param name="credentials"></param>
        /// <param name="sessionDetails"></param>
        /// <param name="callback"></param>
        public void Authenticate(string principal, ICredentials credentials, ISessionDetails sessionDetails,
                                 IAuthenticationHandlerCallback callback)
        {
            var output = string.Format("ExampleControlAuthenticationHandler asked to authenticate: Principal {0}," +
                                       "Credentials {1} -> {2}, SessionDetails {3}: ", principal, credentials,
                                       System.Text.Encoding.UTF8.GetString(credentials.ToBytes()), sessionDetails);

            Console.WriteLine(output);

            callback.Abstain();
        }
Ejemplo n.º 7
0
        public static ISpecification <TimeSlot> ByDetails(ISessionDetails details)
        {
            Check.NotNull(details, nameof(details));
            var dateTime = details.DateTime;

            return(new TimeSlotSpecification(HasDetails(details))
                   .Where(timeSlot =>
                          timeSlot.Items.Any(item =>
                                             item.TimeOfDay == dateTime.TimeOfDay &&
                                             item.DayOfWeek == dateTime.DayOfWeek))
                   .Where(WithinDateRange(dateTime, dateTime)));
        }
Ejemplo n.º 8
0
        public static ISpecification <TimeSlot> ByDetailsOrderByDateDesc(ISessionDetails details)
        {
            Check.NotNull(details, nameof(details));
            var dateTime = details.DateTime;

            return(new TimeSlotSpecification(HasDetails(details))
                   .Where(timeSlot =>
                          timeSlot.Items.Any(item =>
                                             item.TimeOfDay == dateTime.TimeOfDay &&
                                             item.DayOfWeek == dateTime.DayOfWeek))
                   .Where(WithinDateRange(dateTime, dateTime))
                   .AddSorting(timeSlot => timeSlot.CreationDate, SortDirection.Descending));
        }
        public async Task <IHaveSessionDetails> GetSessionDetails(ISessionDetails details)
        {
            var sessionSpecification = TherapySessionSpecification.ByDetailsOrderDesc(details);
            var therapySession       = await _therapySessionRepository.GetFirstOrDefaultAsync(sessionSpecification);

            if (therapySession != null)
            {
                return(therapySession);
            }
            var timeSlotSpecification = TimeSlotSpecification.ByDetailsOrderByDateDesc(details);
            var timeSlot = await _timeSlotRepository.GetFirstOrDefaultAsync(timeSlotSpecification);

            Check.NotNull(timeSlot, nameof(timeSlot));
            return(timeSlot);
        }
            /// <summary>
            /// Request authentication.
            ///
            /// The server calls this to authenticate new sessions, and when a client requests the session principal is
            /// changed.
            ///
            /// For each call to Authenticate, the authentication handler should respond by calling one of the methods
            /// of the provided callback. The handler may return immediately and process the authentication request
            /// asynchronously. The client session will be blocked until a callback method is called.
            /// </summary>
            /// <param name="principal"></param>
            /// <param name="credentials"></param>
            /// <param name="sessionDetails"></param>
            /// <param name="callback"></param>
            public void Authenticate(string principal, ICredentials credentials, ISessionDetails sessionDetails,
                                     IAuthenticationHandlerCallback callback)
            {
                var passwordBytes = Encoding.UTF8.GetBytes("password");

                if ("admin".Equals(principal) &&
                    credentials.Type == CredentialsType.PLAIN_PASSWORD &&
                    credentials.ToBytes().Equals(passwordBytes))
                {
                    callback.Allow();
                }
                else
                {
                    callback.Deny();
                }
            }
        public async Task <TherapySession> GetOrCreateIfNotExistsAsync(ISessionDetails details)
        {
            var sessionSpecification = TherapySessionSpecification.ByDetailsOrderDesc(details);
            var therapySession       = await _therapySessionRepository.GetSingleOrDefaultAsync(sessionSpecification);

            if (therapySession != null)
            {
                return(therapySession);
            }
            var timeSlotSpecification = TimeSlotSpecification.ByDetailsOrderByDateDesc(details);
            var timeSlot = await _timeSlotRepository.GetFirstOrDefaultAsync(timeSlotSpecification);

            Check.NotNull(timeSlot, nameof(timeSlot));
            therapySession = new TherapySession(details.DateTime, timeSlot);
            _therapySessionRepository.Add(therapySession);
            _logger.LogInformation($"Created therapySession with Id = {therapySession.Id}");
            return(therapySession);
        }
        /// <summary>
        /// Request authentication.
        ///
        /// The server calls this to authenticate new sessions, and when a client requests the session principal is
        /// changed.
        ///
        /// For each call to Authenticate, the authentication handler should respond by calling one of the methods of
        /// the provided callback. The handler may return immediately and process the authentication request
        /// asynchronously. The client session will be blocked until a callback method is called.
        /// </summary>
        /// <param name="principal"></param>
        /// <param name="credentials"></param>
        /// <param name="sessionDetails"></param>
        /// <param name="callback"></param>
        public void Authenticate( string principal, ICredentials credentials, ISessionDetails sessionDetails,
            IAuthenticationHandlerCallback callback )
        {
            if ( credentials.Type == CredentialsType.PLAIN_PASSWORD ) {
                if ( AuthUser.Equals( principal ) ) {
                    if ( AuthPassword.Equals( System.Text.Encoding.UTF8.GetString( credentials.ToBytes() ) ) ) {
                        callback.Allow();

                        return;
                    }

                    callback.Deny();

                    return;
                }
            }

            callback.Abstain();
        }
Ejemplo n.º 13
0
 public LoginFilter(ISessionDetails session)
 {
     _session = session;
 }
 public SetSessionDetailViewDataFilter(ISessionDetails details)
 {
     _details = details;
 }
 public static ISpecification <TherapySession> ByDetailsOrderDesc(ISessionDetails details)
 {
     // to be removed
     return(ByDetails(details)
            .AddSorting(therapySession => therapySession.CreationDate, SortDirection.Descending));
 }
            /// <summary>
            /// Request authentication.
            ///
            /// The server calls this to authenticate new sessions, and when a client requests the session principal is
            /// changed.
            ///
            /// For each call to Authenticate, the authentication handler should respond by calling one of the methods
            /// of the provided callback. The handler may return immediately and process the authentication request
            /// asynchronously. The client session will be blocked until a callback method is called.
            /// </summary>
            /// <param name="principal"></param>
            /// <param name="credentials"></param>
            /// <param name="sessionDetails"></param>
            /// <param name="callback"></param>
            public void Authenticate( string principal, ICredentials credentials, ISessionDetails sessionDetails,
                IAuthenticationHandlerCallback callback )
            {
                var passwordBytes = Encoding.UTF8.GetBytes( "password" );

                if ( "admin".Equals( principal ) &&
                    credentials.Type == CredentialsType.PLAIN_PASSWORD &&
                    credentials.ToBytes().Equals( passwordBytes ) ) {
                    callback.Allow();
                } else {
                    callback.Deny();
                }
            }
Ejemplo n.º 17
0
 public PropertyImageController(ISessionDetails session, ILandlordService landlordService)
 {
     _session = session;
     _landlordService = landlordService;
 }
Ejemplo n.º 18
0
 public PropertyController(ITenantService tenantService, ISessionDetails sessionDetails)
 {
     _tenantService = tenantService;
     _sessionDetails = sessionDetails;
 }
Ejemplo n.º 19
0
 public PropertyController(ILandlordService landlordService, ISessionDetails sessionDetails)
 {
     _landlordService = landlordService;
     _sessionDetails = sessionDetails;
 }
Ejemplo n.º 20
0
 public LoginFilter(ISessionDetails sessionFactory)
 {
     _session = sessionFactory;
 }