public CommentController(IOrchardServices services, ICommentService commentService, INotifier notifier, IAuthorizer authorizer) {
     Services = services;
     _commentService = commentService;
     _notifier = notifier;
     _authorizer = authorizer;
     T = NullLocalizer.Instance;
 }
Example #2
0
        public static async Task<List<User>> ShowFriends(IAuthorizer auth, string login)
        {
            var users = new List<User>();
            var twitterCtx = new TwitterContext(auth);

            Friendship friendship;
            long cursor = -1;
            do
            {
                friendship = await twitterCtx.Friendship.Where(x =>
                   x.Type == FriendshipType.FriendsList
                   && x.ScreenName == login
                   && x.Cursor == cursor
                   && x.Count == 200
                   && x.IncludeUserEntities == false)
                    .SingleOrDefaultAsync();

                if (friendship != null
                    && friendship.Users != null
                    && friendship.CursorMovement != null)
                {
                    cursor = friendship.CursorMovement.Next;
                    users.AddRange(friendship.Users);
                }
            } while (cursor != 0);
            return users;
        }
Example #3
0
 public LoginForm(IAuthorizer authorizer)
 {
     InitializeComponent();
     AuthorizationResult = new AuthorizationResult();
     this.authorizer = authorizer;
     this.textBoxUseName.Text = "supakull";
 }
 public ProfilerFilter(WorkContext workContext, IAuthorizer authorizer, IShapeFactory shapeFactory, IProfilerService profiler)
 {
     this.workContext = workContext;
     this.shapeFactory = shapeFactory;
     this.authorizer = authorizer;
     this.profiler = profiler;
 }
 public ContentExportController(IContentExportService contentExportService, IMembershipService membershipService, IAuthenticationService authenticationService, IAuthorizer authorizer)
 {
     _contentExportService = contentExportService;
     _membershipService = membershipService;
     _authenticationService = authenticationService;
     _authorizer = authorizer;
 }
 public AdminController(IOrchardServices services, IThemeService themeService, IPreviewTheme previewTheme, IAuthorizer authorizer, INotifier notifier)
 {
     Services = services;
     _themeService = themeService;
     _previewTheme = previewTheme;
     T = NullLocalizer.Instance;
 }
Example #7
0
 public ContentController(IAuthorizer authorizer, IContentManager contentManager, INotifier notifier, IContentDefinitionManager contentDefinitionManager) {
     _authorizer = authorizer;
     _contentManager = contentManager;
     _notifier = notifier;
     _contentDefinitionManager = contentDefinitionManager;
     T = NullLocalizer.Instance;
 }
Example #8
0
 public RoleService(IRepository<Role> rolesRepo,
     IAuthorizer authorizer)
 {
     _rolesRepo = rolesRepo;
     _authorizer = authorizer;
     Logger = NullLogger.Instance;
 }
        public AdminController(IAuthorizer authorizer, IGraphManager graphManager, INotifier notifier)
        {
            _authorizer = authorizer;
            _graphManager = graphManager;
            _notifier = notifier;

            T = NullLocalizer.Instance;
        }
Example #10
0
        public FormsIdentityUserProvider(IHttpContextProvider httpContext, IAuthorizer authorizer)
        {
            Guard.IsNotNull(httpContext, "httpContext");
            Guard.IsNotNull(authorizer, "authorizer");

            this.httpContext = httpContext;
            this.authorizer = authorizer;
        }
 public OAuthHttpHandler(OAuthHttpHandlerOptions options)
 {
     if (options == null) throw new ArgumentNullException("authorizer");
     this.options = options;
     InnerHandler = options.InnerHandler ?? new HttpClientHandler();
     ownsHandler = options.InnerHandler == null;
     authorizer = new Authorizer.Authorizer(options.AuthorizerOptions, () => new HttpClient(InnerHandler, false));
 }
Example #12
0
 public HomeController(ITagService tagService, IAuthorizer authorizer, INotifier notifier, IContentManager contentManager)
 {
     _tagService = tagService;
     _authorizer = authorizer;
     _notifier = notifier;
     _contentManager = contentManager;
     T = NullLocalizer.Instance;
 }
