/// <summary> /// Creates an instance of <see cref="IBoilerplateContext"/> /// </summary> /// <param name="identity">The current identity being used (rights and roles contract requirements/restrictions will apply to this identity)</param> /// <param name="accessProvider">An access provider for specific types (available through IBoilerplateContext.Open<T>())</param> /// <param name="permissionsProvider">The provider that will be used for all permissions verification attempts</param> /// <param name="visibility">The visibility level that this context has. This will affect operations that rely on visibility (e.g. logging).</param> /// <returns>An instance of <see cref="IBoilerplateContext"/></returns> public static IBoilerplateContext New(IIdentity identity = null, ITypeAccessProvider accessProvider = null, IPermissionsProvider permissionsProvider = null, Visibility visibility = Visibility.None) { var actualIdentity = identity ?? Identity.Default; var actualTypeAccessProvider = accessProvider ?? TypeAccessProvider.Empty; var actualPermissionsProvider = permissionsProvider ?? PermissionsProvider.Default; var functionGenerator = new FunctionGenerator(); //Core providers var translationProvider = new TranslationProvider(functionGenerator); var validationProvider = new ValidationProvider(functionGenerator); var logProvider = new LogProvider(functionGenerator, visibility); //Set up error handling var tryCatchProvider = new TryCatchBlockProvider(functionGenerator); var exceptionHandlerProvider = new ExceptionHandlerProvider(logProvider); var errorContext = new ImmutableErrorContext(logProvider, tryCatchProvider, exceptionHandlerProvider); var bundle = new ContextBundle(permissionsProvider: actualPermissionsProvider, errorContext: errorContext, translationProvider: translationProvider, accessProvider: actualTypeAccessProvider, validationProvider: validationProvider, logProvider: logProvider, visibility: visibility); return new InitialBoilerplateContext<ContractContext>(bundle, actualIdentity); }
/// <summary> /// Creates an instance of <see cref="IBoilerplateContext"/> /// </summary> /// <param name="identity">The current identity being used (rights and roles contract requirements/restrictions will apply to this identity)</param> /// <param name="accessProvider">An access provider for specific types (available through IBoilerplateContext.Open<T>())</param> /// <param name="permissionsProvider">The provider that will be used for all permissions verification attempts</param> /// <param name="visibility">The visibility level that this context has. This will affect operations that rely on visibility (e.g. logging).</param> /// <returns>An instance of <see cref="IBoilerplateContext"/></returns> public static IBoilerplateContext New(IIdentity identity = null, ITypeAccessProvider accessProvider = null, IPermissionsProvider permissionsProvider = null, Visibility visibility = Visibility.None) { var actualIdentity = identity ?? Identity.Default; var actualTypeAccessProvider = accessProvider ?? TypeAccessProvider.Empty; var actualPermissionsProvider = permissionsProvider ?? PermissionsProvider.Default; var functionGenerator = new FunctionGenerator(); //Core providers var translationProvider = new TranslationProvider(functionGenerator); var validationProvider = new ValidationProvider(functionGenerator); var logProvider = new LogProvider(functionGenerator, visibility); //Set up error handling var tryCatchProvider = new TryCatchBlockProvider(functionGenerator); var exceptionHandlerProvider = new ExceptionHandlerProvider(logProvider); var errorContext = new ImmutableErrorContext(logProvider, tryCatchProvider, exceptionHandlerProvider); var bundle = new ContextBundle(permissionsProvider: actualPermissionsProvider, errorContext: errorContext, translationProvider: translationProvider, accessProvider: actualTypeAccessProvider, validationProvider: validationProvider, logProvider: logProvider, visibility: visibility); return(new InitialBoilerplateContext <ContractContext>(bundle, actualIdentity)); }
public PermissionAuthorizationPolicyProvider(IOptions <AuthorizationOptions> options, IConfiguration configuration, IPermissionsProvider permissionsProvider, IMemoryCache memoryCache) : base(options) { _configuration = configuration; _permissionsProvider = permissionsProvider; _memoryCache = memoryCache; }
public async Task UpdateDefaultRolesAsync(IPermissionsProvider <Permission> permission) { await UpdateDefaultRolesAsync(new List <IPermissionsProvider <Permission> >() { permission }); }
/// <summary> /// Creates a new instance of the <see cref="TypeAccessProviderBase"/> class /// </summary> /// <param name="permissionsProvider">The permissions provider</param> /// <param name="types">The types that may be provided</param> public TypeAccessProviderBase(IPermissionsProvider permissionsProvider, IEnumerable <Type> types) { this.permissionsProvider = permissionsProvider; if (types == null) { this.types = new HashSet <Type>().ToImmutableHashSet(); } this.types = types.ToImmutableHashSet(); }
public UserSetupController(IUserListProvider userListProvider, IPermissionsProvider permissionsProvider, IUserProvider userProvider, ICommandHandler commandHandler) { _userListProvider = userListProvider; _permissionsProvider = permissionsProvider; _userProvider = userProvider; _commandHandler = commandHandler; }
public PlatformExportImportManager(UserManager <ApplicationUser> userManager, RoleManager <Role> roleManager, IPermissionsProvider permissionsProvider, ISettingsManager settingsManager, IDynamicPropertyService dynamicPropertyService, IModuleCatalog moduleCatalog, IMemoryCache memoryCache) { _dynamicPropertyService = dynamicPropertyService; _userManager = userManager; _roleManager = roleManager; _settingsManager = settingsManager; _moduleCatalog = moduleCatalog; _memoryCache = memoryCache; _permissionsProvider = permissionsProvider; }
/// <summary> /// Initializes a new <c>GablarskiServer</c> instance. /// </summary> /// <param name="settings">The settings for the server, providing name, description, etc.</param> /// <param name="authProvider">The user authentication provider for the server to use.</param> /// <param name="permissionProvider">The user permissions provider for the server to use.</param> /// <param name="channelProvider">The channel provider for the server to use.</param> public GablarskiServer(ServerSettings settings, IUserProvider authProvider, IPermissionsProvider permissionProvider, IChannelProvider channelProvider) : this(settings) { this.authProvider = authProvider; this.permissionProvider = permissionProvider; this.permissionProvider.PermissionsChanged += OnPermissionsChanged; this.channelProvider = channelProvider; SetupHandlers(); }
public static IPermissionsProvider GetPermissionsProvider() { using (PermissionsProviderContext context = new PermissionsProviderContext()) { string userName = HttpContext.Current.User.Identity.Name; IPermissionsProvider permissionsProvider = context.GetUsers().FirstOrDefault(p => p.Name == userName); if (permissionsProvider == null) { BasicAuthModule.CreateNotAuthorizedResponse(HttpContext.Current.ApplicationInstance, 401, 3, "Logon failed."); } return(permissionsProvider); } }
public SecurityController(SignInManager <ApplicationUser> signInManager, UserManager <ApplicationUser> userManager, RoleManager <Role> roleManager, IPermissionsProvider permissionsProvider, IUserSearchService userSearchService, IRoleSearchService roleSearchService, IOptions <SecurityOptions> securityOptions) { _signInManager = signInManager; _userManager = userManager; _securityOptions = securityOptions.Value; _permissionsProvider = permissionsProvider; _roleManager = roleManager; _userSearchService = userSearchService; _roleSearchService = roleSearchService; }
public ServerProviders(IChannelProvider channels, IUserProvider auth, IPermissionsProvider permissions, IEnumerable<IConnectionProvider> cproviders) : this(cproviders) { if (channels == null) throw new ArgumentNullException ("channels"); if (auth == null) throw new ArgumentNullException ("auth"); if (permissions == null) throw new ArgumentNullException ("permissions"); Channels = channels; Users = auth; Permissions = permissions; }
private static void ViewAllContacts(IPermissionsProvider permissionsProvider) { using (EFCoreDemoDbContext dbContext = new EFCoreDemoDbContext(permissionsProvider)) { int i = 1; IEnumerable <Contact> contacts = dbContext.Contacts; foreach (Contact contact in contacts) { if (i == 1) { Console.WriteLine("Contacts:"); } Console.WriteLine("\n{0}. Name: {1}\nAddress: {2}", i, contact.Name, contact.Address); i++; } } }
public ContextBundle(IPermissionsProvider permissionsProvider = null, IImmutableErrorContext errorContext = null, ITypeAccessProvider accessProvider = null, ITranslationProvider translationProvider = null, IValidationProvider validationProvider = null, ILogProvider logProvider = null, Visibility visibility = Visibility.None, Visibility timingVisibility = Visibility.None) { this.permissionsProvider = permissionsProvider ?? PermissionsProvider.Default; this.errorContext = errorContext ?? ImmutableErrorContext.Empty; this.accessProvider = accessProvider ?? TypeAccessProvider.Empty; this.translationProvider = translationProvider ?? TranslationProvider.Empty; this.validationProvider = validationProvider ?? ValidationProvider.Empty; this.logProvider = logProvider ?? LogProvider.Default; this.visibility = visibility; this.timingVisibility = timingVisibility; }
public IContextBundle Copy(IPermissionsProvider permissionsProvider = null, IImmutableErrorContext errorContext = null, ITypeAccessProvider accessProvider = null, ITranslationProvider translationProvider = null, IValidationProvider validationProvider = null, ILogProvider logProvider = null, Visibility? visibility = null, Visibility? timingVisibility = null) { return new ContextBundle(permissionsProvider ?? this.permissionsProvider, errorContext ?? this.errorContext, accessProvider ?? this.accessProvider, translationProvider ?? this.translationProvider, validationProvider ?? this.validationProvider, logProvider ?? this.logProvider, visibility ?? this.visibility, timingVisibility ?? this.timingVisibility); }
public IContextBundle Copy(IPermissionsProvider permissionsProvider = null, IImmutableErrorContext errorContext = null, ITypeAccessProvider accessProvider = null, ITranslationProvider translationProvider = null, IValidationProvider validationProvider = null, ILogProvider logProvider = null, Visibility?visibility = null, Visibility?timingVisibility = null) { return(new ContextBundle(permissionsProvider ?? this.permissionsProvider, errorContext ?? this.errorContext, accessProvider ?? this.accessProvider, translationProvider ?? this.translationProvider, validationProvider ?? this.validationProvider, logProvider ?? this.logProvider, visibility ?? this.visibility, timingVisibility ?? this.timingVisibility)); }
public ServerProviders(IChannelProvider channels, IUserProvider auth, IPermissionsProvider permissions, IEnumerable <IConnectionProvider> cproviders) : this(cproviders) { if (channels == null) { throw new ArgumentNullException("channels"); } if (auth == null) { throw new ArgumentNullException("auth"); } if (permissions == null) { throw new ArgumentNullException("permissions"); } Channels = channels; Users = auth; Permissions = permissions; }
public ImportPipelineBuilder(IEnumerable <IProjectImportManager> importManagers, IEnumerable <IProjectParser> parsers, FilteringExpressionSetManager filteringExpressionSetManager, ProjectRepository projectRepository, PermissionRepository permissionRepository, IServiceProvider serviceProvider, IPermissionsProvider permissionsProvider) { m_projectImportManagers = new Dictionary <string, IProjectImportManager>(); m_projectParsers = new Dictionary <string, IProjectParser>(); m_filteringExpressionSetManager = filteringExpressionSetManager; m_serviceProvider = serviceProvider; m_permissionsProvider = permissionsProvider; m_projectRepository = projectRepository; m_permissionRepository = permissionRepository; foreach (var manager in importManagers) { m_projectImportManagers.Add(manager.ExternalRepositoryTypeName, manager); } foreach (var parser in parsers) { m_projectParsers.Add(parser.BibliographicFormatName, parser); } }
private static IPermissionsProvider GetPermissionProvider() { using (PermissionProviderContext context = new PermissionProviderContext()) { string userName = ""; do { Console.WriteLine("Username (Admin or John): "); userName = Console.ReadLine(); } while(userName != "John" && userName != "Admin"); string password = userName; IPermissionsProvider permissionProvider = context.GetUserByCredentials(userName, password); if (permissionProvider == null) { throw new Exception("Incorrect username. Please try again with the right credentials."); } else { return(permissionProvider); } } }
public TestTypeAccessProvider(IPermissionsProvider provider, IEnumerable <Type> types) : base(provider, types) { }
public SecurityExpressionBuilder(IPermissionProcessor permissionProcessor, IPermissionsProvider permissionsProvider, DbContext securityDbContext) { this.permissionProcessor = permissionProcessor; this.permissionsProvider = permissionsProvider; realDbContext = ((BaseSecurityDbContext)securityDbContext).RealDbContext; }
public ServerProviders GetProviders(ILog log) { var providerTypes = new HashSet <Type>(); foreach (ProviderElement provider in Providers) { Type t; try { t = Type.GetType(provider.Type); if (t == null) { log.WarnFormat("Could not find type: " + provider.Type); continue; } } catch (Exception ex) { log.Warn("Error loading type: " + provider.Type, ex); continue; } if (!providerTypes.Contains(t)) { providerTypes.Add(t); } } var instances = new Dictionary <Type, object>(); List <IConnectionProvider> cproviders = new List <IConnectionProvider>(); foreach (Type cproviderType in providerTypes.Where(t => t.GetInterface("IConnectionProvider") != null)) { try { IConnectionProvider cprovider = (IConnectionProvider)Activator.CreateInstance(cproviderType); instances.Add(cproviderType, cprovider); cproviders.Add(cprovider); } catch (Exception ex) { log.Warn("Error while creating connection provider " + cproviderType.FullName, ex); } } IChannelProvider channels = LoadProvider <IChannelProvider> (providerTypes, instances, log); if (channels == null) { return(null); } IUserProvider auth = LoadProvider <IUserProvider> (providerTypes, instances, log); if (auth == null) { return(null); } IPermissionsProvider permissions = LoadProvider <IPermissionsProvider> (providerTypes, instances, log); if (permissions == null) { return(null); } return(new ServerProviders(channels, auth, permissions, cproviders)); }
public ViewModulesCatalog(ComposablePartCatalog inner, IPermissionsProvider permissionsProvider) : base(inner, part => part.ExportDefinitions.All(def => permissionsProvider.IsAllowed(def)))
protected PermissionManagerBase(IPermissionsProvider permissionProvider) { _definitions = permissionProvider.GetPermissions(); }
/// <summary> /// Creates a new instance of the <see cref="TypeAccessProvider"/> class. /// Uses the given <see cref="IPermissionsProvider"/> to determine permissions. /// </summary> /// <param name="permissionsProvider">The permissions provider</param> /// <param name="typeProviders">The type providers that may be accessed</param> public TypeAccessProvider(IPermissionsProvider permissionsProvider, params ITypeProvider[] typeProviders) : base(permissionsProvider, typeProviders.AggregateProvidableTypes()) { this.typeProviders = typeProviders; }
public PermissionProcessor(IPermissionsProvider permissionsProvider, DbContext securityDbContext) { this.permissionsProvider = permissionsProvider; this.securityDbContext = (BaseSecurityDbContext)securityDbContext; }
public EFCoreDemoDbContext(IPermissionsProvider permissionsProvider) { PermissionsContainer.AddPermissions(permissionsProvider.GetPermissions()); }
public WindowsPermissionManager(IPermissionsProvider permissionProvider) : base(permissionProvider) { _definitions = permissionProvider.GetPermissions(); }