public IMicrosoftGraphClient CreateClientNoPassthrough(MicrosoftGraphOptions options, string teamId)
        {
            var httpHandler = _httpClientFactory.Handler ?? new TokenDelegatingHandler(options, _httpClientFactory.Client, options.GraphApiUserId);

            DelegatingHandler[] handlers = { httpHandler };
            return(new MicrosoftGraphClient(new Uri(options.MSBaseAddress), handlers));
        }
        public IMicrosoftGraphClient CreateUserClient(MicrosoftGraphOptions options, string userId)
        {
            var httpHandler = _httpClientFactory.Handler ?? new TokenDelegatingHandler(options, _httpClientFactory.Client, userId);

            DelegatingHandler[] handlers = { httpHandler, new PassThroughDelegatingHandler() };
            return(new MicrosoftGraphClient(new Uri(options.MSBaseAddress), handlers));
        }
 public MicrosoftGraphScheduleDestinationService(MicrosoftGraphOptions options, IMicrosoftGraphClientFactory clientFactory, IUserPrincipalMap userPrincipalMap, IShiftMap shiftMap)
 {
     _options          = options ?? throw new ArgumentNullException(nameof(options));
     _clientFactory    = clientFactory ?? throw new ArgumentNullException(nameof(clientFactory));
     _userPrincipalMap = userPrincipalMap ?? throw new ArgumentNullException(nameof(userPrincipalMap));
     _shiftMap         = shiftMap ?? throw new ArgumentNullException(nameof(shiftMap));
 }
 public TokenHttpHandler(MicrosoftGraphOptions options, HttpClient httpClient, string teamId, ISecretsService secretsService)
 {
     _options        = options;
     _httpClient     = httpClient;
     _teamId         = teamId;
     _secretsService = secretsService;
 }
        public MicrosoftGraphShiftThemeMap(MicrosoftGraphOptions options)
        {
            var builder = new DbConnectionStringBuilder();

            if (!string.IsNullOrEmpty(options.ThemeMap))
            {
                builder.ConnectionString = options.ThemeMap;
            }
            _themeMap = new ConcurrentDictionary <string, string>();
            foreach (var key in builder.Keys)
            {
                _themeMap[key.ToString()] = builder[key.ToString()].ToString();
            }

            _teamsColours = new Dictionary <Color, string>
            {
                { HexToColour("#a0aeb2"), "white" },          // light: #eceff0, dark: #a0aeb2
                { HexToColour("#0078d7"), "blue" },           // light: #ccedf7, dark: #0078d7
                { HexToColour("#8cbd18"), "green" },          // light: #e8f2d1, dark: #8cbd18
                { HexToColour("#8378de"), "purple" },         // light: #e6e4f8, dark: #8378de
                { HexToColour("#ed616f"), "pink" },           // light: #ffd9d9, dark: #ed616f
                { HexToColour("#ffb900"), "yellow" },         // light: #fff1cc, dark: #ffb900
                { HexToColour("#393939"), "gray" },           // light: #d7d7d7, dark: #393939
                { HexToColour("#004e8c"), "darkBlue" },       // light: #ccdce8, dark: #004e8c
                { HexToColour("#498205"), "darkGreen" },      // light: #dbe6cd, dark: #498205
                { HexToColour("#4e257f"), "darkPurple" },     // light: #dcd3e5, dark: #4e257f
                { HexToColour("#a4262c"), "darkPink" },       // light: #edd4d5, dark: #a4262c
                { HexToColour("#ffaa44"), "darkYellow" },     // light: #ffeeda, dark: #ffaa44
            };
        }
示例#6
0
 public TeamsService(MicrosoftGraphOptions options, IMicrosoftGraphClientFactory clientFactory, IShiftMap shiftMap, ICacheService cacheService, ITimeOffMap timeOffMap, IAvailabilityMap availabilityMap)
 {
     _options         = options ?? throw new ArgumentNullException(nameof(options));
     _clientFactory   = clientFactory ?? throw new ArgumentNullException(nameof(clientFactory));
     _shiftMap        = shiftMap ?? throw new ArgumentNullException(nameof(shiftMap));
     _cacheService    = cacheService ?? throw new ArgumentNullException(nameof(cacheService));
     _timeOffMap      = timeOffMap ?? throw new ArgumentNullException(nameof(timeOffMap));
     _availabilityMap = availabilityMap ?? throw new ArgumentNullException(nameof(availabilityMap));
 }
