code: public String constructLocalLoginServiceUrl(final HttpServletRequest request,
        final HttpServletResponse response, final String service, final String serverName,
        final String artifactParameterName, final boolean encode) {
      if (Strings.isNotBlank(service)) return encode ? response.encodeURL(service) : service;
      final StringBuilder buffer = new StringBuilder();
  
      if (!serverName.startsWith("https://") && !serverName.startsWith("http://")) {
        buffer.append(request.isSecure() ? "https://" : "http://");
      }
      buffer.append(serverName);
      buffer.append(request.getContextPath());
      buffer.append(localLogin);
      final String returnValue = encode ? response.encodeURL(buffer.toString()) : buffer.toString();
      return returnValue;
    }
docs: Construct local login Service Url
  
  @param request
  @param response
  @param service
  @param serverName
  @param artifactParameterName
  @param encode