Exemple #1
0
        public static async Task MainInstancePrincipal()
        {
            // expose the tenancyId for the environment variable OCI_COMPARTMENT_ID
            string tenantId = Environment.GetEnvironmentVariable("OCI_COMPARTMENT_ID");

            // Creates an Instance Principal provider that holds authentication details of the OCI Instance
            // This helps in making API requests by the Instance without user involvement
            var instanceProvider = new InstancePrincipalsAuthenticationDetailsProvider();

            // Create a client for the service to enable using its APIs
            var client = new IdentityClient(instanceProvider, new ClientConfiguration());

            try
            {
                await ListOciRegions(client);
                await ListOciRegionSubscriptions(client, tenantId);
            }
            catch (Exception e)
            {
                logger.Info($"Received exception due to {e.Message}");
            }
            finally
            {
                client.Dispose();
            }
        }
Exemple #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            ClientConfig clientConfig = new ClientConfig
            {
                TenancyId            = TenantIdBox.Text,
                UserId               = UserIdBox.Text,
                Fingerprint          = FingerBox.Text,
                PrivateKey           = KeyPathBox.Text,
                PrivateKeyPassphrase = PassPhraseBox.Text
            };

            string           caption        = "SuccessFull";
            string           messageBoxText = "OCI Connected.";
            MessageBoxButton button         = MessageBoxButton.OK;
            MessageBoxImage  icon           = MessageBoxImage.Information;

            var identityClient = new IdentityClient(clientConfig);

            try
            {
                var root = identityClient.GetTenancy(new OCISDK.Identity.Request.GetTenancyRequest {
                    TenancyId = clientConfig.TenancyId
                });
            }
            catch (Exception ex)
            {
                messageBoxText = ex.Message;
                caption        = "failed.";
                button         = MessageBoxButton.OK;
                icon           = MessageBoxImage.Error;
            }

            System.Windows.MessageBox.Show(messageBoxText, caption, button, icon);
        }
Exemple #3
0
        internal static IIdentityService CreateService(TestCredentials credentials, bool logRequests = true)
        {
            if (credentials == null)
            {
                throw new ArgumentNullException("credentials");
            }

            IdentityClient client;

            switch (credentials.Vendor)
            {
            case "HP":
                // currently HP does not have a vendor-specific IIdentityService
                goto default;

            case "Rackspace":
                client = new RackspaceIdentityClient(credentials.BaseAddress);
                break;

            case "OpenStack":
            default:
                client = new IdentityClient(credentials.BaseAddress);
                break;
            }

            TestProxy.ConfigureService(client, credentials.Proxy);
            if (logRequests)
            {
                client.BeforeAsyncWebRequest += TestHelpers.HandleBeforeAsyncWebRequest;
                client.AfterAsyncWebResponse += TestHelpers.HandleAfterAsyncWebResponse;
            }

            return(client);
        }
        public List <IdentityClient> ShowAllItems()
        {
            sql = "SELECT * FROM identity";
            List <IdentityClient> idnClients = new List <IdentityClient>();
            var Identities = search();

            foreach (Identity identity in Identities)
            {
                IdentityClient idntClient = new IdentityClient();
                idntClient.ID              = identity.ID;
                idntClient.BusinessPlanId  = identity.BusinessPlanId;
                idntClient.Name            = identity.Name;
                idntClient.Date            = identity.Date;
                idntClient.LegalForm       = identity.LegalForm;
                idntClient.OrderOfBusiness = identity.OrderOfBusiness;
                idnClients.Add(idntClient);
            }
            sql = "SELECT * FROM identity_clients";
            List <Client> clients = new List <Client>();

            clients.AddRange(searchClients());
            foreach (IdentityClient idntClient in idnClients)
            {
                foreach (Client client in clients)
                {
                    if (idntClient.ID == client.IdentityId)
                    {
                        idntClient.Clients.Add(client);
                    }
                }
            }
            return(idnClients);
        }
