private bool SendIdentityProviderToApi(JObject identityProvider) { BaseRequest baseRequest = FederationLibrary.RequestIdentityProviderClient(this.stsUrl, this.apiUrl, this.clientId, this.clientSecret, new string[2] { "idmconfigapi.access", "idmconfigapi.writeidentityproviders" }); if (baseRequest.tokenResponse == null || baseRequest.tokenResponse.IsError) { return(false); } baseRequest.Create(identityProvider); baseRequest.ExecuteRequest(); if (baseRequest.HttpStatusCode == HttpStatusCode.Created) { BaseRequest.LogInfo("Identity provider created.", ConsoleColor.Green); return(true); } if (baseRequest.HttpStatusCode == HttpStatusCode.NotFound) { BaseRequest.LogError("Failed to create identity provider. Verify API URL is correct.", ConsoleColor.Red); } else { BaseRequest.LogError(string.Format("Failed to create identity provider - {0}: {1}", (object)baseRequest.HttpStatusCode, (object)baseRequest.responsePayload), ConsoleColor.Red); } return(false); }
private bool RetreiveAndStoreIdentityProviderInformation() { BaseRequest.verbose = true; BaseRequest baseRequest = FederationLibrary.RequestIdentityProviderClient(this.stsUrl, this.apiUrl, this.clientId, this.clientSecret, new string[2] { "idmconfigapi.access", "idmconfigapi.readidentityproviders" }); if (baseRequest.tokenResponse == null || baseRequest.tokenResponse.IsError) { return(false); } baseRequest.GetAll((string[])null, (string[])null); baseRequest.ExecuteRequest(); JArray jarray = JObject.Parse(baseRequest.responsePayload)["resources"].ToObject <JArray>(); JObject jobject = (JObject)null; foreach (JToken jtoken in jarray) { jobject = jtoken.ToObject <JObject>(); if (jobject["AuthenticationMode"].ToString().Equals("local", StringComparison.InvariantCultureIgnoreCase)) { break; } } Exporter.WriteToFile("identityprovider.json", new JObject() { { "Name", jobject["Name"] } }.ToString()); return(true); }