コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ManagementApiClient"/> class.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <param name="baseUri">The base URI.</param>
        /// <param name="diagnostics">The diagnostics.</param>
        /// <param name="handler">The <see cref="HttpMessageHandler"/> which is used for HTTP requests</param>
        public ManagementApiClient(string token, Uri baseUri, DiagnosticsHeader diagnostics, HttpMessageHandler handler)
        {
            // If no diagnostics header structure was specified, then revert to the default one
            if (diagnostics == null)
            {
                diagnostics = DiagnosticsHeader.Default;
            }

            apiConnection = new ApiConnection(token, baseUri.AbsoluteUri, diagnostics, handler);

            BlacklistedTokens = new BlacklistedTokensClient(apiConnection);
            ClientGrants      = new ClientGrantsClient(apiConnection);
            Clients           = new ClientsClient(apiConnection);
            Connections       = new ConnectionsClient(apiConnection);
            DeviceCredentials = new DeviceCredentialsClient(apiConnection);
            EmailProvider     = new EmailProviderClient(apiConnection);
            Jobs            = new JobsClient(apiConnection);
            Logs            = new LogsClient(apiConnection);
            ResourceServers = new ResourceServersClient(apiConnection);
            Rules           = new RulesClient(apiConnection);
            Stats           = new StatsClient(apiConnection);
            TenantSettings  = new TentantSettingsClient(apiConnection);
            Tickets         = new TicketsClient(apiConnection);
            UserBlocks      = new UserBlocksClient(apiConnection);
            Users           = new UsersClient(apiConnection);
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ManagementApiClient"/> class.
        /// </summary>
        /// <param name="token">A valid Auth0 Management API v2 token.</param>
        /// <param name="baseUri"><see cref="Uri"/> of the tenant to manage.</param>
        /// <param name="managementConnection"><see cref="IManagementConnection"/> to facilitate communication with server.</param>
        public ManagementApiClient(string token, Uri baseUri, IManagementConnection managementConnection = null)
        {
            if (managementConnection == null)
            {
                var ownedManagementConnection = new HttpClientManagementConnection();
                managementConnection = ownedManagementConnection;
                connectionToDispose  = ownedManagementConnection;
            }

            var defaultHeaders = CreateDefaultHeaders(token);

            BlacklistedTokens = new BlacklistedTokensClient(managementConnection, baseUri, defaultHeaders);
            ClientGrants      = new ClientGrantsClient(managementConnection, baseUri, defaultHeaders);
            Clients           = new ClientsClient(managementConnection, baseUri, defaultHeaders);
            Connections       = new ConnectionsClient(managementConnection, baseUri, defaultHeaders);
            CustomDomains     = new CustomDomainsClient(managementConnection, baseUri, defaultHeaders);
            DeviceCredentials = new DeviceCredentialsClient(managementConnection, baseUri, defaultHeaders);
            EmailProvider     = new EmailProviderClient(managementConnection, baseUri, defaultHeaders);
            EmailTemplates    = new EmailTemplatesClient(managementConnection, baseUri, defaultHeaders);
            Guardian          = new GuardianClient(managementConnection, baseUri, defaultHeaders);
            Jobs            = new JobsClient(managementConnection, baseUri, defaultHeaders);
            Logs            = new LogsClient(managementConnection, baseUri, defaultHeaders);
            ResourceServers = new ResourceServersClient(managementConnection, baseUri, defaultHeaders);
            Roles           = new RolesClient(managementConnection, baseUri, defaultHeaders);
            Rules           = new RulesClient(managementConnection, baseUri, defaultHeaders);
            Stats           = new StatsClient(managementConnection, baseUri, defaultHeaders);
            TenantSettings  = new TenantSettingsClient(managementConnection, baseUri, defaultHeaders);
            Tickets         = new TicketsClient(managementConnection, baseUri, defaultHeaders);
            UserBlocks      = new UserBlocksClient(managementConnection, baseUri, defaultHeaders);
            Users           = new UsersClient(managementConnection, baseUri, defaultHeaders);
        }
コード例 #3
0
 public ContainerViewModel(ItemsClient itemsClient, ClientsClient clientsClient)
 {
     _itemsClient   = itemsClient;
     _clientsClient = clientsClient;
     Data           = new Data();
     GotoSearchPage();
 }
コード例 #4
0
 public ContainerViewModel(IItemsSource itemsSource, ClientsClient clientsClient)
 {
     _itemsSource   = itemsSource;
     _clientsClient = clientsClient;
     Data           = new Data {
         SearchContext = new NullSearchContext()
     };
     GotoSearchPage();
 }
コード例 #5
0
        public async Task GetProtocolMappersInTokenGenerationAsync(string realm, string clientId)
        {
            var clients = await ClientsClient.GetClientsAsync(realm);

            string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;

            if (clientsId != null)
            {
                var result = await ClientsClient.GetProtocolMappersInTokenGenerationAsync(realm, clientsId);

                Assert.NotNull(result);
            }
        }
コード例 #6
0
        public async Task GenerateClientExampleAccessTokenAsync(string realm, string clientId)
        {
            var clients = await ClientsClient.GetClientsAsync(realm);

            string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;

            if (clientsId != null)
            {
                var result = await ClientsClient.GenerateClientExampleAccessTokenAsync(realm, clientsId);

                Assert.NotNull(result);
            }
        }
コード例 #7
0
        public async Task TestClientClusterNodesAvailableAsync(string realm, string clientId)
        {
            var clients = await ClientsClient.GetClientsAsync(realm);

            string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;

            if (clientsId != null)
            {
                var result = await ClientsClient.TestClientClusterNodesAvailableAsync(realm, clientsId);

                Assert.NotNull(result);
            }
        }
コード例 #8
0
        public async Task GetClientSessionCountAsync(string realm, string clientId)
        {
            var clients = await ClientsClient.GetClientsAsync(realm);

            string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;

            if (clientsId != null)
            {
                int?result = await ClientsClient.GetClientSessionCountAsync(realm, clientsId);

                Assert.True(result >= 0);
            }
        }
コード例 #9
0
        public async Task GetClientAuthorizationPermissionsInitializedAsync(string realm, string clientId)
        {
            var clients = await ClientsClient.GetClientsAsync(realm);

            string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;

            if (clientsId != null)
            {
                var result = await ClientsClient.GetClientAuthorizationPermissionsInitializedAsync(realm, clientsId);

                Assert.NotNull(result);
            }
        }
コード例 #10
0
        public async Task GetRolesForClientAsync(string realm, string clientId)
        {
            var clients = await ClientsClient.GetClientsAsync(realm);

            string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;

            if (clientsId != null)
            {
                var result = await RolesClient.GetRolesAsync(realm, clientsId);

                Assert.NotNull(result);
            }
        }
コード例 #11
0
        public async Task GetEffectiveRealmRolesForClientScopeForClientAsync(string realm)
        {
            var clients = await ClientsClient.GetClientsAsync(realm);

            string clientId = clients.FirstOrDefault()?.Id;

            if (clientId != null)
            {
                var result = await ScopeMappingsClient.GetEffectiveRealmRolesForClientScopeForClientAsync(realm, clientId);

                Assert.NotNull(result);
            }
        }
コード例 #12
0
        public async Task GetKeyInfoAsync(string realm)
        {
            var clients = await ClientsClient.GetClientsAsync(realm);

            (string clientId, string attribute) = clients
                                                  .Where(x => x.Attributes.Any())
                                                  .Select(client => (client.Id, client.Attributes.FirstOrDefault().Key))
                                                  .FirstOrDefault();
            if (clientId != null)
            {
                var result = await ClientAttributeCertificateClient.GetKeyInfoAsync(realm, clientId, attribute);

                Assert.NotNull(result);
            }
        }
コード例 #13
0
 public Client[] LoadAllClients(TenroxIdentity identity)
 {
     if (identity == null) throw new ArgumentNullException("identity");
     return _cache.TryGetSet("Clients", () =>
     {
         BasicHttpBinding basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
         basicHttpBinding.MaxReceivedMessageSize = int.MaxValue;
         using (
             ClientsClient client = new ClientsClient(basicHttpBinding,
                 new EndpointAddress(_webServiceEndpoint))
             )
         {
             return client.QueryByAll(identity.UserToken);
         }
     });
 }
コード例 #14
0
        public async Task GetClientNotGrantedScopeMappingsAsync(string realm, string clientId)
        {
            var clients = await ClientsClient.GetClientsAsync(realm);

            string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;

            if (clientsId != null)
            {
                var result = await ClientsClient.GetClientNotGrantedScopeMappingsAsync(realm, clientsId, realm);

                Assert.NotNull(result);
                result = await ClientsClient.GetClientNotGrantedScopeMappingsAsync(realm, clientsId, clientsId);

                Assert.NotNull(result);
            }
        }
コード例 #15
0
        public async Task GetClientProviderAsync(string realm, string clientId)
        {
            var clients = await ClientsClient.GetClientsAsync(realm);

            string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;

            if (clientsId != null)
            {
                var providerInstances = await IdentityProvidersClient.GetIdentityProviderInstancesAsync(realm);

                string providerInstanceId = providerInstances.FirstOrDefault()?.ProviderId;
                if (providerInstanceId != null)
                {
                    string result = await ClientsClient.GetClientProviderAsync(realm, clientsId, providerInstanceId);

                    Assert.NotNull(result);
                }
            }
        }
コード例 #16
0
        public async Task GetAvailableClientRolesForClientScopeAsync(string realm)
        {
            var clientScopes = await ClientScopesClient.GetClientScopesAsync(realm);

            string clientScopeId = clientScopes.FirstOrDefault()?.Id;

            if (clientScopeId != null)
            {
                var clients = await ClientsClient.GetClientsAsync(realm);

                string clientId = clients.FirstOrDefault()?.Id;
                if (clientId != null)
                {
                    var result = await ScopeMappingsClient.GetAvailableClientRolesForClientScopeAsync(realm, clientScopeId, clientId);

                    Assert.NotNull(result);
                }
            }
        }
コード例 #17
0
        public async Task GetClientRolesForCompositeByIdAsync(string realm, string clientId)
        {
            var roles = await RolesClient.GetRolesAsync(realm);

            string roleId = roles.FirstOrDefault()?.Id;

            if (roleId != null)
            {
                var clients = await ClientsClient.GetClientsAsync(realm);

                string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;
                if (clientsId != null)
                {
                    var result = await RolesByIdClient.GetClientRolesForCompositeByIdAsync(realm, roleId, clientsId);

                    Assert.NotNull(result);
                }
            }
        }
コード例 #18
0
        public async Task GetAvailableClientRoleMappingsForUserAsync(string realm, string clientId)
        {
            var users = await UsersClient.GetUsersAsync(realm);

            string userId = users.FirstOrDefault()?.Id;

            if (userId != null)
            {
                var clients = await ClientsClient.GetClientsAsync(realm);

                string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;
                if (clientId != null)
                {
                    var result = await ClientRoleMappingsClient.GetAvailableClientRoleMappingsForUserAsync(realm, userId, clientsId);

                    Assert.NotNull(result);
                }
            }
        }
コード例 #19
0
        public async Task GetApplicationRolesForCompositeForClientAsync(string realm, string clientId)
        {
            var clients = await ClientsClient.GetClientsAsync(realm);

            string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;

            if (clientsId != null)
            {
                var roles = await RolesClient.GetRolesAsync(realm, clientsId);

                string roleName = roles.FirstOrDefault()?.Name;
                if (roleName != null)
                {
                    var result = await RolesClient.GetApplicationRolesForCompositeAsync(realm, clientsId, roleName, clientsId);

                    Assert.NotNull(result);
                }
            }
        }
コード例 #20
0
        public async Task GetEffectiveClientRoleMappingsForGroupAsync(string realm, string clientId)
        {
            var groups = await GroupsClient.GetGroupHierarchyAsync(realm);

            string groupId = groups.FirstOrDefault()?.Id;

            if (groupId != null)
            {
                var clients = await ClientsClient.GetClientsAsync(realm);

                string clientsId = clients.FirstOrDefault(x => x.ClientId == clientId)?.Id;
                if (clientId != null)
                {
                    var result = await ClientRoleMappingsClient.GetEffectiveClientRoleMappingsForGroupAsync(realm, groupId, clientsId);

                    Assert.NotNull(result);
                }
            }
        }
コード例 #21
0
        private ManagementApiClient(string token, Uri baseUri, DiagnosticsHeader diagnostics,
                                    ApiConnection apiConnection)
        {
            _apiConnection = apiConnection;

            BlacklistedTokens = new BlacklistedTokensClient(_apiConnection);
            ClientGrants      = new ClientGrantsClient(_apiConnection);
            Clients           = new ClientsClient(_apiConnection);
            Connections       = new ConnectionsClient(_apiConnection);
            DeviceCredentials = new DeviceCredentialsClient(_apiConnection);
            EmailProvider     = new EmailProviderClient(_apiConnection);
            EmailTemplates    = new EmailTemplatesClient(_apiConnection);
            Jobs            = new JobsClient(_apiConnection);
            Logs            = new LogsClient(_apiConnection);
            ResourceServers = new ResourceServersClient(_apiConnection);
            Rules           = new RulesClient(_apiConnection);
            Stats           = new StatsClient(_apiConnection);
            TenantSettings  = new TenantSettingsClient(_apiConnection);
            Tickets         = new TicketsClient(_apiConnection);
            UserBlocks      = new UserBlocksClient(_apiConnection);
            Users           = new UsersClient(_apiConnection);
        }
コード例 #22
0
        private ManagementApiClient(ApiConnection apiConnection)
        {
            _apiConnection = apiConnection;

            BlacklistedTokens = new BlacklistedTokensClient(_apiConnection);
            ClientGrants      = new ClientGrantsClient(_apiConnection);
            Clients           = new ClientsClient(_apiConnection);
            Connections       = new ConnectionsClient(_apiConnection);
            CustomDomains     = new CustomDomainsClient(_apiConnection);
            DeviceCredentials = new DeviceCredentialsClient(_apiConnection);
            EmailProvider     = new EmailProviderClient(_apiConnection);
            EmailTemplates    = new EmailTemplatesClient(_apiConnection);
            Guardian          = new GuardianClient(_apiConnection);
            Jobs            = new JobsClient(_apiConnection);
            Logs            = new LogsClient(_apiConnection);
            ResourceServers = new ResourceServersClient(_apiConnection);
            Roles           = new RolesClient(_apiConnection);
            Rules           = new RulesClient(_apiConnection);
            Stats           = new StatsClient(_apiConnection);
            TenantSettings  = new TenantSettingsClient(_apiConnection);
            Tickets         = new TicketsClient(_apiConnection);
            UserBlocks      = new UserBlocksClient(_apiConnection);
            Users           = new UsersClient(_apiConnection);
        }
コード例 #23
0
        public async Task GetClientsAsync(string realm)
        {
            var result = await ClientsClient.GetClientsAsync(realm);

            Assert.NotNull(result);
        }
コード例 #24
0
 public static IAsyncEnumerable <Client> GetAllAsync(this ClientsClient client, GetClientsRequest request, IReporter reporter = null)
 {
     return(GetAllAsyncInternal(page => client.GetAllAsync(request, page), "clients", reporter));
 }