You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by sebb <se...@gmail.com> on 2014/06/25 17:02:36 UTC

Re: svn commit: r1605338 - in /httpcomponents/httpcore/trunk: httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/ httpcore/src/main/java/org/apache/http/impl/bootstrap/

On 25 June 2014 12:16,  <ol...@apache.org> wrote:
> Author: olegk
> Date: Wed Jun 25 11:16:00 2014
> New Revision: 1605338
>
> URL: http://svn.apache.org/r1605338
> Log:
> Added SSL server setup handler
>
> Added:
>     httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/SSLServerSetupHandler.java   (with props)
> Modified:
>     httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLSetupHandler.java
>     httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/HttpServer.java
>     httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/ServerBootstrap.java
>
> Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLSetupHandler.java
> URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLSetupHandler.java?rev=1605338&r1=1605337&r2=1605338&view=diff
> ==============================================================================
> --- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLSetupHandler.java (original)
> +++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLSetupHandler.java Wed Jun 25 11:16:00 2014
> @@ -49,6 +49,7 @@ public interface SSLSetupHandler {
>       * @param sslengine the SSL engine.
>       * @throws SSLException if case of SSL protocol error.
>       */
> +    //FIXME: fix type
>      void initalize(SSLEngine sslengine) throws SSLException;
>
>      /**
>
> Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/HttpServer.java
> URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/HttpServer.java?rev=1605338&r1=1605337&r2=1605338&view=diff
> ==============================================================================
> --- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/HttpServer.java (original)
> +++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/HttpServer.java Wed Jun 25 11:16:00 2014
> @@ -36,6 +36,7 @@ import java.util.concurrent.TimeUnit;
>  import java.util.concurrent.atomic.AtomicReference;
>
>  import javax.net.ServerSocketFactory;
> +import javax.net.ssl.SSLServerSocket;
>
>  import org.apache.http.ExceptionLogger;
>  import org.apache.http.HttpConnectionFactory;
> @@ -57,6 +58,7 @@ public class HttpServer {
>      private final ServerSocketFactory serverSocketFactory;
>      private final HttpService httpService;
>      private final HttpConnectionFactory<? extends DefaultBHttpServerConnection> connectionFactory;
> +    private final SSLServerSetupHandler sslSetupHandler;
>      private final ExceptionLogger exceptionLogger;
>      private final ExecutorService listenerExecutorService;
>      private final ThreadGroup workerThreads;
> @@ -73,6 +75,7 @@ public class HttpServer {
>              final ServerSocketFactory serverSocketFactory,
>              final HttpService httpService,
>              final HttpConnectionFactory<? extends DefaultBHttpServerConnection> connectionFactory,
> +            final SSLServerSetupHandler sslSetupHandler,
>              final ExceptionLogger exceptionLogger) {
>          this.port = port;
>          this.ifAddress = ifAddress;
> @@ -80,6 +83,7 @@ public class HttpServer {
>          this.serverSocketFactory = serverSocketFactory;
>          this.httpService = httpService;
>          this.connectionFactory = connectionFactory;
> +        this.sslSetupHandler = sslSetupHandler;
>          this.exceptionLogger = exceptionLogger;
>          this.listenerExecutorService = Executors.newSingleThreadExecutor(
>                  new ThreadFactoryImpl("HTTP-listener-" + this.port));
> @@ -115,6 +119,9 @@ public class HttpServer {
>              if (this.socketConfig.getRcvBufSize() > 0) {
>                  this.serverSocket.setReceiveBufferSize(this.socketConfig.getRcvBufSize());
>              }
> +            if (this.sslSetupHandler != null && this.serverSocket instanceof SSLServerSocket) {
> +                this.sslSetupHandler.initialize((SSLServerSocket) this.serverSocket);
> +            }
>              this.requestListener = new RequestListener(
>                      this.socketConfig,
>                      this.serverSocket,
>
> Added: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/SSLServerSetupHandler.java
> URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/SSLServerSetupHandler.java?rev=1605338&view=auto
> ==============================================================================
> --- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/SSLServerSetupHandler.java (added)
> +++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/SSLServerSetupHandler.java Wed Jun 25 11:16:00 2014
> @@ -0,0 +1,45 @@
> +/*
> + * ====================================================================
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements.  See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership.  The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License.  You may obtain a copy of the License at
> + *
> + *   http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied.  See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + * ====================================================================
> + *
> + * This software consists of voluntary contributions made by many
> + * individuals on behalf of the Apache Software Foundation.  For more
> + * information on the Apache Software Foundation, please see
> + * <http://www.apache.org/>.
> + *
> + */
> +package org.apache.http.impl.bootstrap;
> +
> +import javax.net.ssl.SSLException;
> +import javax.net.ssl.SSLServerSocket;
> +
> +/**
> + * Server SSL setup handler. Custom implementations of this interface can be used to
> + * configure various SSL protocol aspects such as supported protocol versions, cypher suites,
> + * and mandatory / optional client authentication.
> + *
> + * @see javax.net.ssl.SSLServerSocket
> + * @see javax.net.ssl.SSLSession
> + * @since 4.4
> + */
> +public interface SSLServerSetupHandler {
> +
> +    void initialize(SSLServerSocket socket) throws SSLException;
> +
> +}
>
> Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/SSLServerSetupHandler.java
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
> Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/SSLServerSetupHandler.java
> ------------------------------------------------------------------------------
>     svn:keywords = Date Revision
>
> Propchange: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/SSLServerSetupHandler.java
> ------------------------------------------------------------------------------
>     svn:mime-type = text/plain
>
> Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/ServerBootstrap.java
> URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/ServerBootstrap.java?rev=1605338&r1=1605337&r2=1605338&view=diff
> ==============================================================================
> --- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/ServerBootstrap.java (original)
> +++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/bootstrap/ServerBootstrap.java Wed Jun 25 11:16:00 2014
> @@ -80,6 +80,7 @@ public class ServerBootstrap {
>      private HttpExpectationVerifier expectationVerifier;
>      private ServerSocketFactory serverSocketFactory;
>      private SSLContext sslContext;
> +    private SSLServerSetupHandler sslSetupHandler;
>      private HttpConnectionFactory<? extends DefaultBHttpServerConnection> connectionFactory;
>      private ExceptionLogger exceptionLogger;
>
> @@ -275,6 +276,14 @@ public class ServerBootstrap {
>      }
>
>      /**
> +     * Assigns {@link org.apache.http.impl.bootstrap.SSLServerSetupHandler} instance.

@since marker?

> +     */
> +    public final ServerBootstrap setSslSetupHandler(final SSLServerSetupHandler sslSetupHandler) {
> +        this.sslSetupHandler = sslSetupHandler;
> +        return this;
> +    }
> +
> +    /**
>       * Assigns {@link javax.net.ServerSocketFactory} instance.
>       */
>      public final ServerBootstrap setServerSocketFactory(final ServerSocketFactory serverSocketFactory) {
> @@ -396,6 +405,7 @@ public class ServerBootstrap {
>                  serverSocketFactoryCopy,
>                  httpService,
>                  connectionFactoryCopy,
> +                this.sslSetupHandler,
>                  exceptionLoggerCopy);
>      }
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org