Example #13
0
        public ClientController(IClientManager clientManager, IUserClientService svcUserClient, IAuthorizer authorizer)
        {
            _clientManager = clientManager;
            _svcUserClient = svcUserClient;

            Logger = NullLogger.Instance;
            _authorizer = authorizer;
        }
 public MovieLookupController(
     IOrchardServices orchardServices,
     IMovieService movieService,
     IAuthorizer authorizer) {
     _orchardServices = orchardServices;
     _movieService = movieService;
     _authorizer = authorizer;
 }
Example #15
0
 public TemplatesFilter(
     WorkContext workContext, 
     IAuthorizer authorizer,
     IShapeFactory shapeFactory) {
     _workContext = workContext;
     _authorizer = authorizer;
     _shapeFactory = shapeFactory;
 }
 public ViewPermissionsSettingsHooks(
     IAuthorizer authorizer, 
     IAuthorizationService authorizationService, 
     IRoleService roleService
     ) {
     _authorizer = authorizer;
     _authorizationService = authorizationService;
     _roleService = roleService;
 }
 public DownloadController(
     IContentManager contentManager,
     IAuthorizer authorizer,
     IFileBuilder fileBuilder)
 {
     _contentManager = contentManager;
     _authorizer = authorizer;
     _fileBuilder = fileBuilder;
 }
 public InlineShapeFactory(IAuthorizer authorizer, 
     IWorkContextAccessor workContextAccessor,
     IShapeTableManager shapeTableManager,
     IThemeManager themeManager) {
     _authorizer = authorizer;
     _shapeTableManager = shapeTableManager;
     _themeManager = themeManager;
     _workContext = workContextAccessor.GetContext();
 }
Example #19
0
 public ContactController(IOrchardServices services, IContactInfoService cis, IContactFormService cfs, INotifier notifier, IAuthorizer auth)
 {
     Services = services;
     _notifier = notifier;
     _authorizer = auth;
     _cIS = cis;
     _cFS = cfs;
     T = NullLocalizer.Instance;
 }
Example #20
0
 public Crawler(VkApi api, IConnectionChecker checker, IAuthorizer authorizer, IUrlConverter converter, IDatabaseProvider databaseDbProvider, IGroupInfoProvider groupInfoProvider)
 {
     this.api = api;
     this.checker = checker;
     this.converter = converter;
     this.authorizer = authorizer;
     this.dbProvider = databaseDbProvider;
     this.groupInfoProvider = groupInfoProvider;
 }
 public HttpQueryRouteMapper(
     ILogger<HttpQueryProcessor> logger,
     IAuthorizer authorizer,
     IProcessQueries processor)
 {
     _logger = logger;
     _authorizer = authorizer;
     _processor = processor;
 }
 public HttpCommandRouteMapper(
     ILogger<HttpCommandDispatcher> logger,
     IAuthorizer authorizer,
     IDispatchCommands dispatcher)
 {
     _logger = logger;
     _authorizer = authorizer;
     _dispatcher = dispatcher;
 }
 public RecycleBinController(IAuthorizer authorizer, IContentManager contentManager, INotifier notifier, IOrchardServices services, IRecycleBin recycleBin) {
     _authorizer = authorizer;
     _contentManager = contentManager;
     _notifier = notifier;
     _services = services;
     _recycleBin = recycleBin;
     T = NullLocalizer.Instance;
     Logger = NullLogger.Instance;
 }
 public AdminController(
     IAuthorizer authorizer,
     IMembershipService membershipService,
     IAuthenticationService authenticationService)
 {
     _authorizer = authorizer;
     _membershipService = membershipService;
     _authenticationService = authenticationService;
 }
Example #25
0
 public PageController(IPageRepository repository, PageService pageService,
                       ITemplateRepository templateRepository, IPageTreeRepository pageTreeRepository,
                       IAuthorizer authorizer)
 {
     _repository = repository;
     _pageService = pageService;
     _templateRepository = templateRepository;
     _pageTreeRepository = pageTreeRepository;
     _authorizer = authorizer;
 }
