/// <summary> /// Initializes a new instance of the <see cref="SessionValidatorService" /> class. /// </summary> /// <param name="config">The configuration.</param> /// <param name="traceManager">The trace manager.</param> /// <param name="sessionStateProvider">The session state provider.</param> public SessionValidatorService(SessionValidatorConfiguration config, ITraceManager traceManager, ISessionStateProvider sessionStateProvider) { TimeProvider = SystemTime.Current; _traceManager = traceManager; _sessionStateProvider = sessionStateProvider; _config = config; }
public DbUtils.Core.Api.IDbServerConnection[] RestoreSessions(SqliteConnection connection) { InitializeStateDb(connection); IList <IDbServerConnection> sessions = new List <IDbServerConnection> (); using (SqliteCommand cmd = connection.CreateCommand()) { cmd.CommandText = "select * from dbstate"; using (SqliteDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { string providerName = reader.GetString(reader.GetOrdinal("provider")); string state = reader.GetString(reader.GetOrdinal("state")); try { Type providerType = Type.GetType(providerName); ISessionStateProvider sessionProvider = (ISessionStateProvider)providerType.GetConstructor(new Type[] {}).Invoke(new object[] {}); IDbServerConnection session = sessionProvider.restoreSessionFromState(state); sessions.Add(session); } catch (Exception e) { // todo, log error and continue throw e; } } } } return(sessions.ToArray()); }
/// <summary> /// When overridden, provides an entry point for custom authorization checks. /// </summary> /// <param name="httpContext">The HTTP context, which encapsulates all HTTP-specific information about an individual HTTP request.</param> /// <returns> /// true if the user is authorized; otherwise, false. /// </returns> /// <exception cref="System.ArgumentNullException">httpContext</exception> protected override bool AuthorizeCore(HttpContextBase httpContext) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } var isGranted = false; sessionStateProvider = new SessionStateProvider(); session = new SessionStateService(sessionStateProvider); var theRolesAsStored = session.GetSessionValue(SessionKey.UserRoles); var roleCollection = theRolesAsStored != null ? ((string[])theRolesAsStored).ToList() : new List <string>(); var roleCollectionToUpper = roleCollection.Select(role => role.ToUpper()).ToList(); var userId = (session.GetSessionValue(SessionKey.UserId) ?? "").ToString().AsInt(); if (userId < 1) { return(false); } foreach (var role in this.Roles) { isGranted = roleCollectionToUpper.Contains(role.ToUpper()); if (isGranted) { break; } } return(isGranted); }
public SessionStateBasedAlarmManager(ISessionStateProvider sessionInformation) { if (sessionInformation == null) throw new ArgumentNullException("sessionInformation"); this.sessionStateProvider = sessionInformation; this.sessionStateProvider.SessionLocked += sessionInformation_SessionDeactivated; this.sessionStateProvider.SessionUnlocked += sessionInformation_SessionActivated; this.sessionStateProvider.SessionActivated += sessionInformation_SessionActivated; this.sessionStateProvider.SessionDeactivated += sessionInformation_SessionDeactivated; }
protected void Page_Load(object sender, EventArgs e) { session = IoC.Resolve<ISessionStateProvider>(); this.UserInformation = UserInformation.Current; // Only generate this in Test environments... if (ShowExceptionDetails) RegisterFullExceptionScripts(); SetErrorMessage(); }
public SessionStateBasedAlarmManager(ISessionStateProvider sessionInformation) { if (sessionInformation == null) { throw new ArgumentNullException("sessionInformation"); } this.sessionStateProvider = sessionInformation; this.sessionStateProvider.SessionLocked += sessionInformation_SessionDeactivated; this.sessionStateProvider.SessionUnlocked += sessionInformation_SessionActivated; this.sessionStateProvider.SessionActivated += sessionInformation_SessionActivated; this.sessionStateProvider.SessionDeactivated += sessionInformation_SessionDeactivated; }
/// <summary> /// When overridden, provides an entry point for custom authorization checks. /// </summary> /// <param name="httpContext">The HTTP context, which encapsulates all HTTP-specific information about an individual HTTP request.</param> /// <returns> /// true if the user is authorized; otherwise, false. /// </returns> /// <exception cref="System.ArgumentNullException">httpContext</exception> protected override bool AuthorizeCore(HttpContextBase httpContext) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } var isGranted = false; sessionStateProvider = new SessionStateProvider(); session = new SessionStateService(sessionStateProvider); accountRepository = new AccountRepository(); var userId = (session.GetSessionValue(SessionKey.UserId) ?? "").ToString().ToString(); if (string.IsNullOrEmpty(userId)) { return(false); } var theRolesAsStored = session.GetSessionValue(SessionKey.UserRoles); var roleCollection = theRolesAsStored != null ? ((string[])theRolesAsStored).ToList() : new List <string>(); var roleCollectionToUpper = roleCollection.Select(role => role.ToUpper()).ToList(); foreach (var role in Roles) { isGranted = roleCollectionToUpper.Contains(role.ToUpper()); if (isGranted) { var theAction = role.ToUpper(); accountRepository.LogUserAction(userId, theAction, true); break; } } if (isGranted) { return(true); } //log all action when action is not granted foreach (var role in Roles) { accountRepository.LogUserAction(userId, role, false); } return(false); }
/// <summary> /// When overridden, provides an entry point for custom authorization checks. /// </summary> /// <param name="httpContext">The HTTP context, which encapsulates all HTTP-specific information about an individual HTTP request.</param> /// <returns> /// true if the user is authorized; otherwise, false. /// </returns> /// <exception cref="System.ArgumentNullException">httpContext</exception> protected override bool AuthorizeCore(HttpContextBase httpContext) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } sessionStateProvider = new SessionStateProvider(); session = new SessionStateService(sessionStateProvider); var userId = (session.GetSessionValue(SessionKey.UserId) ?? "").ToString().AsInt(); if (userId < 1) { return(false); } return(true); }
/// <summary> /// Determines whether the node is visible. /// </summary> /// <param name="node">The node.</param> /// <param name="sourceMetadata">The source metadata.</param> /// <returns> /// <c>true</c> if the specified node is visible; otherwise, <c>false</c>. /// </returns> /// <exception cref="System.ArgumentNullException">node</exception> public bool IsVisible(ISiteMapNode node, IDictionary <string, object> sourceMetadata) { if (node == null) { throw new ArgumentNullException("node"); } sessionStateProvider = new SessionStateProvider(); session = new SessionStateService(sessionStateProvider); //TODO: Uncomment below before deployment to prod. var isUserLoggedIn = (session.GetSessionValue(SessionKey.UserIsAuthenticated) ?? "").ToString().AsBoolean(); if (!isUserLoggedIn && (node.Title != "Home")) { return(false); } IRoleCollection roles = node.Roles; //if no role is associated to node - allow it to show if (!roles.Any()) { return(true); } var roleCollection = ((string[])session.GetSessionValue(SessionKey.UserRoles) ?? new[] { "" }).ToList(); var roleCollectionToUpper = roleCollection.Select(role => role.ToUpper()).ToList(); var isGranted = false; foreach (var role in roles) { isGranted = roleCollectionToUpper.Contains(role.ToUpper()); if (isGranted) { break; } } return(isGranted); }
/// <summary> /// Initializes a new instance of the <see cref="TopicBroker" /> class. /// </summary> /// <param name="traceManager">The trace manager to use for tracing. Should contain a trace /// source named SignalR.MagicHub</param> /// <param name="messageHub">The message hub.</param> /// <param name="sessionValidatorService">The session validator service.</param> /// <param name="sessionStateProvider">The session state provider.</param> /// <param name="sessionMappingStore">The session mapping store.</param> /// <param name="hubReleaser">Optional. The hub releaser. Can release hub instance from an IoC store.</param> public TopicBroker( ITraceManager traceManager, IMessageHub messageHub, ISessionValidatorService sessionValidatorService, ISessionStateProvider sessionStateProvider, ISessionMappings sessionMappingStore, IHubReleaser hubReleaser) { AssertNotNull(traceManager, "traceManager"); AssertNotNull(messageHub, "messageHub"); AssertNotNull(sessionValidatorService, "sessionValidatorService"); AssertNotNull(messageHub, "sessionStateProvider"); AssertNotNull(messageHub, "sessionMappingStore"); _traceManager = traceManager; _messageHub = messageHub; _sessionValidatorService = sessionValidatorService; _sessionStateProvider = sessionStateProvider; _sessionToConnectionId = sessionMappingStore; // This is optional _hubReleaser = hubReleaser; }
protected void Page_Load(object sender, EventArgs e) { session = IoC.Resolve<ISessionStateProvider>(); this.UserInformation = UserInformation.Current; }
public SessionState(ISessionStateProvider sessionProvider) { _sessionProvider = sessionProvider; }
protected RemoteSessionBase(ISessionStateProvider sessionProvider) { _session = new SessionState(sessionProvider); }
public SessionStudentListController(ISessionStateProvider session, IUniqueListIdProvider uniqueListProvider) { this.session = session; this.uniqueListProvider = uniqueListProvider; }
public CurrentUserClaimInterrogator(ISessionStateProvider sessionStateProvider) { this.sessionStateProvider = sessionStateProvider; }
protected override void EstablishContext() { windsorContainer = new WindsorContainer(); authorizationInformationProvider = mocks.StrictMock<IAuthorizationInformationProvider>(); sessionStateProvider = mocks.StrictMock<ISessionStateProvider>(); currentUserClaimInterrogator = mocks.StrictMock<ICurrentUserClaimInterrogator>(); currentUserAccessibleStudentsProvider = mocks.StrictMock<ICurrentUserAccessibleStudentsProvider>(); RegisterServices(windsorContainer); var userAssociatedOrgs = UserInformation.Current.AssociatedSchools; foreach(var associatedOrg in userAssociatedOrgs) { foreach(var claimType in associatedOrg.ClaimTypes) { Expect.Call(currentUserClaimInterrogator.HasClaimWithinEducationOrganizationHierarchy(claimType,associatedOrg.EducationOrganizationId )).Repeat.Any().Return(true); } } var userAssociatedLeaOrgs = UserInformation.Current.AssociatedLocalEducationAgencies; foreach (var associatedOrg in userAssociatedLeaOrgs) { foreach (var claimType in associatedOrg.ClaimTypes) { Expect.Call(currentUserClaimInterrogator.HasClaimWithinEducationOrganizationHierarchy(claimType, associatedOrg.EducationOrganizationId )).Repeat.Any().Return(true); } } Expect.Call(currentUserClaimInterrogator.HasClaimForStateAgency(string.Empty)).Repeat.Any().Return(false).IgnoreArguments(); CreateEdFiDashboardContext(LoginHelper.localEducationAgencyOneId); if (registerAccessibleStudentsInBase) Expect.Call(currentUserAccessibleStudentsProvider.GetAccessibleStudents(1, false)).IgnoreArguments().Repeat. Any().Return(new AccessibleStudents { CanAccessAllStudents = false, StudentUSIs = GetAllStaffStudents() }); //Expect.Call(authorizationInformationProvider.GetAllStaffStudentUSIs(providedStaffUSI)).Repeat.Any().Return(GetAllStaffStudents()); //Expect.Call(authorizationInformationProvider.GetPrincipalStudentUSIs(providedStaffUSI)).Repeat.Any().Return(GetPrincipalStudents()); //Expect.Call(authorizationInformationProvider.GetStaffCohortStudentUSIs(providedStaffUSI)).Repeat.Any().Return(GetCohortStudents()); //Expect.Call(authorizationInformationProvider.GetTeacherStudentUSIs(providedStaffUSI)).Repeat.Any().Return(GetTeacherStudents()); base.EstablishContext(); }
public EntryController(ISessionStateProvider sessionStateProvider, IEntryService entryService) { this.sessionStateProvider = sessionStateProvider; this.entryService = entryService; }
public PhotoManagementController(IPhotoManagementService photoManagementService, ISessionStateProvider sessionStateProvider) { this.photoManagementService = photoManagementService; this.sessionStateProvider = sessionStateProvider; }
public SessionBaseProvider(ISessionStateProvider sessionObject) { CSession = sessionObject; }
public PreviousNextController(ISessionStateProvider sessionStateProvider, IRouteValuesPreparer routeValuesPreparer, IRequestUrlBaseProvider requestUrlBaseProvider) { this.sessionStateProvider = sessionStateProvider; this.routeValuesPreparer = routeValuesPreparer; this.requestUrlBaseProvider = requestUrlBaseProvider; }
public PreviousNextSessionProvider(ISessionStateProvider sessionStateProvider, IUniqueListIdProvider uniqueListProvider) { this.sessionStateProvider = sessionStateProvider; this.uniqueListProvider = uniqueListProvider; }
public EdFiSecurityTokenCache(ISessionStateProvider sessionStateProvider) { this.sessionStateProvider = sessionStateProvider; }
public AppSession(ISessionStateProvider sessionObject) : base(sessionObject) { }