annotate src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java @ 1005:0e96ce3db20a

remove HttpBuffers
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 23 Oct 2016 02:42:05 -0600
parents 21910079096e
children 945568ee77ac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 // ========================================================================
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 // ------------------------------------------------------------------------
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 // All rights reserved. This program and the accompanying materials
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 // are made available under the terms of the Eclipse Public License v1.0
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 // and Apache License v2.0 which accompanies this distribution.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 // The Eclipse Public License is available at
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 // http://www.eclipse.org/legal/epl-v10.html
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 // The Apache License v2.0 is available at
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 // http://www.opensource.org/licenses/apache2.0.php
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 // You may elect to redistribute this code under either of these licenses.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 // ========================================================================
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 package org.eclipse.jetty.server.ssl;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 import java.io.IOException;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 import java.nio.channels.SocketChannel;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 import javax.net.ssl.SSLContext;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 import javax.net.ssl.SSLEngine;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 import javax.net.ssl.SSLSession;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 import javax.net.ssl.SSLSocket;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 import org.eclipse.jetty.http.HttpSchemes;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 import org.eclipse.jetty.io.AsyncEndPoint;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 import org.eclipse.jetty.io.Buffers;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 import org.eclipse.jetty.io.Buffers.Type;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 import org.eclipse.jetty.io.EndPoint;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 import org.eclipse.jetty.io.RuntimeIOException;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 import org.eclipse.jetty.io.nio.AsyncConnection;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 import org.eclipse.jetty.io.nio.SslConnection;
952
669769bcdf5c simplify AsyncEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 893
diff changeset
37 import org.eclipse.jetty.io.nio.SelectChannelEndPoint;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 import org.eclipse.jetty.server.Request;
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
39 import org.eclipse.jetty.server.Server;
1001
Franklin Schmidt <fschmidt@gmail.com>
parents: 972
diff changeset
40 import org.eclipse.jetty.server.AbstractHttpConnection;
1003
Franklin Schmidt <fschmidt@gmail.com>
parents: 1002
diff changeset
41 import org.eclipse.jetty.server.AsyncHttpConnection;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 import org.eclipse.jetty.server.nio.SelectChannelConnector;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 import org.eclipse.jetty.util.component.AggregateLifeCycle;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 import org.eclipse.jetty.util.ssl.SslContextFactory;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 /* ------------------------------------------------------------ */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 /**
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 * SslSelectChannelConnector.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 *
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50 * @org.apache.xbean.XBean element="sslConnector" description="Creates an NIO ssl connector"
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51 */
1002
35d04ac3fd0b simplify ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 1001
diff changeset
52 public final class SslSelectChannelConnector extends SelectChannelConnector
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 {
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
54 private final SslContextFactory _sslContextFactory;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
56 /* ------------------------------------------------------------ */
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
57 public SslSelectChannelConnector(Server server,int port)
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
58 {
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
59 this(new SslContextFactory(SslContextFactory.DEFAULT_KEYSTORE_PATH),server,port);
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
60 setSoLingerTime(30000);
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
61 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
62
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
63 /* ------------------------------------------------------------ */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
64 /** Construct with explicit SslContextFactory.
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
65 * The SslContextFactory passed is added via {@link #addBean(Object)} so that
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
66 * it's lifecycle may be managed with {@link AggregateLifeCycle}.
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
67 * @param sslContextFactory
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
68 */
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
69 public SslSelectChannelConnector(SslContextFactory sslContextFactory,Server server,int port)
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
70 {
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 885
diff changeset
71 super(server,port);
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
72 _sslContextFactory = sslContextFactory;
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
73 addBean(_sslContextFactory);
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
74 setUseDirectBuffers(false);
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
75 setSoLingerTime(30000);
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
76 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
77
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
78 /* ------------------------------------------------------------ */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
79 /**
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
80 * Allow the Listener a chance to customise the request. before the server
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
81 * does its stuff. <br>
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
82 * This allows the required attributes to be set for SSL requests. <br>
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
83 * The requirements of the Servlet specs are:
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
84 * <ul>
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
85 * <li> an attribute named "javax.servlet.request.ssl_session_id" of type
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
86 * String (since Servlet Spec 3.0).</li>
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
87 * <li> an attribute named "javax.servlet.request.cipher_suite" of type
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
88 * String.</li>
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
89 * <li> an attribute named "javax.servlet.request.key_size" of type Integer.</li>
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
90 * <li> an attribute named "javax.servlet.request.X509Certificate" of type
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
91 * java.security.cert.X509Certificate[]. This is an array of objects of type
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
92 * X509Certificate, the order of this array is defined as being in ascending
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
93 * order of trust. The first certificate in the chain is the one set by the
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
94 * client, the next is the one used to authenticate the first, and so on.
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
95 * </li>
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
96 * </ul>
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
97 *
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
98 * @param endpoint
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
99 * The Socket the request arrived on.
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
100 * @param request
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
101 * HttpRequest to be customised.
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
102 */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
103 @Override
1001
Franklin Schmidt <fschmidt@gmail.com>
parents: 972
diff changeset
104 public void customize(AbstractHttpConnection con) throws IOException
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
105 {
1001
Franklin Schmidt <fschmidt@gmail.com>
parents: 972
diff changeset
106 con._request.setScheme(HttpSchemes.HTTPS);
Franklin Schmidt <fschmidt@gmail.com>
parents: 972
diff changeset
107 super.customize(con);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
108
1001
Franklin Schmidt <fschmidt@gmail.com>
parents: 972
diff changeset
109 SslConnection.SslEndPoint sslEndpoint=(SslConnection.SslEndPoint)con._endp;
Franklin Schmidt <fschmidt@gmail.com>
parents: 972
diff changeset
110 SSLEngine sslEngine = sslEndpoint.getSslEngine();
Franklin Schmidt <fschmidt@gmail.com>
parents: 972
diff changeset
111 SSLSession sslSession = sslEngine.getSession();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
112
1001
Franklin Schmidt <fschmidt@gmail.com>
parents: 972
diff changeset
113 SslCertificates.customize(sslSession,con._endp,con._request);
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
114 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
115
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
116 /* ------------------------------------------------------------ */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
117 /**
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
118 * @see org.eclipse.jetty.server.ssl.SslConnector#getSslContextFactory()
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
119 */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
120 public SslContextFactory getSslContextFactory()
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
121 {
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
122 return _sslContextFactory;
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
123 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
124
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
125 /* ------------------------------------------------------------ */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
126 /**
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
127 * By default, we're confidential, given we speak SSL. But, if we've been
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
128 * told about an confidential port, and said port is not our port, then
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
129 * we're not. This allows separation of listeners providing INTEGRAL versus
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
130 * CONFIDENTIAL constraints, such as one SSL listener configured to require
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
131 * client certs providing CONFIDENTIAL, whereas another SSL listener not
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
132 * requiring client certs providing mere INTEGRAL constraints.
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
133 */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
134 @Override
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 970
diff changeset
135 public boolean isConfidential()
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
136 {
893
d1c302afeeb6 remove _confidentialPort
Franklin Schmidt <fschmidt@gmail.com>
parents: 891
diff changeset
137 return true;
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
138 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
139
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
140 @Override
970
d82eb99e8df6 remove ConnectorSelectorManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 952
diff changeset
141 public AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint)
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
142 {
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
143 try
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
144 {
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
145 SSLEngine engine = createSSLEngine(channel);
952
669769bcdf5c simplify AsyncEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 893
diff changeset
146 SslConnection connection = new SslConnection(engine, endpoint);
1003
Franklin Schmidt <fschmidt@gmail.com>
parents: 1002
diff changeset
147 AsyncHttpConnection delegate = (AsyncHttpConnection)super.newConnection(channel, connection.getSslEndPoint());
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
148 connection.getSslEndPoint().setConnection(delegate);
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
149 connection.setAllowRenegotiate(_sslContextFactory.isAllowRenegotiate());
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
150 return connection;
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
151 }
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
152 catch (IOException e)
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
153 {
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
154 throw new RuntimeIOException(e);
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
155 }
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
156 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
157
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
158 /* ------------------------------------------------------------ */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
159 /**
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
160 * @param channel A channel which if passed is used as to extract remote
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
161 * host and port for the purposes of SSL session caching
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
162 * @return A SSLEngine for a new or cached SSL Session
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
163 * @throws IOException if the SSLEngine cannot be created
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
164 */
1002
35d04ac3fd0b simplify ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 1001
diff changeset
165 private SSLEngine createSSLEngine(SocketChannel channel) throws IOException
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
166 {
1002
35d04ac3fd0b simplify ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 1001
diff changeset
167 String peerHost = channel.socket().getInetAddress().getHostAddress();
35d04ac3fd0b simplify ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 1001
diff changeset
168 int peerPort = channel.socket().getPort();
35d04ac3fd0b simplify ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 1001
diff changeset
169 SSLEngine engine = _sslContextFactory.newSslEngine(peerHost, peerPort);
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
170 engine.setUseClientMode(false);
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
171 return engine;
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
172 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
173
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
174 /* ------------------------------------------------------------ */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
175 /**
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
176 * @see org.eclipse.jetty.server.nio.SelectChannelConnector#doStart()
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
177 */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
178 @Override
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
179 protected void doStart() throws Exception
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
180 {
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
181 _sslContextFactory.checkKeyStore();
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
182 _sslContextFactory.start();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
183
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
184 SSLEngine sslEngine = _sslContextFactory.newSslEngine();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
185
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
186 sslEngine.setUseClientMode(false);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
187
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
188 SSLSession sslSession = sslEngine.getSession();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
189
1005
0e96ce3db20a remove HttpBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
190 if (_buffers.getRequestHeaderSize()<sslSession.getApplicationBufferSize())
0e96ce3db20a remove HttpBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
191 _buffers.setRequestHeaderSize(sslSession.getApplicationBufferSize());
0e96ce3db20a remove HttpBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
192 if (_buffers.getRequestBufferSize()<sslSession.getApplicationBufferSize())
0e96ce3db20a remove HttpBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents: 1003
diff changeset
193 _buffers.setRequestBufferSize(sslSession.getApplicationBufferSize());
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
194
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
195 super.doStart();
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
196 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
197
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
198 }