annotate src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java @ 1039:a7319f14ba1e

remove Buffer.isImmutable()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 03 Nov 2016 22:55:28 -0600
parents 4dc1e1a18661
children a8c92b0a08ed
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.io.AsyncEndPoint;
1011
4e7208df7741 remove PooledBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents: 1007
diff changeset
30 import org.eclipse.jetty.io.Buffer;
802
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.EndPoint;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 import org.eclipse.jetty.io.RuntimeIOException;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 import org.eclipse.jetty.io.nio.AsyncConnection;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 import org.eclipse.jetty.io.nio.SslConnection;
952
669769bcdf5c simplify AsyncEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 893
diff changeset
36 import org.eclipse.jetty.io.nio.SelectChannelEndPoint;
1011
4e7208df7741 remove PooledBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents: 1007
diff changeset
37 import org.eclipse.jetty.io.nio.IndirectNIOBuffer;
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 setSoLingerTime(30000);
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
75 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
76
1011
4e7208df7741 remove PooledBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents: 1007
diff changeset
77 @Override
4e7208df7741 remove PooledBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents: 1007
diff changeset
78 protected Buffer newBuffer(int size) {
4e7208df7741 remove PooledBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents: 1007
diff changeset
79 return new IndirectNIOBuffer(size);
4e7208df7741 remove PooledBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents: 1007
diff changeset
80 }
4e7208df7741 remove PooledBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents: 1007
diff changeset
81
4e7208df7741 remove PooledBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents: 1007
diff changeset
82
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
83 /* ------------------------------------------------------------ */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
84 /**
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
85 * Allow the Listener a chance to customise the request. before the server
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
86 * does its stuff. <br>
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
87 * This allows the required attributes to be set for SSL requests. <br>
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
88 * The requirements of the Servlet specs are:
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
89 * <ul>
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
90 * <li> an attribute named "javax.servlet.request.ssl_session_id" of type
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
91 * String (since Servlet Spec 3.0).</li>
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
92 * <li> an attribute named "javax.servlet.request.cipher_suite" of type
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
93 * String.</li>
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
94 * <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
95 * <li> an attribute named "javax.servlet.request.X509Certificate" of type
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
96 * java.security.cert.X509Certificate[]. This is an array of objects of type
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
97 * X509Certificate, the order of this array is defined as being in ascending
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
98 * 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
99 * 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
100 * </li>
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
101 * </ul>
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 * @param endpoint
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
104 * The Socket the request arrived on.
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
105 * @param request
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
106 * HttpRequest to be customised.
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
107 */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
108 @Override
1001
Franklin Schmidt <fschmidt@gmail.com>
parents: 972
diff changeset
109 public void customize(AbstractHttpConnection con) throws IOException
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
110 {
1018
4dc1e1a18661 remove HttpSchemes
Franklin Schmidt <fschmidt@gmail.com>
parents: 1011
diff changeset
111 con._request.setScheme("https");
1001
Franklin Schmidt <fschmidt@gmail.com>
parents: 972
diff changeset
112 super.customize(con);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
113
1001
Franklin Schmidt <fschmidt@gmail.com>
parents: 972
diff changeset
114 SslConnection.SslEndPoint sslEndpoint=(SslConnection.SslEndPoint)con._endp;
Franklin Schmidt <fschmidt@gmail.com>
parents: 972
diff changeset
115 SSLEngine sslEngine = sslEndpoint.getSslEngine();
Franklin Schmidt <fschmidt@gmail.com>
parents: 972
diff changeset
116 SSLSession sslSession = sslEngine.getSession();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
117
1001
Franklin Schmidt <fschmidt@gmail.com>
parents: 972
diff changeset
118 SslCertificates.customize(sslSession,con._endp,con._request);
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
119 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
120
872
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 /**
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
123 * @see org.eclipse.jetty.server.ssl.SslConnector#getSslContextFactory()
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
124 */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
125 public SslContextFactory getSslContextFactory()
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 return _sslContextFactory;
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
128 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
129
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
130 /* ------------------------------------------------------------ */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
131 /**
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
132 * 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
133 * 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
134 * we're not. This allows separation of listeners providing INTEGRAL versus
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
135 * CONFIDENTIAL constraints, such as one SSL listener configured to require
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
136 * client certs providing CONFIDENTIAL, whereas another SSL listener not
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
137 * requiring client certs providing mere INTEGRAL constraints.
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
138 */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
139 @Override
972
5ee36654b383 simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents: 970
diff changeset
140 public boolean isConfidential()
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
141 {
893
d1c302afeeb6 remove _confidentialPort
Franklin Schmidt <fschmidt@gmail.com>
parents: 891
diff changeset
142 return true;
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
143 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
144
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
145 @Override
970
d82eb99e8df6 remove ConnectorSelectorManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 952
diff changeset
146 public AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint)
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
147 {
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
148 try
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
149 {
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
150 SSLEngine engine = createSSLEngine(channel);
952
669769bcdf5c simplify AsyncEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 893
diff changeset
151 SslConnection connection = new SslConnection(engine, endpoint);
1003
Franklin Schmidt <fschmidt@gmail.com>
parents: 1002
diff changeset
152 AsyncHttpConnection delegate = (AsyncHttpConnection)super.newConnection(channel, connection.getSslEndPoint());
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
153 connection.getSslEndPoint().setConnection(delegate);
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
154 connection.setAllowRenegotiate(_sslContextFactory.isAllowRenegotiate());
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
155 return connection;
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
156 }
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
157 catch (IOException e)
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 throw new RuntimeIOException(e);
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
160 }
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
161 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
162
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
163 /* ------------------------------------------------------------ */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
164 /**
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
165 * @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
166 * host and port for the purposes of SSL session caching
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
167 * @return A SSLEngine for a new or cached SSL Session
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
168 * @throws IOException if the SSLEngine cannot be created
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
169 */
1002
35d04ac3fd0b simplify ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 1001
diff changeset
170 private SSLEngine createSSLEngine(SocketChannel channel) throws IOException
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
171 {
1002
35d04ac3fd0b simplify ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 1001
diff changeset
172 String peerHost = channel.socket().getInetAddress().getHostAddress();
35d04ac3fd0b simplify ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 1001
diff changeset
173 int peerPort = channel.socket().getPort();
35d04ac3fd0b simplify ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 1001
diff changeset
174 SSLEngine engine = _sslContextFactory.newSslEngine(peerHost, peerPort);
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
175 engine.setUseClientMode(false);
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
176 return engine;
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
177 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
178
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
179 /* ------------------------------------------------------------ */
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 * @see org.eclipse.jetty.server.nio.SelectChannelConnector#doStart()
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
182 */
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
183 @Override
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
184 protected void doStart() throws Exception
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
185 {
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
186 _sslContextFactory.checkKeyStore();
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
187 _sslContextFactory.start();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
188
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
189 SSLEngine sslEngine = _sslContextFactory.newSslEngine();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
190
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
191 sslEngine.setUseClientMode(false);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
192
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
193 SSLSession sslSession = sslEngine.getSession();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
194
1007
945568ee77ac remove HttpBuffersImpl
Franklin Schmidt <fschmidt@gmail.com>
parents: 1005
diff changeset
195 if (_requestHeaderSize < sslSession.getApplicationBufferSize())
945568ee77ac remove HttpBuffersImpl
Franklin Schmidt <fschmidt@gmail.com>
parents: 1005
diff changeset
196 _requestHeaderSize = sslSession.getApplicationBufferSize();
945568ee77ac remove HttpBuffersImpl
Franklin Schmidt <fschmidt@gmail.com>
parents: 1005
diff changeset
197 if (_requestBufferSize < sslSession.getApplicationBufferSize())
945568ee77ac remove HttpBuffersImpl
Franklin Schmidt <fschmidt@gmail.com>
parents: 1005
diff changeset
198 _requestBufferSize = sslSession.getApplicationBufferSize();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
199
872
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
200 super.doStart();
1c0b6841cd32 remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
201 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
202
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
203 }