public GinkgoAbpSession(IPrincipalAccessor principalAccessor , IMultiTenancyConfig multiTenancy , ITenantResolver tenantResolver , IAmbientScopeProvider <SessionOverride> sessionOverrideScopeProvider) : base(principalAccessor, multiTenancy, tenantResolver, sessionOverrideScopeProvider) { }
/// <summary> /// Constructor for dependency injection. /// </summary> /// <param name="vmControllerFactory">Factory of view model controllers.</param> /// <param name="principalAccessor">Allow to pass the hub principal.</param> /// <param name="hubPipeline">Manages middlewares and view model filters.</param> public DotNetifyHub(IVMControllerFactory vmControllerFactory, IPrincipalAccessor principalAccessor, IHubPipeline hubPipeline) { _vmControllerFactory = vmControllerFactory; _vmControllerFactory.ResponseDelegate = Response_VM; _principalAccessor = principalAccessor; _hubPipeline = hubPipeline; }
/// <summary> /// Constructor for dependency injection. /// </summary> /// <param name="vmControllerFactory">Factory of view model controllers.</param> /// <param name="principalAccessor">Allow to pass the hub principal.</param> public DotNetifyHub(IVMControllerFactory vmControllerFactory, IPrincipalAccessor principalAccessor) { _vmControllerFactory = vmControllerFactory; _vmControllerFactory.ResponseDelegate = Response_VM; _principalAccessor = principalAccessor; }
public TelemetryServiceTest() { _principalAccessor = Mock.Of <IPrincipalAccessor>(); _principalAccessor.Principal = new GenericPrincipal(new GenericIdentity("username"), null); var moduleTable = new Mock <ModuleTable>(); moduleTable .Setup(_ => _.GetModules()) .Returns(new[] { new ShellModule("CMS", null, null) }); _uiUserProviderMock = new Mock <UIUserProvider>(); _uiUserProviderMock.Setup(x => x.GetUser("username")) .Returns(new FakeUser { CreationDate = new DateTime(2010, 1, 1) }); _telemetryOptions = new TelemetryOptions { OptedIn = true }; _licensingOptions = new LicensingOptions { LicenseKey = "LicenseKey" }; _httpResponseMessage = new HttpResponseMessage { Content = new StringContent("{\"key\":true}") }; _telemetryService = new TelemetryService(_telemetryOptions, _licensingOptions, _principalAccessor, moduleTable.Object, new JsonObjectSerializer(), _uiUserProviderMock.Object) { GetRequestAsync = (string url) => Task.FromResult(_httpResponseMessage), }; }
/// <summary> /// Creates a new instance of a DataSource object, and initializes it with the specified configuration options. /// </summary> /// <param name="principalAccessor"></param> /// <param name="mapProfile"></param> DataSource(IPrincipalAccessor principalAccessor, IMapper mapper, ModelProfile profile) { if (principalAccessor == null) { throw new ArgumentNullException(nameof(principalAccessor)); } this.Principal = principalAccessor.Principal; profile.BindDataSource(this); this.Mapper = mapper; //this.Mapper = new MapperConfiguration(config => //{ // mapProfile.BindDataSource(this); // config.AllowNullCollections = true; // config.AddProfile((Profile)mapProfile); //}).CreateMapper(); // TODO: Fix threading issue. // TODO: reflection to auto initialize the services. _helperService = new Lazy <IHelperService>(() => new HelperService(this)); _subscriptionService = new Lazy <ISubscriptionService>(() => new SubscriptionService(this)); _userService = new Lazy <IUserService>(() => new UserService(this)); _accountService = new Lazy <IAccountService>(() => new AccountService(this)); _calendarService = new Lazy <ICalendarService>(() => new CalendarService(this)); _participantService = new Lazy <IParticipantService>(() => new ParticipantService(this)); _eventService = new Lazy <IEventService>(() => new EventService(this)); _activityService = new Lazy <IActivityService>(() => new ActivityService(this)); _openingService = new Lazy <IOpeningService>(() => new OpeningService(this)); _scheduleService = new Lazy <IScheduleService>(() => new ScheduleService(this)); }
/// <summary> /// Creates a dotNetify hub that uses HTTP context for its hub context, and sets the response callback to a local function. /// </summary> /// <param name="vmControllerFactory">Factory of view model controllers.</param> /// <param name="serviceProvider">Allows to provide scoped service provider for the view models.</param> /// <param name="principalAccessor">Allows to pass the hub principal.</param> /// <param name="hubPipeline">Manages middlewares and view model filters.</param> /// <param name="hubResponseFactory">Factory of objects to send responses back to hub clients.</param> /// <param name="callType">Hub call type.</param> /// <param name="vmId">Identifies the view model.</param> /// <param name="data">View model data.</param> /// <returns>Hub instance.</returns> private IDotNetifyHubHandler CreateHubHandler( IVMControllerFactory vmControllerFactory, IHubServiceProvider hubServiceProvider, IPrincipalAccessor principalAccessor, IHubPipeline hubPipeline, IDotNetifyHubResponseManager hubResponseManager, string callType, string vmId, object data = null) { var httpCallerContext = new HttpCallerContext(HttpContext); if (principalAccessor is HubInfoAccessor) { var hubPrincipalAccessor = principalAccessor as HubInfoAccessor; hubPrincipalAccessor.Principal = HttpContext?.User; hubPrincipalAccessor.Context = new DotNetifyHubContext(httpCallerContext, callType, vmId, data, null, hubPrincipalAccessor.Principal); } return(new DotNetifyHubHandler(vmControllerFactory, hubServiceProvider, principalAccessor, hubPipeline, hubResponseManager) { CallerContext = httpCallerContext, OnVMResponse = ResponseVMCallback }); }
public static void SetSession(this IPrincipalAccessor accessor, SessionDto session) { if (accessor?.Principal == null) { return; } var claims = new List <Claim>(); if (session.UserId != null) { claims.AddRange(new[] { new Claim(SpearClaimTypes.UserId, session.UserId?.ToString()), new Claim(SpearClaimTypes.UserName, session.UserName ?? string.Empty), new Claim(SpearClaimTypes.Role, session.Role ?? string.Empty) }); } if (session.TenantId != null) { claims.Add(new Claim(SpearClaimTypes.TenantId, session.TenantId.ToString())); } if (!claims.Any()) { return; } var identity = new ClaimsIdentity(claims); accessor.Principal.AddIdentity(identity); }
public async Task <string> Request_VM( string vmId, [FromQuery] string vmArg, [FromServices] WebApiVMControllerFactory vmControllerFactory, [FromServices] IHubServiceProvider hubServiceProvider, [FromServices] IPrincipalAccessor principalAccessor, [FromServices] IHubPipeline hubPipeline, [FromServices] IDotNetifyHubResponseManager hubResponseManager ) { var hub = CreateHubHandler(vmControllerFactory, hubServiceProvider, principalAccessor, hubPipeline, hubResponseManager, nameof(IDotNetifyHubMethod.Request_VM), vmId, vmArg); try { await hub.RequestVMAsync(vmId, vmArg); _taskCompletionSource.TrySetResult(_responses.LastOrDefault()); _responses.Clear(); } catch (Exception ex) { _taskCompletionSource.TrySetResult(ex.Serialize()); } return(await _taskCompletionSource.Task); }
public ClaimsStoveSession( IAmbientScopeProvider <SessionOverride> sessionOverrideScopeProvider, IPrincipalAccessor principalAccessor) : base(sessionOverrideScopeProvider) { PrincipalAccessor = principalAccessor; }
public AppLayout(IPrincipalAccessor principalAccessor) { var userIdentity = principalAccessor.Principal.Identity as ClaimsIdentity; UserName = userIdentity.Name; UserAvatar = userIdentity.Claims.FirstOrDefault(i => i.Type == ClaimTypes.Uri)?.Value; this.RegisterRoutes("/", new List <RouteTemplate> { new RouteTemplate(nameof(Route.Home)) { UrlPattern = "", ViewUrl = nameof(Route.Dashboard) }, new RouteTemplate(nameof(Route.Dashboard)), new RouteTemplate(nameof(Route.FormPage)) { UrlPattern = $"{nameof(Form)}(/:id)" }, new RouteTemplate(nameof(Route.TablePage)), new RouteTemplate(nameof(Route.MeterList)), new RouteTemplate(nameof(Route.MeterDashboard)) { UrlPattern = $"{nameof(Route.MeterDashboard)}(/:id)" }, }); }
public ClaimsSharePlatformSession( IPrincipalAccessor principalAccessor, IAmbientScopeProvider <SessionOverride> sessionOverrideScopeProvider) : base( sessionOverrideScopeProvider) { PrincipalAccessor = principalAccessor; }
public static void SetValue(this IPrincipalAccessor accessor, string type, string value) { if (accessor.Principal.HasClaim(type, value)) { return; } accessor.Principal.AddIdentity(new ClaimsIdentity(new[] { new Claim(type, value) })); }
/// <summary> /// Constructor for dependency injection. /// </summary> /// <param name="vmControllerFactory">Factory of view model controllers.</param> /// <param name="principalAccessor">Allow to pass the hub principal.</param> /// <param name="middlewareFactories">Middlewares to intercept incoming view model requests and updates.</param> public DotNetifyHub(IVMControllerFactory vmControllerFactory, IPrincipalAccessor principalAccessor, IList <Func <IMiddleware> > middlewareFactories) { _vmControllerFactory = vmControllerFactory; _vmControllerFactory.ResponseDelegate = Response_VM; _principalAccessor = principalAccessor; _middlewareFactories = middlewareFactories; }
/// <summary> /// Constructor for dependency injection. /// </summary> /// <param name="vmControllerFactory">Factory of view model controllers.</param> /// <param name="principalAccessor">Allow to pass the hub principal.</param> /// <param name="hubPipeline">Manages middlewares and view model filters.</param> /// <param name="globalHubContext">Provides access to hubs.</param> public DotNetifyHub(IVMControllerFactory vmControllerFactory, IPrincipalAccessor principalAccessor, IHubPipeline hubPipeline, IHubContext <DotNetifyHub> globalHubContext) { _vmControllerFactory = vmControllerFactory; _vmControllerFactory.ResponseDelegate = Response_VM; _principalAccessor = principalAccessor; _hubPipeline = hubPipeline; _globalHubContext = globalHubContext; }
//protected ITenantResolver TenantResolver { get; } public ClaimsSafSession( IPrincipalAccessor principalAccessor, IOptions <MultiTenancyConfig> multiTenancy ) : base(multiTenancy) { //TenantResolver = tenantResolver; PrincipalAccessor = principalAccessor; }
public SecurePageVM(IPrincipalAccessor principalAccessor) { SecureCaption = $"Only authenticated user \"{principalAccessor.Principal.Identity.Name}\" can see this live clock."; _timer = new Timer(state => { Changed(nameof(SecureData)); PushUpdates(); }, null, 0, 1000); }
public AbpSessionExtens( IPrincipalAccessor principalAccessor, IMultiTenancyConfig multiTenancy, ITenantResolver tenantResolver, IAmbientScopeProvider <SessionOverride> sessionOverrideScopeProvider, ICacheManagerExtens cacheManagerExtens) : base(principalAccessor, multiTenancy, tenantResolver, sessionOverrideScopeProvider) { _cacheManagerExtens = cacheManagerExtens; }
public void TestFixtureSetup() { principalAccessorMock = Substitute.For <IPrincipalAccessor>(); idValidatorMock = Substitute.ForPartsOf <AbstractValidator <IRequestWithUserNameId> >(); requestMock = Substitute.For <IRequestTest>(); nextMock = Substitute.For <RequestHandlerDelegate <int> >(); principalAccessorMock.UserNameId.Returns(userNameId); }
public CustomAbpSession(IRepository <User, long> userRepository, IPrincipalAccessor principalAccessor, IMultiTenancyConfig multiTenancy, ITenantResolver tenantResolver, IAmbientScopeProvider <SessionOverride> sessionOverrideScopeProvider, IAmbientScopeProvider <CustomSessionOverride> customSessionOverrideScopeProvider) : base(principalAccessor, multiTenancy, tenantResolver, sessionOverrideScopeProvider) { _userRepository = userRepository; CustomSessionOverrideScopeProvider = customSessionOverrideScopeProvider; }
public ClaimsAbpSession( IPrincipalAccessor principalAccessor, IMultiTenancyConfig multiTenancy, ITenantResolver tenantResolver, IAmbientScopeProvider <SessionOverride> sessionOverrideScopeProvider) : base( multiTenancy, sessionOverrideScopeProvider) { this.TenantResolver = tenantResolver; this.PrincipalAccessor = principalAccessor; }
public async Task Dispose_VM( string vmId, [FromServices] WebApiVMControllerFactory vmControllerFactory, [FromServices] IHubServiceProvider hubServiceProvider, [FromServices] IPrincipalAccessor principalAccessor, [FromServices] IHubPipeline hubPipeline, [FromServices] IDotNetifyHubResponseManager hubResponseManager ) { var hub = CreateHubHandler(vmControllerFactory, hubServiceProvider, principalAccessor, hubPipeline, hubResponseManager, nameof(IDotNetifyHubMethod.Dispose_VM), vmId); await hub.DisposeVMAsync(vmId); }
//protected ITenantResolver TenantResolver { get; } public ClaimsSession( IPrincipalAccessor principalAccessor, //IMultiTenancyConfig multiTenancy, //ITenantResolver tenantResolver, IAmbientScopeProvider <SessionOverride> sessionOverrideScopeProvider) : base( //multiTenancy, sessionOverrideScopeProvider) { //TenantResolver = tenantResolver; PrincipalAccessor = principalAccessor; }
public SessionService( IAbpSession abpSession, IRepository <User, long> userRepository, IHttpContextAccessor httpContextAccessor, IOptions <AppConfigBoundValues> appSettings, IPrincipalAccessor principalAccessor) { _abpSession = abpSession; _userRepository = userRepository; _httpContextAccessor = httpContextAccessor; _appSettings = appSettings; _principalAccessor = principalAccessor; }
/// <summary> /// Constructor for dependency injection. /// </summary> /// <param name="vmControllerFactory">Factory of view model controllers.</param> /// <param name="serviceProvider">Allows to provide scoped service provider for the view models.</param> /// <param name="principalAccessor">Allows to pass the hub principal.</param> /// <param name="hubPipeline">Manages middlewares and view model filters.</param> /// <param name="globalHubContext">Provides access to hubs.</param> public DotNetifyHub( IVMControllerFactory vmControllerFactory, IHubServiceProvider serviceProvider, IPrincipalAccessor principalAccessor, IHubPipeline hubPipeline, IHubContext <DotNetifyHub> globalHubContext) { _vmControllerFactory = vmControllerFactory; _vmControllerFactory.ResponseDelegate = ResponseVMAsync; _serviceProvider = serviceProvider; _principalAccessor = principalAccessor; _hubPipeline = hubPipeline; _globalHubContext = globalHubContext; }
public AppLayout(IPrincipalAccessor principalAccessor) { var userIdentity = principalAccessor.Principal.Identity as ClaimsIdentity; UserName = userIdentity.Name; UserAvatar = userIdentity.Claims.FirstOrDefault(i => i.Type == ClaimTypes.Uri)?.Value; this.RegisterRoutes("/", new List<RouteTemplate> { new RouteTemplate(nameof(Route.Home)) { UrlPattern = "", ViewUrl = nameof(Route.StartPage) }, new RouteTemplate(nameof(Route.StartPage)), new RouteTemplate(nameof(Route.InterestPage)), }); }
public async Task <string> Request_VM( string vmId, [FromQuery] string vmArg, [FromServices] IVMFactory vmFactory, [FromServices] IHubServiceProvider hubServiceProvider, [FromServices] IVMServiceScopeFactory serviceScopeFactory, [FromServices] IHubPipeline hubPipeline, [FromServices] IPrincipalAccessor principalAccessor ) { var taskCompletionSource = new TaskCompletionSource <string>(TaskCreationOptions.RunContinuationsAsynchronously); Task responseVM(string arg1, string arg2, string arg3) { taskCompletionSource.TrySetResult(arg3); return(Task.CompletedTask); } var vmController = new VMController(responseVM, vmFactory, serviceScopeFactory.CreateScope()) { ResponseVMFilter = CreateRespondingVMFilter(hubPipeline, vmId, vmArg) }; var httpCallerContext = InitializeContext(vmController, hubServiceProvider, principalAccessor); var connectionId = httpCallerContext.ConnectionId; try { var hubContext = new DotNetifyHubContext(httpCallerContext, nameof(Request_VM), vmId, vmArg, BuildHeaders(), httpCallerContext.User); vmController.RequestVMFilter = CreateVMFilter(hubContext, hubPipeline); await hubPipeline.RunMiddlewaresAsync(hubContext, async ctx => { await vmController.OnRequestVMAsync(connectionId, ctx.VMId, ctx.Data); vmController.Dispose(); }); } catch (Exception ex) { var finalEx = await hubPipeline.RunExceptionMiddlewareAsync(httpCallerContext, ex); if (finalEx is OperationCanceledException == false) { taskCompletionSource.TrySetResult(DotNetifyHub.SerializeException(finalEx)); } } return(await taskCompletionSource.Task); }
public ReviewsNotifier(ApprovalOptions options, IContentLoader contentLoader, IPrincipalAccessor principalAccessor, ISubscriptionService subscriptionService, IObjectSerializer objectSerializer, INotifier notifier, ReviewLocationParser reviewLocationParser) { _options = options; _contentLoader = contentLoader; _principalAccessor = principalAccessor; _subscriptionService = subscriptionService; _objectSerializer = objectSerializer; _notifier = notifier; _reviewLocationParser = reviewLocationParser; }
public TelemetryService( TelemetryOptions telemetryOptions, LicensingOptions licensingOptions, IPrincipalAccessor principalAccessor, ModuleTable moduleTable, IObjectSerializer objectSerializer, UIUserProvider uiUserProvider) { _telemetryOptions = telemetryOptions; _licensingOptions = licensingOptions; _principalAccessor = principalAccessor; _moduleTable = moduleTable; _objectSerializer = objectSerializer; _uiUserProvider = uiUserProvider; }
public ApiClient(IPrincipalAccessor principalAccessor, IConfiguration configuration, IOptions <MvcJsonOptions> options) { if (principalAccessor == null) { throw new ArgumentNullException(nameof(principalAccessor)); } this.Settings = options?.Value?.SerializerSettings; _client = new HttpClient(); if (principalAccessor.Principal is ClaimsPrincipal) { var bearer = principalAccessor.Principal?.Claims.FirstOrDefault(c => c.Type == "token"); if (bearer != null) { _client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", bearer?.Value); } } this.Uri = configuration["Api:Uri"]; }
public DefaultDataImporterInterceptor(IDataImporter defaultDataImporter , IContentCacheRemover contentCacheRemover , IPrincipalAccessor principalAccessor , IDataImportEvents dataImportEvents , IDataImportEventsRaiser dataImportEventsRaiser , IContentRepository contentRepository , IPermanentLinkMapper permanentLinkMapper , IContentTypeRepository contentTypeRepository , ContentTypeAvailabilityService contentTypeAvailabilityService , IAvailableSettingsRepository availableSettingsRepository , IContentImporter contentImporter , IContentTransferValidator contentTransferValidator , PropertyCategoryTransform propertyCategoryTransform , ContentRootRepository contentRootRepository , ISiteDefinitionRepository siteDefinitionRepository , ContentOptions contentOptions , ISiteDefinitionResolver siteDefinitionResolver) : base(contentCacheRemover, principalAccessor, dataImportEvents , dataImportEventsRaiser, contentRepository , permanentLinkMapper, contentTypeRepository , contentTypeAvailabilityService, availableSettingsRepository , contentImporter, contentTransferValidator , propertyCategoryTransform, contentRootRepository , siteDefinitionRepository, contentOptions, siteDefinitionResolver) { this.defaultDataImporter = defaultDataImporter; this.contentCacheRemover = contentCacheRemover; this.principalAccessor = principalAccessor; this.dataImportEvents = dataImportEvents; this.dataImportEventsRaiser = dataImportEventsRaiser; this.contentRepository = contentRepository; this.permanentLinkMapper = permanentLinkMapper; this.contentTypeRepository = contentTypeRepository; this.contentTypeAvailabilityService = contentTypeAvailabilityService; this.availableSettingsRepository = availableSettingsRepository; this.contentImporter = contentImporter; this.contentTransferValidator = contentTransferValidator; this.propertyCategoryTransform = propertyCategoryTransform; this.contentRootRepository = contentRootRepository; this.siteDefinitionRepository = siteDefinitionRepository; this.contentOptions = contentOptions; this.siteDefinitionResolver = siteDefinitionResolver; }
public ItemLogService(IPrincipalAccessor principalAccessor, IRepository repository) { this.principalAccessor = principalAccessor; this.repository = repository; }
public SessionFactoryProvider(IPrincipalAccessor principalAccessor) { this.principalAccessor = principalAccessor; }
public ClaimsAbpSession(IMultiTenancyConfig multiTenancy) { MultiTenancy = multiTenancy; PrincipalAccessor = DefaultPrincipalAccessor.Instance; }
public EventListenerHelper(IPrincipalAccessor principalAccessor) { this.principalAccessor = principalAccessor; }