code: public String getRedirectUrlFromServerToClient(String clientId, String contextPath, String redirectToRPHostAndPort) {
          String redirectURL = null;
          if (redirectToRPHostAndPort != null && redirectToRPHostAndPort.length() > 0) {
              try {
                  final String fHostPort = redirectToRPHostAndPort;
                  @SuppressWarnings({ "unchecked", "rawtypes" })
                  URL url = (URL) java.security.AccessController.doPrivileged(new java.security.PrivilegedExceptionAction() {
                      @Override
                      public Object run() throws Exception {
                          return new URL(fHostPort);
                      }
                  });
                  int port = url.getPort();
                  String path = url.getPath();
                  if (path == null)
                      path = "";
                  if (path.endsWith("/")) {
                      path = path.substring(0, path.length() - 1);
                  }
                  String entryPoint = path + contextPath + "/redirect/" + clientId;
                  redirectURL = url.getProtocol() + "://" + url.getHost() + (port > 0 ? ":" + port : "");
  
                  redirectURL = redirectURL + (entryPoint.startsWith("/") ? "" : "/") + entryPoint;
              } catch (Exception e) {
                  if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                      Tr.debug(tc, "the value of redirectToRPHostAndPort might not valid. Please verify that the format is <protocol>://<host>:<port> " + redirectToRPHostAndPort
                              + "\n" + e.getMessage());
                  }
              }
          }
          return redirectURL;
      }
docs: moved from oidcconfigimpl so social can use it.