Example #26
0
        public TagsController(
            ITaxonomyService taxonomyService,
            IContentManager contentManager,
			IAuthorizer authorizer) {
            _taxonomyService = taxonomyService;
            T = NullLocalizer.Instance;
            _contentManager = contentManager;
	        _authorizer = authorizer;
            Logger = NullLogger.Instance;
        }
Example #27
0
        public TweetRating(IAuthorizer client, ITweet tweet)
        {
            _client = client;
            _tweet = tweet;

            _observer = new PropertyObserver<IAuthorizer>(_client).
                RegisterHandler(x => x.AuthenticatedUser,
                                x => UpdateIsMention());
            UpdateIsMention();
        }
 public ContactFormController(
     IShapeFactory shapeFactory, 
     IContactFormService contactFormService, IClock clock, IAuthorizer authorizer)
 {
     T = NullLocalizer.Instance;
     New = shapeFactory;
     _contactFormService = contactFormService;
     _clock = clock;
     _authorizer = authorizer;
 }
 public RolePermissionsService(IRoleService roleService,
     IAuthorizer authorizer,
     IPermissionManager permissionManager,
     IEventManager eventManager)
 {
     _roleService = roleService;
     _authorizer = authorizer;
     _permissionManager = permissionManager;
     _eventManager = eventManager;
     _allPermissionsCache = _permissionManager.GetAllPermissions();
 }
 public HttpCommandDispatcher(
     ILogger<HttpCommandDispatcher> logger,
     IAuthorizer authorizer,
     IDispatchCommands dispatcher,
     Type type)
 {
     _logger = logger;
     _authorizer = authorizer;
     _dispatcher = dispatcher;
     _type = type;
 }
Example #31
0
 public ArticleController(IArticleService service, IAuthorizer authorizer)
     : base(service)
 {
     _authorizer = authorizer;
 }