Exemple #5
0
        protected IIdentityService CreateService(IAuthenticationService authenticationService, bool logRequests = true)
        {
            IdentityClient client;

            switch (Vendor)
            {
            case "HP":
                // currently HP does not have a vendor-specific IIdentityService
                goto default;

            case "Rackspace":
                client = new RackspaceIdentityClient(authenticationService, BaseAddress);
                break;

            case "OpenStack":
            default:
                client = new IdentityClient(authenticationService, BaseAddress);
                break;
            }

            TestProxy.ConfigureService(client, Proxy);
            if (logRequests)
            {
                client.BeforeAsyncWebRequest += TestHelpers.HandleBeforeAsyncWebRequest;
                client.AfterAsyncWebResponse += TestHelpers.HandleAfterAsyncWebResponse;
            }

            return(client);
        }
Exemple #6
0
        public static async Task MainRegionAndRealm()
        {
            // Accepts profile name and creates a auth provider based on config file
            var provider = new ConfigFileAuthenticationDetailsProvider(OciConfigProfileName);
            // Create a client for the service to enable using its APIs
            var client = new IdentityClient(provider, new ClientConfiguration());

            // Assume a new region us-foo-1 is launched in OC2 realm
            // Register the new region
            var fooRegion = Region.Register("us-foo-1", Realm.OC2);

            // If the config file contains a value for region, then it will be picked up automatically by the SDK,
            // else set it up manually by calling setRegion
            logger.Info($"Setting region to {fooRegion.RegionId}");
            client.SetRegion(fooRegion);

            // Use the client to make calls to the endpoint for the new region
            await ListAllRegions(client);

            // Now, assume a new region us-bar-1 is launched in OCX realm
            // (having secondLevelDomain oracle-baz-cloud.com)
            // Register the new region and realm
            var barRegion = Region.Register("us-bar-1", Realm.Register("ocx", "oracle-baz-cloud.com"));

            // Call setRegion to use the endpoint in the new region
            logger.Info($"Setting region to {barRegion.RegionId}");
            client.SetRegion(barRegion);

            // Use the client to make calls to the endpoint for the new region
            await ListAllRegions(client);
        }
Exemple #7
0
        /**
         * This method demonstrates how to do pagination yourself by manually managing the next page
         * tokens returned by service responses
         *
         * @param identityClient the client used to make service calls
         * @param compartmentId the OCID of the compartment we'll issue the ListUsers request against. This should be your tenancy OCID
         */
        private static async Task DoManualPagination(IdentityClient identityClient, string compartmentId)
        {
            logger.Info("Manual Pagination");
            logger.Info("==================");

            string            nextPageToken     = null;
            ListUsersRequest  listUsersRequest  = null;
            ListUsersResponse listUsersResponse = null;

            do
            {
                listUsersRequest = new ListUsersRequest
                {
                    CompartmentId = compartmentId,
                    Page          = nextPageToken
                };
                listUsersResponse = await identityClient.ListUsers(listUsersRequest);

                foreach (User user in listUsersResponse.Items)
                {
                    logger.Info($"user: {user.Name}");
                }
                nextPageToken = listUsersResponse.OpcNextPage;
            } while (nextPageToken != null);

            logger.Info("\n\n");
        }
        public async Task SUBMIT_FILE_TEST()
        {
            var LoginResposne = await IdentityClient.LoginAsync(USER_EMAIL, USER_KEY).ConfigureAwait(false);

            var authToken = LoginResposne.Token;

            var Balance = await APIClient.CreditBalanceAsync(authToken).ConfigureAwait(false);

            var scanId = await SubmitFileScanAsync(authToken).ConfigureAwait(false);

            var progress = await Policy.HandleResult <uint>((result) => result != 100)
                           .WaitAndRetryAsync(6, retryAttempt => TimeSpan.FromSeconds(3))
                           .ExecuteAsync(() => APIClient.ProgressAsync(scanId, authToken)).ConfigureAwait(false);

            Assert.IsTrue(progress == 100, "Scan Progress didn't hit the 100%");

            //downloads
            var pdfReport = await APIClient.DownloadPdfReportAsync(scanId, authToken).ConfigureAwait(false);

            var sources = await APIClient.DownloadSourceReportAsync(scanId, authToken).ConfigureAwait(false);

            var results = await APIClient.ResultAsync(scanId, authToken).ConfigureAwait(false);

            //sandbox scan always have at least one internet result.
            var downloadedResult = await APIClient.DownloadResultAsync(scanId, results.Results.Internet[0].Id, authToken).ConfigureAwait(false);

            await APIClient.DeleteAsync(new DeleteRequest
            {
                Scans = new DeleteScanItem[] { new DeleteScanItem {
                                                   Id = scanId
                                               } },
                Purge = true
            }, authToken).ConfigureAwait(false);
        }
