public object Get(string id)
        {
            SslSettingId settingId = new SslSettingId(id);

            // Ssl settings cannot be configured at server level
            if (settingId.SiteId == null)
            {
                return(NotFound());
            }

            Site site = SiteHelper.GetSite(settingId.SiteId.Value);

            return(SslSettingsHelper.ToJsonModel(site, settingId.Path));
        }
        public object Get()
        {
            Site   site = ApplicationHelper.ResolveSite();
            string path = ApplicationHelper.ResolvePath();

            // Ssl settings cannot be configured at server level
            if (site == null)
            {
                return(NotFound());
            }

            dynamic d = SslSettingsHelper.ToJsonModel(site, path);

            return(LocationChanged(SslSettingsHelper.GetLocation(d.id), d));
        }
        public void Delete(string id)
        {
            SslSettingId settingId = new SslSettingId(id);

            Context.Response.StatusCode = (int)HttpStatusCode.NoContent;

            Site site = (settingId.SiteId != null) ? SiteHelper.GetSite(settingId.SiteId.Value) : null;

            if (site == null)
            {
                return;
            }

            SslSettingsHelper.GetAccessSection(site, settingId.Path, ManagementUnit.ResolveConfigScope()).RevertToParent();

            ManagementUnit.Current.Commit();
        }
        public object Patch(string id, [FromBody] dynamic model)
        {
            SslSettingId settingsId = new SslSettingId(id);

            Site site = settingsId.SiteId == null ? null : SiteHelper.GetSite(settingsId.SiteId.Value);

            // Targetting section for a site, but unable to find that site
            if (settingsId.SiteId != null && site == null)
            {
                return(NotFound());
            }

            string configPath = model == null ? null : ManagementUnit.ResolveConfigScope(model);

            SslSettingsHelper.UpdateSettings(model, site, settingsId.Path, configPath);

            ManagementUnit.Current.Commit();

            return(SslSettingsHelper.ToJsonModel(site, settingsId.Path));
        }
예제 #5
0
        public override void Start()
        {
            Environment.Host.RouteBuilder.MapWebApiRoute(Defines.Resource.Guid, $"{Defines.PATH}/{{id?}}", new { controller = "SslSettings" });

            // Self
            Environment.Hal.ProvideLink(Defines.Resource.Guid, "self", settings => new { href = SslSettingsHelper.GetLocation(settings.id) });

            // Site
            Environment.Hal.ProvideLink(Sites.Defines.Resource.Guid, Defines.Resource.Name, site => {
                var siteId = new SiteId((string)site.id);
                Site s     = SiteHelper.GetSite(siteId.Id);
                var id     = new SslSettingId(siteId.Id, "/", SslSettingsHelper.IsSectionLocal(s, "/"));
                return(new { href = SslSettingsHelper.GetLocation(id.Uuid) });
            });

            // Application
            Environment.Hal.ProvideLink(Applications.Defines.Resource.Guid, Defines.Resource.Name, app => {
                var appId = new ApplicationId((string)app.id);
                Site s    = SiteHelper.GetSite(appId.SiteId);
                var id    = new SslSettingId(appId.SiteId, appId.Path, SslSettingsHelper.IsSectionLocal(s, appId.Path));
                return(new { href = SslSettingsHelper.GetLocation(id.Uuid) });
            });
        }