Example #32
0
 public OAuth2HttpHandler(IAuthorizer authorizer, IMemoryCache memoryCache)
 {
     _authorizer  = authorizer;
     _memoryCache = memoryCache;
     _cacheKey    = Guid.NewGuid().ToString();
 }
 public MediaController(IAuthorizer authorizer, IMediaLibraryService mediaLibraryService, IStorageProvider storageProvider)
 {
     _authorizer          = authorizer;
     _mediaLibraryService = mediaLibraryService;
     _storageProvider     = storageProvider;
 }
        public TestKeyStore(IConfiguration configuration, ILogger <TestKeyStore> logger)
        {
            _logger = logger;
            configuration.ThrowIfNull(nameof(configuration));

            var         testKeysSection = configuration.GetSection("TestKeys");
            IAuthorizer keyAuth         = null;

            if (!testKeysSection.Exists())
            {
                throw new System.ArgumentException("TestKeys section does not exist");
            }

            foreach (var testKey in testKeysSection.GetChildren())
            {
                List <string> roles       = new List <string>();
                var           validRoles  = testKey.GetSection("AuthorizedRoles");
                var           validEmails = testKey.GetSection("AuthorizedEmailAddress");

                if (validRoles != null && validRoles.Exists() &&
                    validEmails != null && validEmails.Exists())
                {
                    throw new System.ArgumentException("Both role and email authorizers cannot be used on the same test key");
                }

                if (validRoles != null && validRoles.Exists())
                {
                    RoleAuthorizer roleAuth = new RoleAuthorizer(configuration);
                    keyAuth = roleAuth;
                    foreach (var role in validRoles.GetChildren())
                    {
                        roleAuth.AddRole(role.Value);
                    }
                }
                else if (validEmails != null && validEmails.Exists())
                {
                    EmailAuthorizer emailAuth = new EmailAuthorizer();
                    keyAuth = emailAuth;
                    foreach (var email in validEmails.GetChildren())
                    {
                        emailAuth.AddEmail(email.Value);
                    }
                }

                int?expirationTimeInDays = null;
                var cacheTime            = testKey["CacheExpirationInDays"];
                if (cacheTime != null)
                {
                    expirationTimeInDays = Convert.ToInt32(cacheTime, sg.CultureInfo.InvariantCulture);
                }

                var name       = testKey["Name"];
                var id         = testKey["Id"];
                var publicPem  = testKey["PublicPem"];
                var privatePem = testKey["PrivatePem"];

                if (name == null)
                {
                    throw new System.ArgumentException("The key must have a name");
                }

                if (id == null)
                {
                    throw new System.ArgumentException("The key must have an id");
                }

                if (publicPem == null)
                {
                    throw new System.ArgumentException("The key must have a publicPem");
                }

                if (privatePem == null)
                {
                    throw new System.ArgumentException("The key must have a privatePem");
                }
                _logger.LogInformation("testStore constructe will createTestKey with following params:name=" + name + " and id=" + id);

                CreateTestKey(
                    name,
                    id,
                    publicPem,
                    privatePem,
                    KeyType,
                    Algorithm,
                    keyAuth,
                    expirationTimeInDays);
            }

            // //use ukc as keystore - add also the key from ukc
            // byte[] keyNameBytes = Encoding.UTF8.GetBytes(ukcKeyName);

            // Library.C_Initialize();
            // CK_SLOT_ID[] slots = Library.C_GetSlotList(true);
            // CK_SLOT_ID slot = slots[0];
            // CK_SESSION_HANDLE session = Library.C_OpenSession(slot);

            // Library.C_FindObjectsInit(session, new CK_ATTRIBUTE[]
            // {
            //     new CK_ATTRIBUTE(CK.CKA_TOKEN, true),
            //     new CK_ATTRIBUTE(CK.CKA_CLASS, CK.CKO_PRIVATE_KEY),
            //     new CK_ATTRIBUTE(CK.CKA_KEY_TYPE, CK.CKK_RSA),
            //     new CK_ATTRIBUTE(CK.CKA_ID, keyNameBytes),
            //     //new CK_ATTRIBUTE(CK.DYCKA_UID , keyUID)
            // });

            // CK_OBJECT_HANDLE[] foundKeyHandles = Library.C_FindObjects(session, 1);
            // Library.C_FindObjectsFinal(session);

            // CK_ATTRIBUTE n =  new CK_ATTRIBUTE(CK.CKA_MODULUS);
            // CK_ATTRIBUTE e = new CK_ATTRIBUTE(CK.CKA_PUBLIC_EXPONENT);
            // CK_ATTRIBUTE privateKeyUid =  new CK_ATTRIBUTE(CK.DYCKA_UID);

            // if(foundKeyHandles.Length > 0)
            // {
            //     //get public key
            //     Library.C_GetAttributeValue(session, foundKeyHandles[0],new CK_ATTRIBUTE[]
            //     {
            //         n,
            //         e,
            //         privateKeyUid
            //     });

            //     string nStrBase64 = Convert.ToBase64String((byte[])n.pValue);
            //     string uid = ukcKeyUid;
            //     //string vOut = (UInt64)privateKeyUid.pValue;


            //     //build the public key obj
            //     var publicKeyFromUkc = new PublicKey(nStrBase64,65537);

            //     //publicKeyFromUkc.KeyId = ((UInt64)privateKeyUid.pValue).ToString();
            //     publicKeyFromUkc.KeyType = "RSA";
            //     publicKeyFromUkc.Algorithm = "RS256";

            //       CreateTestKey(
            //         ukcKeyName,
            //         uid,
            //         nStrBase64,
            //         nStrBase64,
            //         publicKeyFromUkc.KeyType,
            //         publicKeyFromUkc.Algorithm,
            //         keyAuth,
            //         null);
            // }
        }
Example #35
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TwitterContext"/> class.
 /// </summary>
 /// <param name="authorizer">The authorizer.</param>
 public TwitterContext(IAuthorizer authorizer)
     : this(new TwitterExecute(authorizer))
 {
 }
Example #36
0
 public APISecurityProvider(IOperationSecurityConfigProvider securityConfigProvider, ISemanticLog logger, ISessionManager sessionManager, IAuthorizer authorize, IExecutionContextFactory executionContextProvider)
 {
     this.logger = logger;
     this.securityConfigProvider = securityConfigProvider;
     this.sessionManager         = sessionManager;
     this.authorize = authorize;
     this.executionContextProvider = executionContextProvider;
 }