Exemple #9
0
    public async Task GivenDirectoryEntry_WhenRoundTrip_Success()
    {
        const string issuer = "*****@*****.**";

        IdentityClient client = TestApplication.GetIdentityClient();

        var documentId = new DocumentId("test/unit-tests-identity/identity1");

        var query = new QueryParameter()
        {
            Filter    = "test/unit-tests-identity",
            Recursive = false,
        };

        await client.Delete(documentId);

        var request = new IdentityEntryRequest
        {
            DirectoryId = (string)documentId,
            Issuer      = issuer
        };

        bool success = await client.Create(request);

        success.Should().BeTrue();

        IdentityEntry?entry = await client.Get(documentId);

        entry.Should().NotBeNull();

        await client.Delete(documentId);
    }
        public static async Task MainCompartment()
        {
            logger.Info("Starting example");
            // Create Identity Client
            var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");
            var client   = new IdentityClient(provider, new ClientConfiguration());

            logger.Info("IdentityClient created");

            try
            {
                var    compartmentId       = Environment.GetEnvironmentVariable("OCI_COMPARTMENT_ID");
                string sourceCompartmentId = await CreateCompartment(client, compartmentId, "source");

                string targetCompartmentId = await CreateCompartment(client, compartmentId, "target");
                await MoveCompartment(client, sourceCompartmentId, targetCompartmentId);
            }
            catch (Exception e)
            {
                logger.Error($"Failed to move compartments: {e}");
            }
            finally
            {
                client.Dispose();
            }
        }
Exemple #11
0
        public IActionResult OnGet(int?talk_id)
        {
            if (talk_id == null)
            {
                return(NotFound());
            }

            Talk = ApiClient.GetTalkResponseAsync(talk_id.Value).Result;

            if (Talk == null)
            {
                return(NotFound());
            }

            if (IdentityClient.GetUserOwnershipAsync(new UserOwnership {
                UserId = User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier).Value, ConferenceId = ApiClient.GetConferenceFromTalkID(Talk.ID).Result
            }).Result == null)
            {
                return(base.NotFound());
            }

            personList = Talk.ParsePersonsString;

            return(Page());
        }
        private static async Task DisplayAudit(
            AuditClientAsync client, IdentityClient identityClinet,
            Compartment compartment, string startDate, string endDate,
            string requestId = "", string pageId = "")
        {
            // get Audit Events
            var listEventsRequest = new ListEventsRequest()
            {
                CompartmentId = compartment.Id,
                StartTime     = startDate,
                EndTime       = endDate,
                Page          = pageId
            };

            var events = await client.ListEvents(listEventsRequest);

            if (!string.IsNullOrEmpty(events.OpcNextPage))
            {
                await DisplayAudit(client, identityClinet, compartment, startDate, endDate, events.OpcRequestId, events.OpcNextPage);
            }

            if (events.Items.Count > 0)
            {
                Count += events.Items.Count;
                Console.WriteLine($"enventset: com={compartment.Name}, start={startDate}, end={endDate}, events.Items:{events.Items.Count}");
            }
        }
Exemple #13
0
        public async Task <IActionResult> OnGetAsync(int?session_id)
        {
            if (session_id == null)
            {
                return(NotFound());
            }

            SessionResponse = ApiClient.GetSessionResponseAsync(session_id.Value).Result;

            if (SessionResponse == null)
            {
                return(NotFound());
            }

            conference = ApiClient.GetConferenceAsync(SessionResponse.ConferenceID).Result;

            if (conference == null)
            {
                return(NotFound());
            }

            if (IdentityClient.GetUserOwnershipAsync(new UserOwnership {
                UserId = User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier).Value, ConferenceId = conference.ID
            }).Result == null)
            {
                return(base.NotFound());
            }


            return(Page());
        }
