Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/1980#discussion_r18493516
  
    --- Diff: core/src/main/scala/org/apache/spark/ui/JettyUtils.scala ---
    @@ -205,10 +231,74 @@ private[spark] object JettyUtils extends Logging {
         ServerInfo(server, boundPort, collection)
       }
     
    +  private def newURI(scheme: String, server: String, port: Int, path: 
String, query: String) = {
    +    val builder = new StringBuilder
    +
    +    if (server.indexOf(':') >= 0 && server.charAt(0) != '[') {
    +      
builder.append(scheme).append("://").append('[').append(server).append(']')
    +    } else {
    +      builder.append(scheme).append("://").append(server)
    +    }
    +    builder.append(':').append(port)
    +    builder.append(path)
    +    if (query != null && query.length > 0) 
builder.append('?').append(query)
    +    builder.toString
    +  }
    +
    +  private def createRedirectHttpsHandler(securePort: Int, schema: String): 
ContextHandler = {
    +    val redirectHandler: ContextHandler = new ContextHandler
    +    redirectHandler.setContextPath("/")
    +    redirectHandler.setHandler(new AbstractHandler {
    +      @Override def handle(
    +                    target: String,
    +                    baseRequest: Request,
    +                    request: HttpServletRequest,
    +                    response: HttpServletResponse): Unit = {
    +        if (baseRequest.isSecure) {
    +          return
    +        }
    +        val url = newURI(schema, baseRequest.getServerName, securePort,
    +          baseRequest.getRequestURI, baseRequest.getQueryString)
    +        response.setContentLength(0)
    +        response.sendRedirect(url)
    +        baseRequest.setHandled(true)
    +      }
    +    })
    +    redirectHandler
    +  }
    +
       /** Attach a prefix to the given path, but avoid returning an empty path 
*/
       private def attachPrefix(basePath: String, relativePath: String): String 
= {
         if (basePath == "") relativePath else (basePath + 
relativePath).stripSuffix("/")
       }
    +
    +  private def buildSslSelectChannelConnector(port: Int, conf: SparkConf): 
Connector =  {
    +    val ctxFactory = new SslContextFactory()
    +    conf.getAll
    +      .filter { case (k, v) => k.startsWith("spark.ui.ssl.") }
    +      .foreach { case (k, v) => setSslContextFactoryProps(k, v, 
ctxFactory) }
    +
    +    val connector = new SslSelectChannelConnector(ctxFactory)
    +    connector.setPort(port)
    +    connector
    +  }
    +
    +  private def setSslContextFactoryProps(
    +      key: String, value: String, ctxFactory: SslContextFactory) = {
    +    key match {
    +      case "spark.ui.ssl.client.https.needAuth" => 
ctxFactory.setNeedClientAuth(value.toBoolean)
    +      case "spark.ui.ssl.server.keystore.keypassword" => 
ctxFactory.setKeyManagerPassword(value)
    +      case "spark.ui.ssl.server.keystore.location" => 
ctxFactory.setKeyStorePath(value)
    +      case "spark.ui.ssl.server.keystore.password" => 
ctxFactory.setKeyStorePassword(value)
    +      case "spark.ui.ssl.server.keystore.type" => 
ctxFactory.setKeyStoreType(value)
    +      case "spark.ui.ssl.server.truststore.location" => 
ctxFactory.setTrustStore(value)
    +      case "spark.ui.ssl.server.truststore.password" => 
ctxFactory.setTrustStorePassword(value)
    +      case "spark.ui.ssl.server.truststore.type" => 
ctxFactory.setTrustStoreType(value)
    +    }
    +
    +    ctxFactory
    --- End diff --
    
    Not needed?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to