示例#7
0
 public SubscribeTrigger(MicrosoftGraphOptions options, IScheduleConnectorService scheduleConnectorService, IScheduleSourceService scheduleSourceService, IScheduleDestinationService scheduleDestinationService, ISecretsService secretsService, IHttpClientFactory httpClientFactory)
 {
     _options = options ?? throw new ArgumentNullException(nameof(options));
     _scheduleConnectorService   = scheduleConnectorService ?? throw new ArgumentNullException(nameof(scheduleConnectorService));
     _scheduleSourceService      = scheduleSourceService ?? throw new ArgumentNullException(nameof(scheduleSourceService));
     _scheduleDestinationService = scheduleDestinationService ?? throw new ArgumentNullException(nameof(scheduleDestinationService));
     _secretsService             = secretsService ?? throw new ArgumentNullException(nameof(secretsService));
     _httpClientFactory          = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));
 }
        public TokenDelegatingHandler(MicrosoftGraphOptions options, HttpClient httpClient, string userId)
        {
            if (string.IsNullOrEmpty(userId))
            {
                throw new ArgumentException("message", nameof(userId));
            }

            _options    = options ?? throw new ArgumentNullException(nameof(options));
            _httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
            _userId     = userId;
        }
示例#9
0
        /// <inheritdoc cref="IAuthenticationProvider"/>
        public AzureAuthenticationProvider(MicrosoftGraphOptions graphOptions)
        {
            _graphOptions = graphOptions;
            var certPath = @"C:\Repositories\Labs\VRIS2\API\src\VRIS.OutlookConnect\cert (2).pfx";
            var certPass = "******";

            // Create a collection object and populate it using the PFX file
            var collection = new X509Certificate2Collection();

            collection.Import(certPath, certPass, X509KeyStorageFlags.PersistKeySet);

            _certificate = collection[0];
        }
 public SubscribeTrigger(TeamOrchestratorOptions teamOrchestratorOptions, MicrosoftGraphOptions options,
                         FeatureOptions featureOptions, IScheduleConnectorService scheduleConnectorService, IWfmDataService wfmDataService,
                         ITeamsService teamsService, ISecretsService secretsService, IHttpClientFactory httpClientFactory,
                         ISystemTimeService systemTimeService, ITimeZoneService timeZoneService)
 {
     _teamOrchestratorOptions = teamOrchestratorOptions ?? throw new ArgumentNullException(nameof(teamOrchestratorOptions));
     _options                  = options ?? throw new ArgumentNullException(nameof(options));
     _featureOptions           = featureOptions ?? throw new ArgumentNullException(nameof(featureOptions));
     _scheduleConnectorService = scheduleConnectorService ?? throw new ArgumentNullException(nameof(scheduleConnectorService));
     _wfmDataService           = wfmDataService ?? throw new ArgumentNullException(nameof(wfmDataService));
     _teamsService             = teamsService ?? throw new ArgumentNullException(nameof(teamsService));
     _secretsService           = secretsService ?? throw new ArgumentNullException(nameof(secretsService));
     _httpClientFactory        = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));
     _systemTimeService        = systemTimeService ?? throw new ArgumentNullException(nameof(systemTimeService));
     _timeZoneService          = timeZoneService ?? throw new ArgumentNullException(nameof(timeZoneService));
 }
        public static Task <TokenResponse> RequestTokenAsync(this HttpClient httpClient, MicrosoftGraphOptions options, string redirectUri, string code)
        {
            Guard.ArgumentNotEmpty(redirectUri, nameof(redirectUri));
            Guard.ArgumentNotEmpty(code, nameof(code));

            var tokenRequest = new TokenRequest
            {
                Address      = options.TokenUrl,
                ClientId     = options.ClientId,
                ClientSecret = options.ClientSecret,
                GrantType    = OidcConstants.GrantTypes.AuthorizationCode,
                Parameters   =
                {
                    { "code",         code          },
                    { "redirect_uri", redirectUri   },
                    { "scope",        options.Scope }
                }
            };

            return(httpClient.RequestTokenAsync(tokenRequest));
        }