Exemple #14
0
        private IdentityClient BuildIdentityClient(Row row)
        {
            if (row == null)
            {
                return(null);
            }

            IdentityClient identityClient = new IdentityClient
            {
                ClientId             = row.GetValue <string>(IdentityClientConstant.COLUMNS_CLIENT_ID),
                ClientDescription    = row.GetValue <string>(IdentityClientConstant.COLUMNS_CLIENT_DESCRIPTION),
                TimeLife             = row.GetValue <int>(IdentityClientConstant.COLUMNS_TIME_LIFE),
                GrantTypes           = row.GetValue <ICollection <string> >(IdentityClientConstant.COLUMNS_GRANT_TYPES),
                RequireClientSecret  = row.GetValue <bool>(IdentityClientConstant.COLUMNS_REQUIRE_CLIENT_SECRET),
                ClientSecret         = row.GetValue <string>(IdentityClientConstant.COLUMNS_CLIENT_SECRET),
                AllowAccessInBrowser = row.GetValue <bool>(IdentityClientConstant.COLUMNS_ALLOW_ACCESS_IN_BROWSER),
                Scopes                 = row.GetValue <ICollection <string> >(IdentityClientConstant.COLUMNS_SCOPES),
                RedirectUris           = row.GetValue <ICollection <string> >(IdentityClientConstant.COLUMNS_REDIRECT_URIS),
                PostLogoutRedirectUris = row.GetValue <ICollection <string> >(IdentityClientConstant.COLUMNS_POST_LOGOUT_REDIRECT_URIS),
                Authority              = row.GetValue <ICollection <string> >(IdentityClientConstant.COLUMNS_AUTHORITY),
                AllowOfflineAccess     = row.GetValue <bool>(IdentityClientConstant.COLUMNS_ALLOW_OFFLINE_ACCESS),
                Claims                 = row.GetValue <ICollection <IdentityClaim> >(IdentityClientConstant.COLUMNS_CLAIMS)
            };

            return(identityClient);
        }
        public async Task USER_USAGE_TEST()
        {
            var LoginResposne = await IdentityClient.LoginAsync(USER_EMAIL, USER_KEY).ConfigureAwait(false);

            var authToken = LoginResposne.Token;

            DateTime start = new DateTime(2020, 3, 11);

            start.ToString("dd-MM-yyyy");
            DateTime end = new DateTime(2020, 3, 15);

            end.ToString("dd-MM-yyyy");

            using (var stream = new MemoryStream())
            {
                await APIClient.GetUserUsageAsync(start, end, stream, authToken).ConfigureAwait(false);

                using (var sr = new StreamReader(stream))
                {
                    stream.Seek(0, SeekOrigin.Begin);
                    var csv = await sr.ReadToEndAsync();

                    Console.WriteLine(csv);
                }
            }
        }
Exemple #16
0
        public static void ConsoleDisplay(ClientConfig config)
        {
            var identityClient = new IdentityClient(config)
            {
                Region = Regions.US_ASHBURN_1
            };

            LoadOciUsers(identityClient);

            Console.WriteLine("* Users------------------------");
            var listUsersRequest = new ListUsersRequest()
            {
                CompartmentId = config.TenancyId
            };

            var users = identityClient.ListUsers(listUsersRequest).Items;

            foreach (var user in users)
            {
                Console.WriteLine($" |-{user.Name}");
                Console.WriteLine($" | providerId: {user.IdentityProviderId}");
                Console.WriteLine($" | inactiveStatus: {user.InactiveStatus}");
                Console.WriteLine($" | lifecycleState: {user.LifecycleState}");
                Console.WriteLine($" | mfaActivated: {user.IsMfaActivated}");
                Console.WriteLine($" | timeCreated: {user.TimeCreated}");
            }
        }
