docs: private CmsResource handleSecureResource(
          CmsObject cms,
          HttpServletRequest req,
          HttpServletResponse res,
          CmsResource resource,
          String resourceName)
      throws CmsException, CmsVfsResourceNotFoundException {
  
          // check online project
          if (cms.getRequestContext().getCurrentProject().isOnlineProject() && (res != null)) {
              boolean secure = false;
              try {
                  // check if resource is secure
                  secure = Boolean.valueOf(
                      cms.readPropertyObject(
                          cms.getSitePath(resource),
                          CmsPropertyDefinition.PROPERTY_SECURE,
                          true).getValue()).booleanValue();
              } catch (CmsVfsResourceNotFoundException e) {
                  LOG.warn(e.getLocalizedMessage(), e);
              } catch (CmsException e) {
                  LOG.error(e.getLocalizedMessage(), e);
              }
              if (secure) {
                  CmsResource resource1 = resource;
                  // resource is secure, check site config
                  CmsSite site = OpenCms.getSiteManager().getCurrentSite(cms);
                  // check the secure url
                  String secureUrl = null;
                  try {
                      secureUrl = site.getSecureUrl();
                  } catch (Exception e) {
                      LOG.error(
                          Messages.get().getBundle().key(Messages.ERR_SECURE_SITE_NOT_CONFIGURED_1, resourceName),
                          e);
                      throw new CmsException(
                          Messages.get().container(Messages.ERR_SECURE_SITE_NOT_CONFIGURED_1, resourceName),
                          e);
                  }
                  boolean usingSec = true;
                  if (req != null) {
                      usingSec = req.getRequestURL().toString().toUpperCase().startsWith(secureUrl.toUpperCase());
                  }
                  if (site.isExclusiveUrl() && !usingSec) {
                      resource1 = null;
                      // secure resource without secure protocol, check error config
                      if (site.isExclusiveError()) {
                          // trigger 404 error
                          throw new CmsVfsResourceNotFoundException(
                              Messages.get().container(Messages.ERR_REQUEST_SECURE_RESOURCE_0));
                      } else {
                          // redirect
                          String target = OpenCms.getLinkManager().getOnlineLink(cms, resourceName);
                          if (!target.toLowerCase().startsWith(secureUrl.toLowerCase())) {
                              Optional<String> targetWithReplacedHost = CmsStringUtil.replacePrefix(
                                  target,
                                  site.getSiteMatcher().getUrl(),
                                  secureUrl,
                                  true);
                              if (targetWithReplacedHost.isPresent()) {
                                  target = targetWithReplacedHost.get();
                              }
                              if (!target.toLowerCase().startsWith(secureUrl.toLowerCase())) {
                                  LOG.warn("Failed to generate secure URL for " + target + ", site = " + site);
                              }
                          }
  
                          try {
                              if (site.usesPermanentRedirects()) {
                                  res.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
                                  res.setHeader("Location", target);
                              } else {
                                  res.sendRedirect(target);
                              }
                          } catch (Exception e) {
                              // ignore, but should never happen
                              LOG.error("Error sending secure resource redirect.", e);
                          }
                      }
                  }
                  resource = resource1;
              }
  
          }
          return resource;
      }