/// <summary>
 /// Create a specific `Partner`.
 /// </summary>
 /// <remarks>
 /// Create a management partner for the objectId and tenantId.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='partnerId'>
 /// Id of the Partner
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <PartnerResponse> CreateAsync(this IPartnerOperations operations, string partnerId, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateWithHttpMessagesAsync(partnerId, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 public Office365CustomerService(
     IPartnerOperations partnerOperations,
     IOffice365UtilitiesService office365Utilities,
     IConfigurationManager configurationManager)
 {
     _partnerOperations  = partnerOperations;
     _office365Utilities = office365Utilities;
     _retryAttempts      = int.Parse(configurationManager.GetByKey("RetryAttempts"));
 }
Ejemplo n.º 3
0
 public Office365SubscriptionService(
     IPartnerOperations partnerOperations,
     IOffice365OrderService office365OrderService,
     IConfigurationManager configurationManager)
 {
     _partnerOperations     = partnerOperations;
     _office365OrderService = office365OrderService;
     _retryAttempts         = int.Parse(configurationManager.GetByKey("RetryAttempts"));
 }
 /// <summary>
 /// Create a specific `Partner`.
 /// </summary>
 /// <remarks>
 /// Create a management partner for the objectId and tenantId.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='partnerId'>
 /// Id of the Partner
 /// </param>
 public static PartnerResponse Create(this IPartnerOperations operations, string partnerId)
 {
     return(operations.CreateAsync(partnerId).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Delete a specific `Partner`.
 /// </summary>
 /// <remarks>
 /// Delete the management partner for the objectId and tenantId.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='partnerId'>
 /// Id of the Partner
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task DeleteAsync(this IPartnerOperations operations, string partnerId, CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.DeleteWithHttpMessagesAsync(partnerId, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
 /// <summary>
 /// Delete a specific `Partner`.
 /// </summary>
 /// <remarks>
 /// Delete the management partner for the objectId and tenantId.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='partnerId'>
 /// Id of the Partner
 /// </param>
 public static void Delete(this IPartnerOperations operations, string partnerId)
 {
     operations.DeleteAsync(partnerId).GetAwaiter().GetResult();
 }
 public Office365UserService(IPartnerOperations partnerOperations, IConfigurationManager configurationManager)
 {
     _partnerOperations = partnerOperations;
     _retryAttempts     = int.Parse(configurationManager.GetByKey("RetryAttempts"));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MigrationBatchController"/> class.
 /// </summary>
 /// <param name="service">Provides access to core services.</param>
 /// <param name="operations">Provides the ability to perform partner operations.</param>
 public MigrationBatchController(IMigrationService service, IPartnerOperations operations) : base(service)
 {
     this.operations = operations;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Configures authentication for the application.
        /// </summary>
        /// <param name="app">The application to be configured.</param>
        public void ConfigureAuth(IAppBuilder app)
        {
            IMigrationService  service    = MvcApplication.UnityContainer.Resolve <IMigrationService>();
            IPartnerOperations operations = MvcApplication.UnityContainer.Resolve <IPartnerOperations>();

            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            app.UseOpenIdConnectAuthentication(
                new OpenIdConnectAuthenticationOptions
            {
                ClientId  = service.Configuration.ApplicationId,
                Authority = $"{service.Configuration.ActiveDirectoryEndpoint}/common",

                Notifications = new OpenIdConnectAuthenticationNotifications
                {
                    AuthenticationFailed = (context) =>
                    {
                        // Track the exceptions using the telemetry provider.
                        service.Telemetry.TrackException(context.Exception);

                        // Pass in the context back to the app
                        context.OwinContext.Response.Redirect("/Home/Error");

                        // Suppress the exception
                        context.HandleResponse();

                        return(Task.FromResult(0));
                    },
                    AuthorizationCodeReceived = async(context) =>
                    {
                        string userTenantId         = context.AuthenticationTicket.Identity.FindFirst("http://schemas.microsoft.com/identity/claims/tenantid").Value;
                        string signedInUserObjectId = context.AuthenticationTicket.Identity.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;

                        IGraphClient client = new GraphClient(service, userTenantId);

                        List <RoleModel> roles = await client.GetDirectoryRolesAsync(signedInUserObjectId);

                        foreach (RoleModel role in roles)
                        {
                            context.AuthenticationTicket.Identity.AddClaim(new System.Security.Claims.Claim(System.Security.Claims.ClaimTypes.Role, role.DisplayName));
                        }

                        bool isPartnerUser = userTenantId.Equals(
                            service.Configuration.PartnerCenterApplicationTenantId, StringComparison.CurrentCultureIgnoreCase);

                        string customerId   = string.Empty;
                        string organization = string.Empty;

                        if (!isPartnerUser)
                        {
                            try
                            {
                                Customer c   = await operations.GetCustomerAsync(userTenantId);
                                customerId   = c.Id;
                                organization = c.CompanyProfile.Domain;
                            }
                            catch (PartnerException ex)
                            {
                                if (ex.ErrorCategory != PartnerErrorCategory.NotFound)
                                {
                                    throw;
                                }
                            }
                        }

                        if (isPartnerUser || !string.IsNullOrWhiteSpace(customerId))
                        {
                            // Add the customer identifier to the claims
                            context.AuthenticationTicket.Identity.AddClaim(new System.Security.Claims.Claim("CustomerId", userTenantId));
                            context.AuthenticationTicket.Identity.AddClaim(new System.Security.Claims.Claim("Organization", organization));
                        }
                    },
                    RedirectToIdentityProvider = (context) =>
                    {
                        string appBaseUrl = context.Request.Scheme + "://" + context.Request.Host + context.Request.PathBase;
                        context.ProtocolMessage.RedirectUri           = appBaseUrl + "/";
                        context.ProtocolMessage.PostLogoutRedirectUri = appBaseUrl;
                        return(Task.FromResult(0));
                    }
                },
                TokenValidationParameters = new TokenValidationParameters
                {
                    SaveSigninToken = true,
                    ValidateIssuer  = false
                }
            });
        }
Ejemplo n.º 10
0
 public AddressValidationService(IPartnerOperations partnerOperations)
 {
     _partnerOperations = partnerOperations;
 }
Ejemplo n.º 11
0
 public Office365DomainService(IPartnerOperations partnerOperations, IOffice365ApiService office365ApiService)
 {
     _partnerOperations   = partnerOperations;
     _office365ApiService = office365ApiService;
 }