Exemple #17
0
        public static async Task MainPagination()
        {
            string compartmentId = Environment.GetEnvironmentVariable("OCI_COMPARTMENT_ID");

            logger.Info("Starting Pagination example");

            // Accepts profile name and creates a auth provider based on config file
            var provider = new ConfigFileAuthenticationDetailsProvider(OciConfigProfileName);
            // Create a client for the service to enable using its APIs
            var identityClient = new IdentityClient(provider, new ClientConfiguration());

            try
            {
                await DoManualPagination(identityClient, compartmentId);

                DoPaginateWithResponsePaginator(identityClient, compartmentId);
                DoPaginateWithRecordPaginator(identityClient, compartmentId);
            }
            catch (Exception e)
            {
                logger.Info($"Received exception due to {e.Message}");
            }
            finally
            {
                logger.Info("ending Pagination example");
                identityClient.Dispose();
            }
        }
Exemple #18
0
 protected override void ProcessRecord()
 {
     base.ProcessRecord();
     try
     {
         client?.Dispose();
         int timeout = GetPreferredTimeout();
         WriteDebug($"Cmdlet Timeout : {timeout} milliseconds.");
         client = new IdentityClient(AuthProvider, new Oci.Common.ClientConfiguration
         {
             RetryConfiguration = retryConfig,
             TimeoutMillis      = timeout,
             ClientUserAgent    = PSUserAgent
         });
         string region = GetPreferredRegion();
         if (region != null)
         {
             WriteDebug("Choosing Region:" + region);
             client.SetRegion(region);
         }
         if (Endpoint != null)
         {
             WriteDebug("Choosing Endpoint:" + Endpoint);
             client.SetEndpoint(Endpoint);
         }
     }
     catch (Exception ex)
     {
         TerminatingErrorDuringExecution(ex);
     }
 }
        private static async Task ListOciRegions(IdentityClient client)
        {
            // Create a Retry configuration to override defaults
            RetryConfiguration retryConfiguration = new RetryConfiguration
            {
                // Enable exponential backoff.
                GetNextDelayInSeconds = DelayStrategy.GetExponentialDelayInSeconds,
                //  Defines total duration in seconds for which the retry attempts.
                TotalElapsedTimeInSecs = 600,
                // Defines the total number of retry attempts.
                MaxAttempts = 4,
                // Retryable status code family. This will make the SDK retry for all 5xx.
                RetryableStatusCodeFamilies = new List <int>(new int[] { 5 }),
                // Retrying on certain HTTP Status Ccode and Error code combo.
                RetryableErrors = new Collection <Tuple <int, string> >(new Tuple <int, string>[] {
                    new Tuple <int, string>(409, "IncorrectState"),
                    new Tuple <int, string>(429, "TooManyRequests")
                })
            };
            // List regions
            var listRegionsRequest = new ListRegionsRequest();
            ListRegionsResponse listRegionsResponse = await client.ListRegions(listRegionsRequest, retryConfiguration);

            logger.Info("List Regions");
            logger.Info("=============");
            foreach (Oci.IdentityService.Models.Region reg in listRegionsResponse.Items)
            {
                logger.Info($"{reg.Key} : {reg.Name}");
            }
        }
        public static async Task MainRetry()
        {
            string compartmentId = Environment.GetEnvironmentVariable("OCI_COMPARTMENT_ID");

            // Configuring the AuthenticationDetailsProvider. It's assuming there is a default OCI config file
            // "~/.oci/config", and a profile in that config with the name OciConfigProfileName . Make changes to the following
            // line if needed and use ConfigFileAuthenticationDetailsProvider(configurationFilePath, profile);
            var provider = new ConfigFileAuthenticationDetailsProvider(OciConfigProfileName);
            // Create a client for the service to enable using its APIs
            var client = new IdentityClient(provider, new ClientConfiguration());

            try
            {
                await ListOciRegions(client);
                await ListOciRegionSubscriptions(client, compartmentId);
            }
            catch (Exception e)
            {
                logger.Info($"Received exception due to {e.Message}");
            }
            finally
            {
                client.Dispose();
            }
        }
Exemple #21
0
 public Application(ILoggerFactory loggerFactory, IdentityClient identityClient, SqsClient sqsClient, IServiceProvider serviceProvider)
 {
     _logger          = loggerFactory.CreateLogger(nameof(Application));
     _identityClient  = identityClient;
     _sqsClient       = sqsClient;
     _serviceProvider = serviceProvider;
 }