示例#12
0
 public MicrosoftGraphShiftMap(IShiftThemeMap shiftThemeMap, MicrosoftGraphOptions options)
 {
     _shiftThemeMap = shiftThemeMap ?? throw new ArgumentNullException(nameof(shiftThemeMap));
     _options       = options ?? throw new ArgumentNullException(nameof(options));
 }
 public RefreshTrigger(MicrosoftGraphOptions options, IHttpClientFactory httpClientFactory)
 {
     _options           = options ?? throw new ArgumentNullException(nameof(options));
     _httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));
 }
示例#14
0
 /// <inheritdoc cref="AuthorizationController"/>
 public AuthorizationController(IHttpContextAccessor httpContextAccessor, MicrosoftGraphOptions graphOptions, ITokenStore tokenStore)
 {
     _httpContextAccessor = httpContextAccessor;
     _graphOptions        = graphOptions;
     _tokenStore          = tokenStore;
 }
        public IMicrosoftGraphClient CreateClient(MicrosoftGraphOptions options, string teamId)
        {
            var httpHandler = _httpClientFactory.Handler ?? new TokenHttpHandler(options, _httpClientFactory.Client, teamId, _secretsService);

            return(new MicrosoftGraphClient(new Uri(options.BaseAddress), httpHandler));
        }
示例#16
0
 public ConfigTrigger(MicrosoftGraphOptions microsoftGraphOptions, JdaPersonaOptions jdaPersonaOptions, IScheduleConnectorService scheduleConnectorService)
 {
     _microsoftGraphOptions    = microsoftGraphOptions ?? throw new ArgumentNullException(nameof(microsoftGraphOptions));
     _jdaPersonaOptions        = jdaPersonaOptions ?? throw new ArgumentNullException(nameof(jdaPersonaOptions));
     _scheduleConnectorService = scheduleConnectorService ?? throw new ArgumentNullException(nameof(scheduleConnectorService));
 }
示例#17
0
 public MicrosoftGraphUserPrincipalMap(MicrosoftGraphOptions options)
 {
     _options = options ?? throw new ArgumentNullException(nameof(options));
     _formats = options.UserPrincipalNameFormatString.Split(',', ';');
 }
        public static Task <TokenResponse> RequestTokenAsync(this HttpClient httpClient, MicrosoftGraphOptions options)
        {
            var tokenRequest = new TokenRequest
            {
                Address      = string.Format(options.AppTokenUrl, options.TenantId),
                ClientId     = options.ClientId,
                ClientSecret = options.ClientSecret,
                GrantType    = OidcConstants.GrantTypes.ClientCredentials,
                Parameters   =
                {
                    { "scope", options.AppScope }
                }
            };

            return(httpClient.RequestTokenAsync(tokenRequest));
        }
 public ConsentTrigger(MicrosoftGraphOptions options)
 {
     _options = options ?? throw new ArgumentNullException(nameof(options));
 }
示例#20
0
 public MicrosoftGraphTimeOffMap(MicrosoftGraphOptions options)
 {
     _options = options ?? throw new ArgumentNullException(nameof(options));
 }
        public static Task <TokenResponse> RequestRefreshTokenAsync(this HttpClient httpClient, MicrosoftGraphOptions options, TokenModel tokenModel)
        {
            var refreshTokenRequest = new RefreshTokenRequest
            {
                Address      = options.TokenUrl,
                ClientId     = options.ClientId,
                ClientSecret = options.ClientSecret,
                Scope        = options.Scope,
                RefreshToken = tokenModel.RefreshToken,
                GrantType    = OidcConstants.GrantTypes.RefreshToken
            };

            return(httpClient.RequestRefreshTokenAsync(refreshTokenRequest));
        }