/// <summary> /// /// </summary> /// <param name="configuration"></param> /// <param name="authorization"></param> /// <param name="webExecute"></param> /// <param name="logger"></param> public Transaction(IConfiguration configuration, IAuthorization authorization, IExecutorWeb webExecute, ILog logger) { _configuration = configuration; _authorization = authorization; _webExecute = webExecute; _logger = logger; }
private int runCount = 0; // number of times run has been called #endregion Fields #region Constructors /// <summary> /// Initializes a new instance of the <see cref="Bot"/> class. /// </summary> /// <param name="client">The client.</param> /// <param name="userInteraction">The user interaction manager..</param> /// <param name="console">The console.</param> /// <param name="settings">The settings.</param> /// <param name="listener">The listener.</param> /// <param name="pluginHandler">The plugin handler.</param> /// <param name="moduleLoader">The module loader.</param> /// <param name="authorization">The authorization manager.</param> public Bot( Client client, IUserInteraction userInteraction, IConsole console, IBotSettings settings, IListener listener, IPluginHandler pluginHandler, IModuleLoader moduleLoader, IAuthorization authorization) { Guard.Against(client.IsNull(), "client"); Guard.Against(userInteraction.IsNull(), "userInteraction"); Guard.Against(console.IsNull(), "console"); Guard.Against(settings.IsNull(), "settings"); Guard.Against(listener.IsNull(), "listener"); Guard.Against(pluginHandler.IsNull(), "pluginHandler"); Guard.Against(moduleLoader.IsNull(), "moduleLoader"); Guard.Against(authorization.IsNull(), "authorization"); this.client = client; this.userInteraction = userInteraction; this.console = console; this.settings = settings; this.listener = listener; this.pluginHandler = pluginHandler; this.moduleLoader = moduleLoader; this.authorization = authorization; this.SessionStart = DateTime.Now; }
protected override void OnInit(EventArgs e) { try { _authorization = new Authorization(User.Identity.Name); } catch { } base.OnInit(e); }
/// <summary> /// Initializes a new instance of the <see cref="PluginContext"/> class. /// Is marked as internal so external clients cannot instantiate. /// </summary> /// <param name="client">The client.</param> /// <param name="console">The console.</param> /// <param name="authorizer">The authorizer.</param> /// <param name="chatrooms">The chatrooms.</param> /// <param name="listener">The listener.</param> /// <param name="botSettings">The bot settings.</param> /// <param name="pluginHandler">The plugin handler.</param> /// <param name="dispatcher">The system dispatcher.</param> /// <param name="packet">The current packet to be processed.</param> /// <param name="chatHelper">The chat helper.</param> public PluginContext(Client client, IConsole console, IAuthorization authorizer, IChatRoomContainer chatrooms, IListener listener, IBotSettings botSettings, IPluginHandler pluginHandler, IDispatcher dispatcher, EventPacket packet, IChatHelper chatHelper) { this.Client = client; this.Console = console; this.Authorizer = authorizer; this.ChatRooms = chatrooms; this.Listener = listener; this.BotSettings = botSettings; this.Plugins = pluginHandler; this.Dispatcher = dispatcher; this.ThisRoom = chatHelper; }
public void CreateServiceAuthorizationStruct(IAuthorization authorization, string serviceName) { if (authorization == null) throw new ArgumentNullException("authorization"); foreach (Structure structure in _dbContext.Structures) { var structureContext = structure; var containers = _dbContext.Containers.Where((c) => c.ContainerPrototype.StructureId == structureContext.Id); foreach (Container container in containers) { CreateGroups(authorization, structure.Id, container.Id); foreach (WorkSpaceType workSpaceType in container.ContainerPrototype.WorkSpaceTypes) { var containerContext = container; var workSpaceTypeContext = workSpaceType; var rootName = authorization.GetContainerName(structure.Id, container.Id, workSpaceType.Name); authorization.CreateContainer(rootName); var roles = _dbContext.Roles.Where( (r) => r.ContainerPrototypeStructureId == structureContext.Id && r.WorkSpaceTypeStructureId == structureContext.Id && r.WorkSpaceTypeName == workSpaceTypeContext.Name && r.ContainerPrototypeName == containerContext.ContainerPrototype.Name ); SetCurrentAndParentRoleTypes(authorization, structure, container, rootName, serviceName, roles); SetChildsRoleTypes(authorization, structure, container, rootName, serviceName, roles); } } } authorization.Dispose(); }
private void CreateGroups(IAuthorization authorization, long structure, long container) { var roletypes = _dbContext.Enrolls.Where( (c) => c.ContainerId == container ).Select( (c) => c.RoleType ).Distinct(); foreach (RoleType roletype in roletypes) { var roletypeContext = roletype; var users = _dbContext.Enrolls.Where( (cu) => cu.ContainerId == container && cu.RoleTypeName == roletypeContext.Name && cu.RoleTypeStructureId == structure ).Select( (cu) => cu.User.Name ); authorization.AddGroup(authorization.GetGroupName(structure, container, roletype.Name), users); } }
public AuthController(UserContext UserContext, ILogger <AuthController> log, IAuthorization authorization) { this.authorization = authorization; this.UserContext = UserContext; this.logger = log; }
public WopiHandler(WopiUserRequest wopiUser) { _userRequest = wopiUser; _errHandler = new ErrorHandler(); _authorization = new Authorization(); }
public AuthorizationBehavior(IAuthorization authorization) { this.authorization = authorization; }
public MyService(IAuthorization auth) { _auth = auth; }
public CustomerFinderImpl(IRepository repository, IAuditor auditor, IAuthorization authorization) { this.repository = repository; this.auditor = auditor; this.authorization = authorization; }
public MainManager(AppDBContext context, IEncryptor encryptor, IKPSService kPSService, IMailSender mailSender, IMemoryCache cache, IAuthorization authenticator) { this.context = context; this.encryptor = encryptor; this.kPSService = kPSService; this.mailSender = mailSender; this.cache = cache; this.authenticator = authenticator; }
public static AuthorizedKey ForMetadata( ISshKey key, string preferredUsername, bool useInstanceKeySet, IAuthorization authorization) { Utilities.ThrowIfNull(key, nameof(key)); if (preferredUsername != null) { if (!IsValidUsername(preferredUsername)) { throw new ArgumentException( $"The username '{preferredUsername}' is not a valid username"); } else { // // Use the preferred username. // return(new AuthorizedKey( key, useInstanceKeySet ? AuthorizeKeyMethods.InstanceMetadata : AuthorizeKeyMethods.ProjectMetadata, preferredUsername)); } } else { Utilities.ThrowIfNull(authorization, nameof(authorization)); // // No preferred username provided, so derive one // from the user's email address: // // 1. Remove all characters following and including '@'. // 2. Lowercase all alpha characters. // 3. Replace all non-alphanum characters with '_'. // var username = new string(authorization.Email .Split('@')[0] .ToLower() .Select(c => IsAsciiLetterOrNumber(c) ? c : '_') .ToArray()); // // 4. Prepend with 'g' if the username does not start with an alpha character. // if (!IsAsciiLetter(username[0])) { username = "******" + username; } // // 5. Truncate the username to 32 characters. // username = username.Substring(0, Math.Min(MaxUsernameLength, username.Length)); return(new AuthorizedKey( key, useInstanceKeySet ? AuthorizeKeyMethods.InstanceMetadata : AuthorizeKeyMethods.ProjectMetadata, username)); } }
public ArtistController(IAuthorization authorization, IRepository artistRepository) { Authorization = authorization; Repository = artistRepository; }
public AuthorizationBehavior(IAuthorization authorization) { this.authorization = authorization; }
public AuthorizationServiceBefore() { // Возникает проблема в том что авторизация может быть только через mail // и чтобы сменить тип авторизации нужно будет лезть в код _authorization = new MailAuthorization(); }
public TwitterEngineConfiguration(TwitterAuthorization authorization) { this.authorization = authorization; }
private void SetCurrentAndParentRoleTypes( IAuthorization authorization, Structure structure, Container rootContainer, string rootName, string service, IEnumerable<Role> roles ) { Container current = rootContainer; do { foreach (var role in roles) if (ContainsRoleType(structure, current, role.RoleType)) { var permissions = role.Rule.Permissions.Where( (sp) => sp.ServiceName == service ).Select( (sp) => sp.Name ); authorization.AddGroupPermission( rootName, authorization.GetGroupName(structure.Id, current.Id, role.RoleTypeName), permissions ); } current = current.ParentContainer; } while (current != null); }
private void SetChildsRoleTypes( IAuthorization authorization, Structure structure, Container rootContainer, string rootName, string service, IEnumerable<Role> roles ) { if (rootContainer.Childs == null) return; foreach (var child in rootContainer.Childs) { SetChildsRoleTypes(authorization, structure, child, service, rootName, roles); foreach (var role in roles) if (ContainsRoleType(structure, child, role.RoleType)) { var permissions = role.Rule.Permissions.Where( (sp) => sp.ServiceName == service ).Select( (sp) => sp.Name ); authorization.AddGroupPermission( rootName, authorization.GetGroupName(structure.Id, child.Id, role.RoleTypeName), permissions ); } } }
public virtual void Logoff() { IAuthorization authorization = (IAuthorization)this.GetService <IPermissionsProvider>(); authorization.Logoff(); }
public AuthorizeController(IAuthorization authorization) { _authorization = authorization; }
/// <summary> /// Initializes a new instance of <see cref="ProductBlo"/> (Business Controller) /// </summary> /// <param name="authorization">Security information access object to be used by this instance</param> /// <param name="dataAccess">Application Request's data access object to be used by this instance</param> public ProductBlo(IProductDao dataAccess, IAuthorization authorization, ILogger logger, IMultimediaBlo multimediaBLO) : base(dataAccess, authorization, logger) { MultimediaBLO = multimediaBLO; }
public WopiProcessor(IAuthorization authorization, IErrorHandler errorHandler, HttpListenerResponse response) { _authorization = authorization; _errorHandler = errorHandler; _response = response; }
public async Task <AddDancerPayload> AddDancerAsync( AddDancerInput input, [ScopedService] DatabaseContext context, [Service] IFileStorage fileStorage, [Service] IAuthorization authorization, CancellationToken cancellationToken) { var authId = authorization.GetUserId(); if (authId == null) { return(new AddDancerPayload( new [] { new UserError("Cannot find auth id.", CommonErrorCodes.ACT_AGAINST_INVALID_SUBJECT) })); } if (context.Dancers.Any(d => d.AuthenticationId == authId)) { return(new AddDancerPayload( new [] { new UserError("Auth id already has associated dancer.", CommonErrorCodes.ACT_AGAINST_INVALID_SUBJECT) })); } var dancer = new Dancer { DdrCode = input.DdrCode, DdrName = input.DdrName, State = input.State, PrimaryMachineLocation = input.PrimaryMachineLocation, AuthenticationId = authId }; if (input.ProfilePicture != null) { dancer.ProfilePictureTimestamp = DateTime.UtcNow; try { using var profileImage = await Image.LoadAsync(input.ProfilePicture.OpenReadStream()); var image = await Images.ImageToPngMemoryStreamFactor(profileImage, 256, 256); var destinationKey = $"profile/picture/{dancer.Id}.{(dancer.ProfilePictureTimestamp?.Ticks - 621355968000000000) / 10000000}.png"; await fileStorage.UploadFileFromStream(image, destinationKey); } catch (Exception e) { Console.WriteLine(e.Message); return(new AddDancerPayload( new [] { new UserError("Failed to upload profile picture.", CommonErrorCodes.IMAGE_UPLOAD_FAILED) })); } } await context.Dancers.AddAsync(dancer, cancellationToken); await context.SaveChangesAsync(cancellationToken); return(new AddDancerPayload(dancer)); }
public async Task InvokeAsync(HttpContext context, IAuthorization authorization) { _authorization = authorization; await _next.Invoke(context); }
public virtual void testInvalidCreateAuthorization() { TestResource resource1 = new TestResource("resource1", 100); // case 1: no user id & no group id //////////// IAuthorization authorization = authorizationService.CreateNewAuthorization(AuthorizationFields.AuthTypeGrant); //authorization.Resource = resource1; try { authorizationService.SaveAuthorization(authorization); Assert.Fail("exception expected"); } catch (ProcessEngineException e) { Assert.True(e.Message.Contains("IAuthorization must either have a 'userId' or a 'groupId'.")); } // case 2: both user id & group id //////////// authorization = authorizationService.CreateNewAuthorization(AuthorizationFields.AuthTypeGrant); authorization.GroupId = "someId"; authorization.UserId = "someOtherId"; //authorization.Resource = resource1; try { authorizationService.SaveAuthorization(authorization); Assert.Fail("exception expected"); } catch (ProcessEngineException e) { AssertTextPresent("IAuthorization must either have a 'userId' or a 'groupId'.", e.Message); } // case 3: no resourceType //////////// authorization = authorizationService.CreateNewAuthorization(AuthorizationFields.AuthTypeGrant); authorization.UserId = "someId"; try { authorizationService.SaveAuthorization(authorization); Assert.Fail("exception expected"); } catch (ProcessEngineException e) { Assert.True(e.Message.Contains("IAuthorization 'resourceType' cannot be null.")); } // case 4: no permissions ///////////////// authorization = authorizationService.CreateNewAuthorization(AuthorizationFields.AuthTypeRevoke); authorization.UserId = "someId"; try { authorizationService.SaveAuthorization(authorization); Assert.Fail("exception expected"); } catch (ProcessEngineException e) { Assert.True(e.Message.Contains("IAuthorization 'resourceType' cannot be null.")); } }
public AcmeProcessingWorkflow() { _authorizationRules = ApplicationRoot.Context.Resolve <IAuthorization>(); _repository = ApplicationRoot.Context.Resolve <IRepository>(); }
public AuthController(IAuthorization repo, IConfiguration config) { _config = config; _repo = repo; }
public CustomerFinderImpl(IRepository repository, IAuditor auditor, IAuthorization authorization) { this.repository = repository; this.auditor = auditor; this.authorization = authorization; }
public BaseService(TBusinessLogicObject businessLogic, IHttpContextAccessor httpContextAccessor, IMapper mapper, IAuthorization authorization) { BusinessLogic = businessLogic; Request = httpContextAccessor.HttpContext.Request; Mapper = mapper; Authorization = authorization; }
public ListingsService(IProductBlo businessLogic, IHttpContextAccessor httpContextAccessor, IMapper mapper, IAuthorization authorization) : base(businessLogic, httpContextAccessor, mapper, authorization) { }
public void AuthorizeUsing(IAuthorization authorizationRules) { Console.WriteLine("Authorizing Stop with " + authorizationRules); }
public TrackController(IAuthorization auth, IRepository repository) { Authorization = auth; Repository = repository; }
public BookPersonManager(IAuthorization authorization) { Authorizator = authorization; }
public AuthorizationController(IAuthorization authorization) { _authorization = authorization; }
public AuthorizeTagHelper(IAuthorization authorization) { Authorization = authorization; }
protected ServerObject() { captcha = IoC.GetService <ICaptcha>(); authorization = IoC.GetService <IAuthorization>(); }
public PersonalAreaController(ILogger <PersonalAreaController> log, UserContext user, IPersonalArea personalArea, IAuthorization authorization) { this.personalAreaService = personalArea; this.logger = log; this.authorization = authorization; }
public AdminPanelFilms(UnitOfWork unitOfWork, IAuthorization authorization) { _unitOfWork = unitOfWork; _authorization = authorization; }
public virtual void Logon(ISecurityUser user) { IAuthorization authorization = (IAuthorization)this.GetService <IPermissionsProvider>(); authorization.Logon(user); }
public void AuthorizeUsing(IAuthorization authorizationRules) { }
public FacebookEngineConfiguration(IAuthorization authorization) { this.authorization = authorization; }
public SettingController(UserContext user, ILogger <SettingController> logger, IAuthorization authorization) { this.settingService = new SettingService(user); this.authorization = authorization; this.logger = logger; }
/// <summary> /// Initializes a new instance of the <see cref="PluginHandler"/> class. /// </summary> /// <param name="pluginLoader">The plugin loader.</param> /// <param name="authorizer">The authorizer.</param> /// <param name="serviceFactory">The service factory.</param> public PluginHandler(IPluginLoader pluginLoader, IAuthorization authorizer, IServiceHostFactory serviceFactory) { Guard.Against(pluginLoader == null, "pluginLoader"); Guard.Against(authorizer == null, "authorizer"); Guard.Against(serviceFactory == null, "serviceFactory"); this.pluginDirectory = pluginLoader.PluginDirectory; this.pluginLoader = pluginLoader; this.authorizer = authorizer; this.serviceFactory = serviceFactory; }
public GooglePlusEngineConfiguration(IAuthorization authorization) { this.authorization = authorization; }