Example #37
0
 public ProductController(IProductService service, IProductCategoryService productCategoryService, IAuthorizer authorizer)
     : base(service)
 {
     _productCategoryService = productCategoryService;
     _authorizer             = authorizer;
 }
Example #38
0
 public SecureMediaPartDriver(IAuthorizer authorizer)
 {
     _authorizer = authorizer;
 }
Example #39
0
 public UserLogic(IUserRepository userRepository,
                  IAuthorizer authorizer)
 {
     this.authorizer     = authorizer;
     this.userRepository = userRepository;
 }
Example #40
0
 public ContentPermissionsPartDriver(IRoleService roleService, IAuthorizer authorizer, IAuthorizationService authorizationService)
 {
     _roleService          = roleService;
     _authorizer           = authorizer;
     _authorizationService = authorizationService;
 }
Example #41
0
 public SecurityFilter(IAuthorizer authorizer)
 {
     _authorizer = authorizer;
     Logger      = NullLogger.Instance;
 }
Example #42
0
        static async Task DoDemosAsync()
        {
            IAuthorizer auth = ChooseAuthenticationStrategy();

            await auth.AuthorizeAsync();

            // This is how you access credentials after authorization.
            // The oauthToken and oauthTokenSecret do not expire.
            // You can use the userID to associate the credentials with the user.
            // You can save credentials any way you want - database, isolated storage, etc. - it's up to you.
            // You can retrieve and load all 4 credentials on subsequent queries to avoid the need to re-authorize.
            // When you've loaded all 4 credentials, LINQ to Twitter will let you make queries without re-authorizing.
            //
            //var credentials = auth.CredentialStore;
            //string oauthToken = credentials.OAuthToken;
            //string oauthTokenSecret = credentials.OAuthTokenSecret;
            //string screenName = credentials.ScreenName;
            //ulong userID = credentials.UserID;
            //

            var  twitterCtx = new TwitterContext(auth);
            char key;

            do
            {
                ShowMenu();

                key = Console.ReadKey(true).KeyChar;

                switch (key)
                {
                case '0':
                    Console.WriteLine("\n\tRunning Account Demos...\n");
                    await AccountDemos.RunAsync(twitterCtx);

                    break;

                case '1':
                    Console.WriteLine("\n\tRunning Account Activity Demos...\n");
                    await AccountActivityDemos.RunAsync(twitterCtx);

                    break;

                case '2':
                    Console.WriteLine("\n\tRunning Block Demos...\n");
                    await BlockDemos.RunAsync(twitterCtx);

                    break;

                case '3':
                    Console.WriteLine("\n\tRunning Direct Message Events Demos...\n");
                    await DirectMessageEventsDemos.RunAsync(twitterCtx);

                    break;

                case '4':
                    Console.WriteLine("\n\tRunning Favorite Demos...\n");
                    await FavoriteDemos.RunAsync(twitterCtx);

                    break;

                case '5':
                    Console.WriteLine("\n\tRunning Friendship Demos...\n");
                    await FriendshipDemos.RunAsync(twitterCtx);

                    break;

                case '6':
                    Console.WriteLine("\n\tRunning Geo Demos...\n");
                    await GeoDemos.RunAsync(twitterCtx);

                    break;

                case '7':
                    Console.WriteLine("\n\tRunning Help Demos...\n");
                    await HelpDemos.RunAsync(twitterCtx);

                    break;

                case '8':
                    Console.WriteLine("\n\tRunning List Demos...\n");
                    await ListDemos.RunAsync(twitterCtx);

                    break;

                case '9':
                    Console.WriteLine("\n\tRunning Media Demos...\n");
                    await MediaDemos.RunAsync(twitterCtx);

                    break;

                case 'a':
                case 'A':
                    Console.WriteLine("\n\tRunning Mutes Demos...\n");
                    await MuteDemos.RunAsync(twitterCtx);

                    break;

                case 'b':
                case 'B':
                    Console.WriteLine("\n\tRunning Raw Demos...\n");
                    await RawDemos.RunAsync(twitterCtx);

                    break;

                case 'c':
                case 'C':
                    Console.WriteLine("\n\tRunning Saved Search Demos...\n");
                    await SavedSearchDemos.RunAsync(twitterCtx);

                    break;

                case 'd':
                case 'D':
                    Console.WriteLine("\n\tRunning Search Demos...\n");
                    await SearchDemos.RunAsync(twitterCtx);

                    break;

                case 'e':
                case 'E':
                    Console.WriteLine("\n\tRunning Status Demos...\n");
                    await StatusDemos.RunAsync(twitterCtx);

                    break;

                case 'f':
                case 'F':
                    Console.WriteLine("\n\tRunning Stream Demos...\n");
                    await StreamDemos.RunAsync(twitterCtx);

                    break;

                case 'g':
                case 'G':
                    Console.WriteLine("\n\tRunning Trend Demos...\n");
                    await TrendDemos.RunAsync(twitterCtx);

                    break;

                case 'h':
                case 'H':
                    Console.WriteLine("\n\tRunning User Demos...\n");
                    await UserDemos.RunAsync(twitterCtx);

                    break;

                case 'i':
                case 'I':
                    Console.WriteLine("\n\tRunning Welcome Message Demos...\n");
                    await WelcomeMessageDemos.RunAsync(twitterCtx);

                    break;

                case 'q':
                case 'Q':
                    Console.WriteLine("\nQuitting...\n");
                    break;

                default:
                    Console.WriteLine(key + " is unknown");
                    break;
                }
            } while (char.ToUpper(key) != 'Q');
        }