Exemple #22
0
        /**
         * Remove all resources created by the 'setup' operation.
         *
         * NB: Resources can only be removed 30 minutes after the last Function
         * invocation.
         *
         * @param provider      the OCI credentials provider.
         * @param region        the OCI region in which to create the required
         *                      resources.
         * @param compartmentId the compartment in which to created the required
         *                      resources.
         * @param name          a name prefix to easily identify the resources.
         */
        private static async Task TearDownResources(IBasicAuthenticationDetailsProvider provider, string compartmentId)
        {
            var identityClient     = new IdentityClient(provider);
            var vcnClient          = new VirtualNetworkClient(provider);
            var fnManagementClient = new FunctionsManagementClient(provider);

            try
            {
                logger.Info("Cleaning up....");

                var vcn = await GetUniqueVcnByName(vcnClient, compartmentId);

                var ig = await GetUniqueInternetGatewayByName(vcnClient, compartmentId, vcn.Id);

                var rt = await GetUniqueRouteTableByName(vcnClient, compartmentId, vcn.Id);

                var subnet = await GetUniqueSubnetByName(vcnClient, compartmentId, vcn.Id);

                var application = await GetUniqueApplicationByName(fnManagementClient, compartmentId);

                var fn = await GetUniqueFunctionByName(fnManagementClient, application.Id, FunctionName);

                if (fn != null)
                {
                    await DeleteFunction(fnManagementClient, fn.Id);
                }

                if (application != null)
                {
                    await DeleteApplication(fnManagementClient, application.Id);
                }

                if (ig != null)
                {
                    await ClearRouteRulesFromDefaultRouteTable(vcnClient, vcn.DefaultRouteTableId);
                    await DeleteInternetGateway(vcnClient, ig.Id);
                }

                if (subnet != null)
                {
                    await DeleteSubnet(vcnClient, subnet);
                }

                if (vcn != null)
                {
                    await DeleteVcn(vcnClient, vcn);
                }
            }
            catch (Exception e)
            {
                logger.Error($"Failed to clean the resources: {e}");
            }
            finally
            {
                fnManagementClient.Dispose();
                vcnClient.Dispose();
                identityClient.Dispose();
            }
        }
Exemple #23
0
        protected async Task <bool> HandleTokenStateAsync()
        {
            if (_nextAuthAttempt.HasValue && DateTime.UtcNow > _nextAuthAttempt.Value)
            {
                return(false);
            }
            _nextAuthAttempt = null;

            if (!string.IsNullOrWhiteSpace(AccessToken) && !TokenNeedsRefresh())
            {
                return(true);
            }

            var requestMessage = new HttpRequestMessage
            {
                Method     = HttpMethod.Post,
                RequestUri = new Uri(string.Concat(IdentityClient.BaseAddress, "connect/token")),
                Content    = new FormUrlEncodedContent(new Dictionary <string, string>
                {
                    { "grant_type", "client_credentials" },
                    { "scope", _identityScope },
                    { "client_id", _identityClientId },
                    { "client_secret", _identityClientSecret }
                })
            };

            HttpResponseMessage response = null;

            try
            {
                response = await IdentityClient.SendAsync(requestMessage);
            }
            catch (Exception e)
            {
                _logger.LogError(12339, e, "Unable to authenticate with identity server.");
            }

            if (response == null)
            {
                return(false);
            }

            if (!response.IsSuccessStatusCode)
            {
                if (response.StatusCode == HttpStatusCode.BadRequest)
                {
                    _nextAuthAttempt = DateTime.UtcNow.AddDays(1);
                }

                return(false);
            }

            var responseContent = await response.Content.ReadAsStringAsync();

            dynamic tokenResponse = JsonConvert.DeserializeObject(responseContent);

            AccessToken = (string)tokenResponse.access_token;
            return(true);
        }
