/// <summary> /// Write oxd settings into json file /// </summary> /// <param name="oxd">oxd models</param> /// <param name="setupClientResponse">oxd setup client response from oxd server</param> public void SetConfigValues(OxdModel oxd, SetupClientResponse setupClientResponse) { string configObjString = System.IO.File.ReadAllText(Server.MapPath(@ConfigurationManager.AppSettings["oxd_config"])); OxdSetting oxdsettings = JsonConvert.DeserializeObject <OxdSetting>(configObjString); oxdsettings.AuthUrl = oxd.RedirectUrl; oxdsettings.OpHost = oxd.OpHost; oxdsettings.PostLogoutRedirectUrl = oxd.PostLogoutRedirectUrl; oxdsettings.ClientName = oxd.ClientName; oxdsettings.ConnectionType = oxd.ConnectionType; oxdsettings.OxdId = setupClientResponse.Data.OxdId; oxdsettings.ClientId = setupClientResponse.Data.clientId; oxdsettings.ClientSecret = setupClientResponse.Data.clientSecret; if (oxd.ConnectionType == "local") { oxdsettings.OxdPort = oxd.OxdPort; } else if (oxd.ConnectionType == "web") { oxdsettings.HttpRestUrl = oxd.HttpRestUrl; } oxdsettings.DynamicRegistration = (isDynamicRegistration(oxd.OpHost) == true) ? true : false; string updatejsonstring = Newtonsoft.Json.JsonConvert.SerializeObject(oxdsettings, Newtonsoft.Json.Formatting.None); System.IO.File.WriteAllText(Server.MapPath(@ConfigurationManager.AppSettings["oxd_config"]), updatejsonstring); }
public ActionResult SetupClient(OxdModel oxd) { Loadoxdsettings(); var setupClientInputParams = new SetupClientParams(); var registerSiteClient = new SetupClientClient(); //prepare input params for Setup client setupClientInputParams.AuthorizationRedirectUri = oxd.RedirectUrl; setupClientInputParams.OpHost = oxd.OpHost; setupClientInputParams.PostLogoutRedirectUri = oxd.PostLogoutRedirectUrl; setupClientInputParams.ClientName = oxd.ClientName; setupClientInputParams.Scope = scope; setupClientInputParams.GrantTypes = grant_types; // setupClientInputParams.ClientId = oxd.ClientId; // setupClientInputParams.ClientSecret = oxd.ClientSecret; var setupClientResponse = new SetupClientResponse(); if (string.IsNullOrEmpty(oxd.OxdId)) { //Setup Client using OXD Local if (oxd.ConnectionType == "local") { setupClientResponse = registerSiteClient.SetupClient(oxdHost, oxd.OxdPort, setupClientInputParams); } //Setup Client using OXD Web if (oxd.ConnectionType == "web") { setupClientResponse = registerSiteClient.SetupClient(oxd.HttpRestUrl, setupClientInputParams); } SetConfigValues(oxd, setupClientResponse); return(Json(new { oxdId = setupClientResponse.Data.OxdId, clientId = setupClientResponse.Data.clientId, clientSecret = setupClientResponse.Data.clientSecret })); } else { return(Json(new { oxdId = oxd.OxdId, clientId = clientid, clientSecret = clientsecret })); } }