コード例 #1
0
 public AzureAd(GrouperConfiguration config) : this(
         tenantId : config.AzureAdTenantId,
         clientId : config.AzureAdClientId,
         clientSecret : config.AzureAdClientSecret,
         clientSecretIsDpapiProtected : config.AzureAdClientSecretIsDpapiProtected)
 {
 }
コード例 #2
0
ファイル: Grouper.cs プロジェクト: Kungsbacka/Grouper
        public static Grouper CreateFromConfig(GrouperConfiguration config)
        {
            Grouper grouper = new Grouper(config.ChangeRatioLowerLimit);

            if (config.AzureAdRole != null && config.AzureAdRole.Length > 0)
            {
                AzureAd az = new AzureAd(config);
                if (config.AzureAdHasRole(GrouperConfiguration.Role.GroupStore))
                {
                    grouper.AddGroupStore(az);
                }
                if (config.ExchangeHasRole(GrouperConfiguration.Role.MemberSource))
                {
                    grouper.AddMemberSource(az);
                }
                if (config.AzureAdHasRole(GrouperConfiguration.Role.GroupOwnerSource))
                {
                    grouper.AddGroupOwnerSource(az);
                }
            }
            if (config.ExchangeRole != null && config.ExchangeRole.Length > 0)
            {
                Exo exo = new Exo(config);
                if (config.ExchangeHasRole(GrouperConfiguration.Role.GroupStore))
                {
                    grouper.AddGroupStore(exo);
                }
                if (config.ExchangeHasRole(GrouperConfiguration.Role.MemberSource))
                {
                    grouper.AddMemberSource(exo);
                }
            }
            if (config.OnPremAdHasRole(GrouperConfiguration.Role.GroupStore))
            {
                OnPremAd onPremAd = new OnPremAd(config);
                if (config.OnPremAdHasRole(GrouperConfiguration.Role.GroupStore))
                {
                    grouper.AddGroupStore(onPremAd);
                }
                if (config.OnPremAdHasRole(GrouperConfiguration.Role.MemberSource))
                {
                    grouper.AddMemberSource(onPremAd);
                }
            }
            if (!string.IsNullOrEmpty(config.MemberDatabaseConnectionString))
            {
                grouper.AddMemberSource(new MemberDb(config));
            }
            if (!string.IsNullOrEmpty(config.LogDatabaseConnectionString))
            {
                grouper.AddLogger(new LogDb(config));
            }
            if (!string.IsNullOrEmpty(config.OpenEDatabaseConnectionString))
            {
                grouper.AddGroupStore(new OpenE(config));
            }
            return(grouper);
        }
コード例 #3
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers()
            .AddNewtonsoftJson();
            services.Configure <GrouperConfiguration>(Configuration.GetSection("Grouper"));
            GrouperConfiguration config = new GrouperConfiguration();

            ConfigurationBinder.Bind(Configuration.GetSection("Grouper"), config);
            services.AddSingleton <IStringResourceHelper, StringResourceHelper>();
            services.AddSingleton((_) =>
            {
                return(Grouper.CreateFromConfig(config));
            });
        }
コード例 #4
0
 public OnPremAd(string userName, string password, bool passwordIsDpapiProtected)
 {
     // userName and password are optional
     if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password))
     {
         _userName = userName;
         _password = GrouperConfiguration.GetSensitiveString(password, passwordIsDpapiProtected);
     }
     _dnCache     = MemoryCache.Default;
     _cachePolicy = new CacheItemPolicy()
     {
         SlidingExpiration = TimeSpan.FromMinutes(30),
     };
 }
コード例 #5
0
ファイル: Exo.cs プロジェクト: Kungsbacka/Grouper
 public Exo(string userName, string password, bool passwordIsDpapiProtected)
 {
     if (string.IsNullOrEmpty(userName))
     {
         throw new ArgumentNullException(nameof(userName));
     }
     if (string.IsNullOrEmpty(password))
     {
         throw new ArgumentNullException(nameof(password));
     }
     string plaintextPassword = GrouperConfiguration.GetSensitiveString(password, passwordIsDpapiProtected);
     SecureString securePassword = new SecureString();
     foreach (char c in plaintextPassword)
     {
         securePassword.AppendChar(c);
     }
     _credential = new PSCredential(userName, securePassword);
 }
コード例 #6
0
 public AzureAd(string tenantId, string clientId, string clientSecret, bool clientSecretIsDpapiProtected)
 {
     if (!Guid.TryParse(tenantId, out _))
     {
         throw new ArgumentException(nameof(tenantId), "Argument is not a valid GUID.");
     }
     if (!Guid.TryParse(clientId, out _))
     {
         throw new ArgumentException(nameof(clientId), "Argument is not a valid GUID.");
     }
     if (string.IsNullOrEmpty(clientSecret))
     {
         throw new ArgumentNullException(nameof(clientSecret));
     }
     _clientId     = clientId;
     _clientSecret = GrouperConfiguration.GetSensitiveString(clientSecret, clientSecretIsDpapiProtected);
     _authorityUri = new Uri($"https://login.microsoftonline.com/{tenantId}");
 }
コード例 #7
0
 public GrouperController(Microsoft.Extensions.Options.IOptions <GrouperConfiguration> config)
 {
     _config = config.Value ?? throw new ArgumentNullException();
 }
コード例 #8
0
 public DocumentController(IOptions <GrouperConfiguration> config, Grouper grouper, IStringResourceHelper stringResourceHelper)
 {
     _config = config.Value ?? throw new ArgumentNullException();
     _stringResourceHelper = stringResourceHelper;
     _grouperBackend       = grouper ?? throw new ArgumentNullException(nameof(grouper));
 }
コード例 #9
0
ファイル: DocumentDb.cs プロジェクト: lulzzz/Grouper
 public DocumentDb(GrouperConfiguration configuration, string author)
     : this(configuration.DocumentDatabaseConnectionString, author)
 {
 }
コード例 #10
0
 public Exo(GrouperConfiguration config) : this(
         userName : config.ExchangeUserName,
         password : config.ExchangePassword,
         passwordIsDpapiProtected : config.ExchangePasswordIsDpapiProtected)
 {
 }
コード例 #11
0
 public AuditLogController(IOptions <GrouperConfiguration> config)
 {
     _config = config.Value ?? throw new ArgumentNullException();
 }
コード例 #12
0
 public OnPremAd(GrouperConfiguration config) : this(
         userName : config.OnPremAdUserName,
         password : config.OnPremAdPassword,
         passwordIsDpapiProtected : config.OnPremAdPasswordIsDpapiProtected)
 {
 }
コード例 #13
0
ファイル: Worker.cs プロジェクト: lulzzz/Grouper
 public Worker(EventLog eventLog)
 {
     _eventLog = eventLog ?? throw new ArgumentNullException(nameof(eventLog));
     _config   = GrouperConfiguration.CreateFromAppSettings(ConfigurationManager.AppSettings);
 }
コード例 #14
0
 public OpenE(GrouperConfiguration config) : this(config.OpenEDatabaseConnectionString)
 {
 }
コード例 #15
0
 public MemberDb(GrouperConfiguration configuration)
     : this(configuration.MemberDatabaseConnectionString)
 {
 }
コード例 #16
0
 public LogDb(GrouperConfiguration configuration)
     : this(configuration.LogDatabaseConnectionString)
 {
 }
コード例 #17
0
ファイル: Worker.cs プロジェクト: Kungsbacka/Grouper
 public Worker()
 {
     _config = GrouperConfiguration.CreateFromAppSettings(ConfigurationManager.AppSettings);
 }