Exemple #24
0
        public void should_return_configured_client()
        {
            var a = new IdentityClient("my-app-id", "https://accounts-staging.appson.ir");

            Assert.IsNotNull(a);
            Assert.IsTrue(a.Configuration.Address.Equals("https://accounts-staging.appson.ir", StringComparison.InvariantCultureIgnoreCase));
            Assert.IsTrue(a.Configuration.ApplicationId.Equals("my-app-id", StringComparison.InvariantCultureIgnoreCase));
        }
Exemple #25
0
 public static IdentityServer3.Core.Models.Client ToModel(this IdentityClient s)
 {
     if (s == null)
     {
         return(null);
     }
     return(Mapper.Map <IdentityClient, IdentityServer3.Core.Models.Client>(s));
 }
Exemple #26
0
 public AuthService(HttpClient httpClient, AuthenticationStateProvider authenticationStateProvider,
                    IdentityClient identityClient, ILocalStorageService localStorage)
 {
     _httpClient = httpClient;
     _authenticationStateProvider = authenticationStateProvider;
     _identityClient = identityClient;
     _localStorage   = localStorage;
 }
 public static Core.Models.Client ToModel(this IdentityClient s)
 {
     if (s == null)
     {
         return(null);
     }
     return(Config.CreateMapper().Map <IdentityClient, IdentityServer3.Core.Models.Client>(s));
 }
 public IdentityService(IdentityClient identityClient, IHttpContextAccessor httpContextAccessor,
                        IOptions <TokenValidationOptions> optionsAccessor)
 {
     IdentityClient = identityClient;
     //HttpContextAccessor = httpContextAccessor;
     TokenValidationOptions = optionsAccessor.Value;
     HttpContext            = httpContextAccessor.HttpContext;
     Client = IdentityClient.Client;
 }
Exemple #29
0
 public async Task <IHttpActionResult> Put(Guid Applicationid, [FromBody] IdentityClient model)
 {
     if (model.Applicationid != Applicationid)
     {
         return(BadRequest("Resource Applicationid's do not match."));
     }
     model.AppendTransactionContext(Request);
     return(await Save(model));
 }
        private static async Task QueryAuthenticationPolicy(string tenantId, IdentityClient client)
        {
            var getAuthenticationPolicyRequest = new GetAuthenticationPolicyRequest
            {
                CompartmentId = tenantId
            };
            var response = await client.GetAuthenticationPolicy(getAuthenticationPolicyRequest);

            logger.Info($"Minimum password length of Authentication Policy is {response.AuthenticationPolicy.PasswordPolicy.MinimumPasswordLength}");
        }
        internal static IIdentityService CreateService(TestCredentials credentials, bool logRequests = true)
        {
            if (credentials == null)
                throw new ArgumentNullException("credentials");

            IdentityClient client;
            switch (credentials.Vendor)
            {
            case "HP":
                // currently HP does not have a vendor-specific IIdentityService
                goto default;

            case "Rackspace":
                client = new RackspaceIdentityClient(credentials.BaseAddress);
                break;

            case "OpenStack":
            default:
                client = new IdentityClient(credentials.BaseAddress);
                break;
            }

            TestProxy.ConfigureService(client, credentials.Proxy);
            if (logRequests)
            {
                client.BeforeAsyncWebRequest += TestHelpers.HandleBeforeAsyncWebRequest;
                client.AfterAsyncWebResponse += TestHelpers.HandleAfterAsyncWebResponse;
            }

            return client;
        }
        protected IIdentityService CreateService(IAuthenticationService authenticationService, bool logRequests = true)
        {
            IdentityClient client;
            switch (Vendor)
            {
            case "HP":
                // currently HP does not have a vendor-specific IIdentityService
                goto default;

            case "Rackspace":
                client = new RackspaceIdentityClient(authenticationService, BaseAddress);
                break;

            case "OpenStack":
            default:
                client = new IdentityClient(authenticationService, BaseAddress);
                break;
            }

            TestProxy.ConfigureService(client, Proxy);
            if (logRequests)
            {
                client.BeforeAsyncWebRequest += TestHelpers.HandleBeforeAsyncWebRequest;
                client.AfterAsyncWebResponse += TestHelpers.HandleAfterAsyncWebResponse;
            }

            return client;
        }