Example #43
0
 public AuditTrailImportHandler(IRepository <AuditTrailEventRecord> auditTrailEventRepository, IAuthorizer authorizer, IWorkContextAccessor wca)
 {
     _auditTrailEventRepository = auditTrailEventRepository;
     _authorizer = authorizer;
     _wca        = wca;
 }
Example #44
0
        public AuthenticateAttribute(IAuthorizer authorizer)
        {
            Require.NotNull(authorizer, nameof(authorizer));

            _authorizer = authorizer;
        }
Example #45
0
 public VersionManagerController(IVersionManagerWorkerService versionManagerWorkerService, IAuthorizer authorizer)
 {
     _versionManagerWorkerService = versionManagerWorkerService;
     _authorizer = authorizer;
     T           = NullLocalizer.Instance;
 }
 public AuthorizationDecorator(IRepository <TModel> repository, IAuthorizer authorizer, User user)
 {
     this.repository = repository;
     this.authorizer = authorizer;
     this.user       = user;
 }
Example #47
0
 public DownloadController(IRepository <FileUploadRecord> fileUploadRepository, IContentManager contentManager, IAuthorizer authorizer, IWorkContextAccessor workContext)
 {
     _fileUploadRepository = fileUploadRepository;
     _contentManager       = contentManager;
     _authorizer           = authorizer;
     _workContext          = workContext;
     Logger = NullLogger.Instance;
 }
Example #48
0
 public EditLinkShapeProvider(IAuthorizer authorizer, IOrchardServices services)
 {
     _services = services;
     _customFormsEditService = new CustomFormsEditService(authorizer);
 }
Example #49
0
 public Calculator(IAuthorizer authorizer)
 {
     this.authorizer = authorizer;
 }
 public HtmlFilter(IWorkContextAccessor workContext, ICacheManager cacheManager, ISignals signals, IAuthorizer authorizer)
 {
     Logger            = NullLogger.Instance;
     this.workContext  = workContext.GetContext();
     this.cacheManager = cacheManager;
     this.signals      = signals;
     this.authorizer   = authorizer;
 }
Example #51
0
 /// <summary>
 /// supports testing
 /// </summary>
 public TwitterExecute(IAuthorizer authorizer)
 {
     Authorizer           = authorizer ?? throw new ArgumentNullException("authorizedClient");
     Authorizer.UserAgent = Authorizer.UserAgent ?? L2TKeys.DefaultUserAgent;
 }
Example #52
0
 public AccountController(IAuthorizer authorizer, IMapper mapper)
 {
     _authorizer = authorizer;
     _mapper     = mapper;
 }
