public void TestUpdateSite_oxd_http()
        {
            intializedParameter();
            var RegisterSite = new RegisterSiteClient();
            RegisterSiteResponse registerSiteResponse = RegisterSite.RegisterSite("https://127.0.0.1:8443", registerSiteParams);

            Assert.That(registerSiteResponse, Is.Not.Null);
            Assert.That(registerSiteResponse.Data.OxdId, Is.Not.Null);

            var updateSiteParams = new UpdateSiteParams();

            updateSiteParams.OxdId = registerSiteResponse.Data.OxdId;
            updateSiteParams.Scope = new List <string> {
                "openid", "profile"
            };
            updateSiteParams.Contacts = new List <string> {
                "*****@*****.**"
            };
            updateSiteParams.PostLogoutRedirectUri = "https://client.example.com/LogoutUri";

            var updateSiteRegistrationclient      = new UpdateSiteRegistrationClient();
            UpdateSiteResponse updatesiteresponse = updateSiteRegistrationclient.UpdateSiteRegistration("127.0.0.1", 8099, updateSiteParams);

            Assert.That(updatesiteresponse, Is.Not.Null);
        }
        /// <summary>
        /// Updates already registered site with input params via http
        /// </summary>
        /// <param name="oxdWebUrl">Oxd Web REST service URL</param>
        /// <param name="registerSiteParams">Input parameters for Register Site via http</param>
        /// <returns></returns>

        public UpdateSiteResponse UpdateSiteRegistration(string oxdWebUrl, UpdateSiteParams registerSiteParams)
        {
            Logger.Info("Verifying input parameters.");
            if (string.IsNullOrEmpty(oxdWebUrl))
            {
                throw new ArgumentNullException("Oxd Rest Service URL should not be NULL.");
            }


            try
            {
                var cmdUpdateSite = new Command {
                    CommandType = RestCommandType.update_site_registration, CommandParams = registerSiteParams
                };
                var    commandClient   = new CommandClient(oxdWebUrl);
                string commandResponse = commandClient.send(cmdUpdateSite);
                var    response        = JsonConvert.DeserializeObject <UpdateSiteResponse>(commandResponse);
                return(response);
            }
            catch (Exception ex)
            {
                Logger.Log(NLog.LogLevel.Error, ex, "Exception when updating Client Info.");
                return(null);
            }
        }
Beispiel #3
0
        public ActionResult Update(OxdModel oxd)
        {
            Loadoxdsettings();

            string updateStatus = "ok";

            if (dynamic_registration)
            {
                var updateSiteInputParams = new UpdateSiteParams();
                var updateSiteClient      = new UpdateSiteRegistrationClient();

                updateSiteInputParams.AuthorizationRedirectUri = oxd.RedirectUrl;
                updateSiteInputParams.PostLogoutRedirectUri    = oxd.PostLogoutRedirectUrl;
                updateSiteInputParams.ClientName = oxd.ClientName;

                updateSiteInputParams.OxdId    = oxd.OxdId;
                updateSiteInputParams.Contacts = new List <string> {
                    oxd.OxdEmail
                };
                updateSiteInputParams.PostLogoutRedirectUri = oxd.PostLogoutRedirectUrl;
                updateSiteInputParams.GrantTypes            = grant_types;
                //updateSiteInputParams.Scope = scope;


                var updateSiteResponse = new UpdateSiteResponse();

                //Update Client using  OXD Local
                if (oxd.ConnectionType == "local")
                {
                    //Get ProtectionAccessToken
                    updateSiteInputParams.ProtectionAccessToken = GetProtectionAccessToken(oxdHost, oxd.OxdPort);
                    // Update Site response
                    updateSiteResponse = updateSiteClient.UpdateSiteRegistration(oxdHost, oxd.OxdPort, updateSiteInputParams);
                }

                //Update Client using OXD Web
                if (oxd.ConnectionType == "web")
                {
                    updateSiteInputParams.ProtectionAccessToken = GetProtectionAccessToken(oxd.HttpRestUrl);
                    updateSiteResponse = updateSiteClient.UpdateSiteRegistration(oxd.HttpRestUrl, updateSiteInputParams);
                }


                updateStatus = updateSiteResponse.Status;
            }

            Updateoxdsettingfile(oxd);


            //Process Response
            return(Json(new { status = updateStatus }));
        }
        /// <summary>
        /// Updates already registered site with input params.
        /// </summary>
        /// <param name="host">Oxd Host</param>
        /// <param name="port">Oxd Port</param>
        /// <param name="updateSiteParams">Input params for Update Site Registration command</param>
        /// <returns></returns>
        public UpdateSiteResponse UpdateSiteRegistration(string host, int port, UpdateSiteParams updateSiteParams)
        {
            Logger.Info("Verifying input parameters.");
            if (string.IsNullOrEmpty(host))
            {
                throw new ArgumentNullException("Oxd Host should not be NULL.");
            }

            if (port <= 0)
            {
                throw new ArgumentNullException("Oxd Port should be a valid port number.");
            }

            if (updateSiteParams == null)
            {
                throw new ArgumentNullException("The update site command params should not be NULL.");
            }

            if (string.IsNullOrEmpty(updateSiteParams.OxdId))
            {
                throw new MissingFieldException("Oxd ID is required for updating site.");
            }

            try
            {
                Logger.Info("Preparing and sending command.");
                var cmdUpdateSite = new Command {
                    CommandType = CommandType.update_site_registration, CommandParams = updateSiteParams
                };
                var    commandClient   = new CommandClient(host, port);
                string commandResponse = commandClient.send(cmdUpdateSite);

                var response = JsonConvert.DeserializeObject <UpdateSiteResponse>(commandResponse);
                Logger.Info(string.Format("Got response status as {0}", response.Status));

                return(response);
            }
            catch (Exception ex)
            {
                Logger.Log(NLog.LogLevel.Error, ex, "Exception when updating site.");
                return(null);
            }
        }