Mercurial Hosting > luan
annotate src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java @ 1011:4e7208df7741
remove PooledBuffers
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 23 Oct 2016 23:59:08 -0600 |
parents | 945568ee77ac |
children | 4dc1e1a18661 |
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; |
1011
4e7208df7741
remove PooledBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1007
diff
changeset
|
31 import org.eclipse.jetty.io.Buffer; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
32 import org.eclipse.jetty.io.Buffers; |
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; |
1011
4e7208df7741
remove PooledBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1007
diff
changeset
|
38 import org.eclipse.jetty.io.nio.IndirectNIOBuffer; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
39 import org.eclipse.jetty.server.Request; |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
885
diff
changeset
|
40 import org.eclipse.jetty.server.Server; |
1001 | 41 import org.eclipse.jetty.server.AbstractHttpConnection; |
1003 | 42 import org.eclipse.jetty.server.AsyncHttpConnection; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
43 import org.eclipse.jetty.server.nio.SelectChannelConnector; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
44 import org.eclipse.jetty.util.component.AggregateLifeCycle; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
45 import org.eclipse.jetty.util.ssl.SslContextFactory; |
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 /** |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
49 * SslSelectChannelConnector. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
50 * |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
51 * @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
|
52 */ |
1002 | 53 public final class SslSelectChannelConnector extends SelectChannelConnector |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
54 { |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
55 private final SslContextFactory _sslContextFactory; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
56 |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
57 /* ------------------------------------------------------------ */ |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
885
diff
changeset
|
58 public SslSelectChannelConnector(Server server,int port) |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
59 { |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
885
diff
changeset
|
60 this(new SslContextFactory(SslContextFactory.DEFAULT_KEYSTORE_PATH),server,port); |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
61 setSoLingerTime(30000); |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
62 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
63 |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
64 /* ------------------------------------------------------------ */ |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
65 /** Construct with explicit SslContextFactory. |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
66 * The SslContextFactory passed is added via {@link #addBean(Object)} so that |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
67 * it's lifecycle may be managed with {@link AggregateLifeCycle}. |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
68 * @param sslContextFactory |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
69 */ |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
885
diff
changeset
|
70 public SslSelectChannelConnector(SslContextFactory sslContextFactory,Server server,int port) |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
71 { |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
885
diff
changeset
|
72 super(server,port); |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
73 _sslContextFactory = sslContextFactory; |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
74 addBean(_sslContextFactory); |
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 |
1011
4e7208df7741
remove PooledBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1007
diff
changeset
|
78 @Override |
4e7208df7741
remove PooledBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1007
diff
changeset
|
79 protected Buffer newBuffer(int size) { |
4e7208df7741
remove PooledBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1007
diff
changeset
|
80 return new IndirectNIOBuffer(size); |
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 |
4e7208df7741
remove PooledBuffers
Franklin Schmidt <fschmidt@gmail.com>
parents:
1007
diff
changeset
|
83 |
872
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 /** |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
86 * Allow the Listener a chance to customise the request. before the server |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
87 * does its stuff. <br> |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
88 * This allows the required attributes to be set for SSL requests. <br> |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
89 * The requirements of the Servlet specs are: |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
90 * <ul> |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
91 * <li> an attribute named "javax.servlet.request.ssl_session_id" of type |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
92 * String (since Servlet Spec 3.0).</li> |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
93 * <li> an attribute named "javax.servlet.request.cipher_suite" of type |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
94 * String.</li> |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
95 * <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
|
96 * <li> an attribute named "javax.servlet.request.X509Certificate" of type |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
97 * java.security.cert.X509Certificate[]. This is an array of objects of type |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
98 * X509Certificate, the order of this array is defined as being in ascending |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
99 * 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
|
100 * 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
|
101 * </li> |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
102 * </ul> |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
103 * |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
104 * @param endpoint |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
105 * The Socket the request arrived on. |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
106 * @param request |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
107 * HttpRequest to be customised. |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
108 */ |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
109 @Override |
1001 | 110 public void customize(AbstractHttpConnection con) throws IOException |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
111 { |
1001 | 112 con._request.setScheme(HttpSchemes.HTTPS); |
113 super.customize(con); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
114 |
1001 | 115 SslConnection.SslEndPoint sslEndpoint=(SslConnection.SslEndPoint)con._endp; |
116 SSLEngine sslEngine = sslEndpoint.getSslEngine(); | |
117 SSLSession sslSession = sslEngine.getSession(); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
118 |
1001 | 119 SslCertificates.customize(sslSession,con._endp,con._request); |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
120 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
121 |
872
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 /** |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
124 * @see org.eclipse.jetty.server.ssl.SslConnector#getSslContextFactory() |
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 public SslContextFactory getSslContextFactory() |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
127 { |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
128 return _sslContextFactory; |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
129 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
130 |
872
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 /** |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
133 * 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
|
134 * 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
|
135 * we're not. This allows separation of listeners providing INTEGRAL versus |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
136 * CONFIDENTIAL constraints, such as one SSL listener configured to require |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
137 * client certs providing CONFIDENTIAL, whereas another SSL listener not |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
138 * requiring client certs providing mere INTEGRAL constraints. |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
139 */ |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
140 @Override |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
970
diff
changeset
|
141 public boolean isConfidential() |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
142 { |
893
d1c302afeeb6
remove _confidentialPort
Franklin Schmidt <fschmidt@gmail.com>
parents:
891
diff
changeset
|
143 return true; |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
144 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
145 |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
146 @Override |
970
d82eb99e8df6
remove ConnectorSelectorManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
952
diff
changeset
|
147 public AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint) |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
148 { |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
149 try |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
150 { |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
151 SSLEngine engine = createSSLEngine(channel); |
952
669769bcdf5c
simplify AsyncEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
893
diff
changeset
|
152 SslConnection connection = new SslConnection(engine, endpoint); |
1003 | 153 AsyncHttpConnection delegate = (AsyncHttpConnection)super.newConnection(channel, connection.getSslEndPoint()); |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
154 connection.getSslEndPoint().setConnection(delegate); |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
155 connection.setAllowRenegotiate(_sslContextFactory.isAllowRenegotiate()); |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
156 return connection; |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
157 } |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
158 catch (IOException e) |
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 throw new RuntimeIOException(e); |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
161 } |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
162 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
163 |
872
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 /** |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
166 * @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
|
167 * host and port for the purposes of SSL session caching |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
168 * @return A SSLEngine for a new or cached SSL Session |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
169 * @throws IOException if the SSLEngine cannot be created |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
170 */ |
1002 | 171 private SSLEngine createSSLEngine(SocketChannel channel) throws IOException |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
172 { |
1002 | 173 String peerHost = channel.socket().getInetAddress().getHostAddress(); |
174 int peerPort = channel.socket().getPort(); | |
175 SSLEngine engine = _sslContextFactory.newSslEngine(peerHost, peerPort); | |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
176 engine.setUseClientMode(false); |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
177 return engine; |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
178 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
179 |
872
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 /** |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
182 * @see org.eclipse.jetty.server.nio.SelectChannelConnector#doStart() |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
183 */ |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
184 @Override |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
185 protected void doStart() throws Exception |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
186 { |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
187 _sslContextFactory.checkKeyStore(); |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
188 _sslContextFactory.start(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
189 |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
190 SSLEngine sslEngine = _sslContextFactory.newSslEngine(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
191 |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
192 sslEngine.setUseClientMode(false); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
193 |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
194 SSLSession sslSession = sslEngine.getSession(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
195 |
1007
945568ee77ac
remove HttpBuffersImpl
Franklin Schmidt <fschmidt@gmail.com>
parents:
1005
diff
changeset
|
196 if (_requestHeaderSize < sslSession.getApplicationBufferSize()) |
945568ee77ac
remove HttpBuffersImpl
Franklin Schmidt <fschmidt@gmail.com>
parents:
1005
diff
changeset
|
197 _requestHeaderSize = sslSession.getApplicationBufferSize(); |
945568ee77ac
remove HttpBuffersImpl
Franklin Schmidt <fschmidt@gmail.com>
parents:
1005
diff
changeset
|
198 if (_requestBufferSize < sslSession.getApplicationBufferSize()) |
945568ee77ac
remove HttpBuffersImpl
Franklin Schmidt <fschmidt@gmail.com>
parents:
1005
diff
changeset
|
199 _requestBufferSize = sslSession.getApplicationBufferSize(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
200 |
872
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
201 super.doStart(); |
1c0b6841cd32
remove SocketEndPoint
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
202 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
203 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
204 } |