Example #53
0
 public CoreAuthorizeFilter(IAuthorizationDataProvider authorizationDataProvider, IAuthorizer authorizer,
                            IAuthorizationPolicyProvider policyProvider)
 {
     _authorizationDataProvider   = authorizationDataProvider;
     BaseAuthorizor               = authorizer;
     _authorizationPolicyProvider = policyProvider;
     BaseAuthorizationPolicy      = ConstructBaseAuthorizationPolicy();
 }
Example #54
0
 public ProjectController(IProjectManager projectManager, IUserManager userManager, IAuthorizer authorizer)
 {
     _projectManager = projectManager;
     _userManager    = userManager;
     _authorizer     = authorizer;
 }
        private async Task InitTwitterAPIAsync(IAuthorizer auth)
        {
            await auth.AuthorizeAsync();

            _twitterContext = new TwitterContext(auth);
        }
Example #56
0
        public TestKeyStore(IConfiguration configuration)
        {
            configuration.ThrowIfNull(nameof(configuration));

            var         testKeysSection = configuration.GetSection("TestKeys");
            IAuthorizer keyAuth         = null;

            if (!testKeysSection.Exists())
            {
                throw new System.ArgumentException("TestKeys section does not exist");
            }

            foreach (var testKey in testKeysSection.GetChildren())
            {
                List <string> roles       = new List <string>();
                var           validRoles  = testKey.GetSection("AuthorizedRoles");
                var           validEmails = testKey.GetSection("AuthorizedEmailAddress");

                if (validRoles != null && validRoles.Exists() &&
                    validEmails != null && validEmails.Exists())
                {
                    throw new System.ArgumentException("Both role and email authorizers cannot be used on the same test key");
                }

                if (validRoles != null && validRoles.Exists())
                {
                    RoleAuthorizer roleAuth = new RoleAuthorizer(configuration);
                    keyAuth = roleAuth;
                    foreach (var role in validRoles.GetChildren())
                    {
                        roleAuth.AddRole(role.Value);
                    }
                }
                else if (validEmails != null && validEmails.Exists())
                {
                    EmailAuthorizer emailAuth = new EmailAuthorizer();
                    keyAuth = emailAuth;
                    foreach (var email in validEmails.GetChildren())
                    {
                        emailAuth.AddEmail(email.Value);
                    }
                }

                int?expirationTimeInDays = null;
                var cacheTime            = testKey["CacheExpirationInDays"];
                if (cacheTime != null)
                {
                    expirationTimeInDays = Convert.ToInt32(cacheTime, sg.CultureInfo.InvariantCulture);
                }

                var name       = testKey["Name"];
                var id         = testKey["Id"];
                var publicPem  = testKey["PublicPem"];
                var privatePem = testKey["PrivatePem"];

                if (name == null)
                {
                    throw new System.ArgumentException("The key must have a name");
                }

                if (id == null)
                {
                    throw new System.ArgumentException("The key must have an id");
                }

                if (publicPem == null)
                {
                    throw new System.ArgumentException("The key must have a publicPem");
                }

                if (privatePem == null)
                {
                    throw new System.ArgumentException("The key must have a privatePem");
                }

                CreateTestKey(
                    name,
                    id,
                    publicPem,
                    privatePem,
                    KeyType,
                    Algorithm,
                    keyAuth,
                    expirationTimeInDays);
            }
        }
 public MoviesController(IMoviesRepository repo, IMapper mapper, IAuthorizer authorizer)
 {
     _repo       = repo;
     _mapper     = mapper;
     _authorizer = authorizer;
 }
 public DefaultTreePermissionProvider(IAuthorizer authorizer)
 {
     _authorizer = authorizer;
 }
Example #59
0
        public SnapshotsController(ISnapshotService snapshotService, INotifier notifier, IClock clock, IContentExportService contentExportService, ShellSettings shellSettings, IAuthorizer authorizer)
        {
            _snapshotService      = snapshotService;
            _notifier             = notifier;
            _clock                = clock;
            _contentExportService = contentExportService;
            _shellSettings        = shellSettings;
            _authorizer           = authorizer;

            T      = NullLocalizer.Instance;
            Logger = NullLogger.Instance;
        }
Example #60
0
 public AdminFilter(IAuthorizer authorizer)
 {
     _authorizer = authorizer;
     T           = NullLocalizer.Instance;
 }