Mercurial Hosting > luan
annotate src/org/eclipse/jetty/io/nio/SslConnection.java @ 944:1d24b6e422fa
simplify SelectorManager
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 11 Oct 2016 20:16:03 -0600 |
parents | b77d631b9e28 |
children | 89fe80dfab2c |
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.io.nio; |
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.ByteBuffer; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
23 import java.util.concurrent.atomic.AtomicBoolean; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
24 import javax.net.ssl.SSLEngine; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
25 import javax.net.ssl.SSLEngineResult; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
26 import javax.net.ssl.SSLEngineResult.HandshakeStatus; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
27 import javax.net.ssl.SSLException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
28 import javax.net.ssl.SSLSession; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
29 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
30 import org.eclipse.jetty.io.AbstractConnection; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
31 import org.eclipse.jetty.io.AsyncEndPoint; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
32 import org.eclipse.jetty.io.Buffer; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
33 import org.eclipse.jetty.io.Connection; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
34 import org.eclipse.jetty.io.EndPoint; |
820
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
35 import org.slf4j.Logger; |
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
36 import org.slf4j.LoggerFactory; |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
37 |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
38 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
39 /* ------------------------------------------------------------ */ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
40 /** SSL Connection. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
41 * An AysyncConnection that acts as an interceptor between and EndPoint and another |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
42 * Connection, that implements TLS encryption using an {@link SSLEngine}. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
43 * <p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
44 * The connector uses an {@link AsyncEndPoint} (like {@link SelectChannelEndPoint}) as |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
45 * it's source/sink of encrypted data. It then provides {@link #getSslEndPoint()} to |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
46 * expose a source/sink of unencrypted data to another connection (eg HttpConnection). |
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 public class SslConnection extends AbstractConnection implements AsyncConnection |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
49 { |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
50 private final Logger _logger = LoggerFactory.getLogger("org.eclipse.jetty.io.nio.ssl"); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
51 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
52 private static final NIOBuffer __ZERO_BUFFER=new IndirectNIOBuffer(0); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
53 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
54 private static final ThreadLocal<SslBuffers> __buffers = new ThreadLocal<SslBuffers>(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
55 private final SSLEngine _engine; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
56 private final SSLSession _session; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
57 private AsyncConnection _connection; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
58 private final SslEndPoint _sslEndPoint; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
59 private int _allocations; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
60 private SslBuffers _buffers; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
61 private NIOBuffer _inbound; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
62 private NIOBuffer _unwrapBuf; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
63 private NIOBuffer _outbound; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
64 private AsyncEndPoint _aEndp; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
65 private boolean _allowRenegotiate=true; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
66 private boolean _handshook; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
67 private boolean _ishut; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
68 private boolean _oshut; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
69 private final AtomicBoolean _progressed = new AtomicBoolean(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
70 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
71 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
72 /* this is a half baked buffer pool |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
73 */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
74 private static class SslBuffers |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
75 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
76 final NIOBuffer _in; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
77 final NIOBuffer _out; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
78 final NIOBuffer _unwrap; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
79 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
80 SslBuffers(int packetSize, int appSize) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
81 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
82 _in=new IndirectNIOBuffer(packetSize); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
83 _out=new IndirectNIOBuffer(packetSize); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
84 _unwrap=new IndirectNIOBuffer(appSize); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
85 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
86 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
87 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
88 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
89 public SslConnection(SSLEngine engine,EndPoint endp) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
90 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
91 this(engine,endp,System.currentTimeMillis()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
92 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
93 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
94 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
95 public SslConnection(SSLEngine engine,EndPoint endp, long timeStamp) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
96 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
97 super(endp,timeStamp); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
98 _engine=engine; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
99 _session=_engine.getSession(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
100 _aEndp=(AsyncEndPoint)endp; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
101 _sslEndPoint = newSslEndPoint(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
102 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
103 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
104 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
105 protected SslEndPoint newSslEndPoint() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
106 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
107 return new SslEndPoint(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
108 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
109 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
110 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
111 /** |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
112 * @return True if SSL re-negotiation is allowed (default false) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
113 */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
114 public boolean isAllowRenegotiate() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
115 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
116 return _allowRenegotiate; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
117 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
118 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
119 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
120 /** |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
121 * Set if SSL re-negotiation is allowed. CVE-2009-3555 discovered |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
122 * a vulnerability in SSL/TLS with re-negotiation. If your JVM |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
123 * does not have CVE-2009-3555 fixed, then re-negotiation should |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
124 * not be allowed. CVE-2009-3555 was fixed in Sun java 1.6 with a ban |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
125 * of renegotiates in u19 and with RFC5746 in u22. |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
126 * |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
127 * @param allowRenegotiate |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
128 * true if re-negotiation is allowed (default false) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
129 */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
130 public void setAllowRenegotiate(boolean allowRenegotiate) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
131 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
132 _allowRenegotiate = allowRenegotiate; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
133 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
134 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
135 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
136 private void allocateBuffers() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
137 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
138 synchronized (this) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
139 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
140 if (_allocations++==0) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
141 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
142 if (_buffers==null) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
143 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
144 _buffers=__buffers.get(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
145 if (_buffers==null) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
146 _buffers=new SslBuffers(_session.getPacketBufferSize()*2,_session.getApplicationBufferSize()*2); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
147 _inbound=_buffers._in; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
148 _outbound=_buffers._out; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
149 _unwrapBuf=_buffers._unwrap; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
150 __buffers.set(null); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
151 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
152 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
153 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
154 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
155 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
156 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
157 private void releaseBuffers() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
158 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
159 synchronized (this) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
160 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
161 if (--_allocations==0) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
162 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
163 if (_buffers!=null && |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
164 _inbound.length()==0 && |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
165 _outbound.length()==0 && |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
166 _unwrapBuf.length()==0) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
167 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
168 _inbound=null; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
169 _outbound=null; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
170 _unwrapBuf=null; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
171 __buffers.set(_buffers); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
172 _buffers=null; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
173 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
174 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
175 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
176 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
177 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
178 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
179 public Connection handle() throws IOException |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
180 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
181 try |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
182 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
183 allocateBuffers(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
184 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
185 boolean progress=true; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
186 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
187 while (progress) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
188 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
189 progress=false; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
190 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
191 // If we are handshook let the delegate connection |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
192 if (_engine.getHandshakeStatus()!=HandshakeStatus.NOT_HANDSHAKING) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
193 progress=process(null,null); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
194 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
195 // handle the delegate connection |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
196 AsyncConnection next = (AsyncConnection)_connection.handle(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
197 if (next!=_connection && next!=null) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
198 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
199 _connection=next; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
200 progress=true; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
201 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
202 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
203 _logger.debug("{} handle {} progress={}", _session, this, progress); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
204 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
205 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
206 finally |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
207 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
208 releaseBuffers(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
209 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
210 if (!_ishut && _sslEndPoint.isInputShutdown() && _sslEndPoint.isOpen()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
211 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
212 _ishut=true; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
213 try |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
214 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
215 _connection.onInputShutdown(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
216 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
217 catch(Throwable x) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
218 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
219 _logger.warn("onInputShutdown failed", x); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
220 try{_sslEndPoint.close();} |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
221 catch(IOException e2){ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
222 _logger.trace("",e2);} |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
223 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
224 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
225 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
226 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
227 return this; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
228 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
229 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
230 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
231 public boolean isIdle() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
232 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
233 return false; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
234 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
235 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
236 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
237 public boolean isSuspended() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
238 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
239 return false; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
240 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
241 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
242 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
243 public void onClose() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
244 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
245 Connection connection = _sslEndPoint.getConnection(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
246 if (connection != null && connection != this) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
247 connection.onClose(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
248 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
249 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
250 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
251 @Override |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
252 public void onIdleExpired(long idleForMs) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
253 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
254 try |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
255 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
256 _logger.debug("onIdleExpired {}ms on {}",idleForMs,this); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
257 if (_endp.isOutputShutdown()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
258 _sslEndPoint.close(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
259 else |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
260 _sslEndPoint.shutdownOutput(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
261 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
262 catch (IOException e) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
263 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
264 _logger.warn("",e); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
265 super.onIdleExpired(idleForMs); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
266 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
267 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
268 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
269 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
270 public void onInputShutdown() throws IOException |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
271 { |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
272 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
273 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
274 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
275 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
276 private synchronized boolean process(Buffer toFill, Buffer toFlush) throws IOException |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
277 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
278 boolean some_progress=false; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
279 try |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
280 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
281 // We need buffers to progress |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
282 allocateBuffers(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
283 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
284 // if we don't have a buffer to put received data into |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
285 if (toFill==null) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
286 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
287 // use the unwrapbuffer to hold received data. |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
288 _unwrapBuf.compact(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
289 toFill=_unwrapBuf; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
290 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
291 // Else if the fill buffer is too small for the SSL session |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
292 else if (toFill.capacity()<_session.getApplicationBufferSize()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
293 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
294 // fill to the temporary unwrapBuffer |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
295 boolean progress=process(null,toFlush); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
296 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
297 // if we received any data, |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
298 if (_unwrapBuf!=null && _unwrapBuf.hasContent()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
299 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
300 // transfer from temp buffer to fill buffer |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
301 _unwrapBuf.skip(toFill.put(_unwrapBuf)); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
302 return true; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
303 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
304 else |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
305 // return progress from recursive call |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
306 return progress; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
307 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
308 // Else if there is some temporary data |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
309 else if (_unwrapBuf!=null && _unwrapBuf.hasContent()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
310 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
311 // transfer from temp buffer to fill buffer |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
312 _unwrapBuf.skip(toFill.put(_unwrapBuf)); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
313 return true; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
314 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
315 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
316 // If we are here, we have a buffer ready into which we can put some read data. |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
317 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
318 // If we have no data to flush, flush the empty buffer |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
319 if (toFlush==null) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
320 toFlush=__ZERO_BUFFER; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
321 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
322 // While we are making progress processing SSL engine |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
323 boolean progress=true; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
324 while (progress) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
325 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
326 progress=false; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
327 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
328 // Do any real IO |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
329 int filled=0,flushed=0; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
330 try |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
331 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
332 // Read any available data |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
333 if (_inbound.space()>0 && (filled=_endp.fill(_inbound))>0) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
334 progress = true; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
335 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
336 // flush any output data |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
337 if (_outbound.hasContent() && (flushed=_endp.flush(_outbound))>0) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
338 progress = true; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
339 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
340 catch (IOException e) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
341 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
342 _endp.close(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
343 throw e; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
344 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
345 finally |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
346 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
347 _logger.debug("{} {} {} filled={}/{} flushed={}/{}",_session,this,_engine.getHandshakeStatus(),filled,_inbound.length(),flushed,_outbound.length()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
348 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
349 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
350 // handle the current hand share status |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
351 switch(_engine.getHandshakeStatus()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
352 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
353 case FINISHED: |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
354 throw new IllegalStateException(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
355 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
356 case NOT_HANDSHAKING: |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
357 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
358 // Try unwrapping some application data |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
359 if (toFill.space()>0 && _inbound.hasContent() && unwrap(toFill)) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
360 progress=true; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
361 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
362 // Try wrapping some application data |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
363 if (toFlush.hasContent() && _outbound.space()>0 && wrap(toFlush)) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
364 progress=true; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
365 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
366 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
367 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
368 case NEED_TASK: |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
369 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
370 // A task needs to be run, so run it! |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
371 Runnable task; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
372 while ((task=_engine.getDelegatedTask())!=null) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
373 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
374 progress=true; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
375 task.run(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
376 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
377 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
378 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
379 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
380 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
381 case NEED_WRAP: |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
382 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
383 // The SSL needs to send some handshake data to the other side |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
384 if (_handshook && !_allowRenegotiate) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
385 _endp.close(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
386 else if (wrap(toFlush)) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
387 progress=true; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
388 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
389 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
390 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
391 case NEED_UNWRAP: |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
392 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
393 // The SSL needs to receive some handshake data from the other side |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
394 if (_handshook && !_allowRenegotiate) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
395 _endp.close(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
396 else if (!_inbound.hasContent()&&filled==-1) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
397 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
398 // No more input coming |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
399 _endp.shutdownInput(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
400 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
401 else if (unwrap(toFill)) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
402 progress=true; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
403 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
404 break; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
405 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
406 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
407 // pass on ishut/oshut state |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
408 if (_endp.isOpen() && _endp.isInputShutdown() && !_inbound.hasContent()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
409 closeInbound(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
410 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
411 if (_endp.isOpen() && _engine.isOutboundDone() && !_outbound.hasContent()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
412 _endp.shutdownOutput(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
413 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
414 // remember if any progress has been made |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
415 some_progress|=progress; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
416 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
417 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
418 // If we are reading into the temp buffer and it has some content, then we should be dispatched. |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
419 if (toFill==_unwrapBuf && _unwrapBuf.hasContent() && !_connection.isSuspended()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
420 _aEndp.dispatch(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
421 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
422 finally |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
423 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
424 releaseBuffers(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
425 if (some_progress) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
426 _progressed.set(true); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
427 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
428 return some_progress; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
429 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
430 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
431 private void closeInbound() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
432 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
433 try |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
434 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
435 _engine.closeInbound(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
436 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
437 catch (SSLException x) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
438 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
439 _logger.debug("",x); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
440 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
441 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
442 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
443 private synchronized boolean wrap(final Buffer buffer) throws IOException |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
444 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
445 ByteBuffer bbuf=extractByteBuffer(buffer); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
446 final SSLEngineResult result; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
447 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
448 synchronized(bbuf) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
449 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
450 _outbound.compact(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
451 ByteBuffer out_buffer=_outbound.getByteBuffer(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
452 synchronized(out_buffer) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
453 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
454 try |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
455 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
456 bbuf.position(buffer.getIndex()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
457 bbuf.limit(buffer.putIndex()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
458 out_buffer.position(_outbound.putIndex()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
459 out_buffer.limit(out_buffer.capacity()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
460 result=_engine.wrap(bbuf,out_buffer); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
461 if (_logger.isDebugEnabled()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
462 _logger.debug("{} wrap {} {} consumed={} produced={}", |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
463 _session, |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
464 result.getStatus(), |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
465 result.getHandshakeStatus(), |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
466 result.bytesConsumed(), |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
467 result.bytesProduced()); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
468 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
469 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
470 buffer.skip(result.bytesConsumed()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
471 _outbound.setPutIndex(_outbound.putIndex()+result.bytesProduced()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
472 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
473 catch(SSLException e) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
474 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
475 _logger.debug(String.valueOf(_endp), e); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
476 _endp.close(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
477 throw e; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
478 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
479 finally |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
480 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
481 out_buffer.position(0); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
482 out_buffer.limit(out_buffer.capacity()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
483 bbuf.position(0); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
484 bbuf.limit(bbuf.capacity()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
485 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
486 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
487 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
488 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
489 switch(result.getStatus()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
490 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
491 case BUFFER_UNDERFLOW: |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
492 throw new IllegalStateException(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
493 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
494 case BUFFER_OVERFLOW: |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
495 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
496 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
497 case OK: |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
498 if (result.getHandshakeStatus()==HandshakeStatus.FINISHED) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
499 _handshook=true; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
500 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
501 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
502 case CLOSED: |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
503 _logger.debug("wrap CLOSE {} {}",this,result); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
504 if (result.getHandshakeStatus()==HandshakeStatus.FINISHED) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
505 _endp.close(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
506 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
507 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
508 default: |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
509 _logger.debug("{} wrap default {}",_session,result); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
510 throw new IOException(result.toString()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
511 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
512 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
513 return result.bytesConsumed()>0 || result.bytesProduced()>0; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
514 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
515 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
516 private synchronized boolean unwrap(final Buffer buffer) throws IOException |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
517 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
518 if (!_inbound.hasContent()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
519 return false; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
520 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
521 ByteBuffer bbuf=extractByteBuffer(buffer); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
522 final SSLEngineResult result; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
523 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
524 synchronized(bbuf) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
525 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
526 ByteBuffer in_buffer=_inbound.getByteBuffer(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
527 synchronized(in_buffer) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
528 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
529 try |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
530 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
531 bbuf.position(buffer.putIndex()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
532 bbuf.limit(buffer.capacity()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
533 in_buffer.position(_inbound.getIndex()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
534 in_buffer.limit(_inbound.putIndex()); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
535 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
536 result=_engine.unwrap(in_buffer,bbuf); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
537 if (_logger.isDebugEnabled()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
538 _logger.debug("{} unwrap {} {} consumed={} produced={}", |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
539 _session, |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
540 result.getStatus(), |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
541 result.getHandshakeStatus(), |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
542 result.bytesConsumed(), |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
543 result.bytesProduced()); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
544 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
545 _inbound.skip(result.bytesConsumed()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
546 _inbound.compact(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
547 buffer.setPutIndex(buffer.putIndex()+result.bytesProduced()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
548 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
549 catch(SSLException e) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
550 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
551 _logger.debug(String.valueOf(_endp), e); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
552 _endp.close(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
553 throw e; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
554 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
555 finally |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
556 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
557 in_buffer.position(0); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
558 in_buffer.limit(in_buffer.capacity()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
559 bbuf.position(0); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
560 bbuf.limit(bbuf.capacity()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
561 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
562 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
563 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
564 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
565 switch(result.getStatus()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
566 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
567 case BUFFER_UNDERFLOW: |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
568 if (_endp.isInputShutdown()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
569 _inbound.clear(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
570 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
571 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
572 case BUFFER_OVERFLOW: |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
573 if (_logger.isDebugEnabled()) _logger.debug("{} unwrap {} {}->{}",_session,result.getStatus(),_inbound.toDetailString(),buffer.toDetailString()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
574 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
575 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
576 case OK: |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
577 if (result.getHandshakeStatus()==HandshakeStatus.FINISHED) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
578 _handshook=true; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
579 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
580 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
581 case CLOSED: |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
582 _logger.debug("unwrap CLOSE {} {}",this,result); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
583 if (result.getHandshakeStatus()==HandshakeStatus.FINISHED) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
584 _endp.close(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
585 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
586 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
587 default: |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
588 _logger.debug("{} wrap default {}",_session,result); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
589 throw new IOException(result.toString()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
590 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
591 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
592 //if (LOG.isDebugEnabled() && result.bytesProduced()>0) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
593 // LOG.debug("{} unwrapped '{}'",_session,buffer); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
594 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
595 return result.bytesConsumed()>0 || result.bytesProduced()>0; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
596 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
597 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
598 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
599 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
600 private ByteBuffer extractByteBuffer(Buffer buffer) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
601 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
602 if (buffer.buffer() instanceof NIOBuffer) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
603 return ((NIOBuffer)buffer.buffer()).getByteBuffer(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
604 return ByteBuffer.wrap(buffer.array()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
605 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
606 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
607 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
608 public AsyncEndPoint getSslEndPoint() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
609 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
610 return _sslEndPoint; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
611 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
612 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
613 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
614 public String toString() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
615 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
616 return String.format("%s %s", super.toString(), _sslEndPoint); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
617 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
618 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
619 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
620 /* ------------------------------------------------------------ */ |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
621 public class SslEndPoint implements AsyncEndPoint |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
622 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
623 public SSLEngine getSslEngine() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
624 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
625 return _engine; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
626 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
627 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
628 public AsyncEndPoint getEndpoint() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
629 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
630 return _aEndp; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
631 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
632 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
633 public void shutdownOutput() throws IOException |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
634 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
635 synchronized (SslConnection.this) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
636 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
637 _logger.debug("{} ssl endp.oshut {}",_session,this); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
638 _engine.closeOutbound(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
639 _oshut=true; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
640 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
641 flush(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
642 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
643 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
644 public boolean isOutputShutdown() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
645 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
646 synchronized (SslConnection.this) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
647 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
648 return _oshut||!isOpen()||_engine.isOutboundDone(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
649 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
650 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
651 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
652 public void shutdownInput() throws IOException |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
653 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
654 _logger.debug("{} ssl endp.ishut!",_session); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
655 // We do not do a closeInput here, as SSL does not support half close. |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
656 // isInputShutdown works it out itself from buffer state and underlying endpoint state. |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
657 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
658 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
659 public boolean isInputShutdown() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
660 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
661 synchronized (SslConnection.this) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
662 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
663 return _endp.isInputShutdown() && |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
664 !(_unwrapBuf!=null&&_unwrapBuf.hasContent()) && |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
665 !(_inbound!=null&&_inbound.hasContent()); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
666 } |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
667 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
668 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
669 public void close() throws IOException |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
670 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
671 _logger.debug("{} ssl endp.close",_session); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
672 _endp.close(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
673 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
674 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
675 public int fill(Buffer buffer) throws IOException |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
676 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
677 int size=buffer.length(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
678 process(buffer, null); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
679 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
680 int filled=buffer.length()-size; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
681 |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
682 if (filled==0 && isInputShutdown()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
683 return -1; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
684 return filled; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
685 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
686 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
687 public int flush(Buffer buffer) throws IOException |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
688 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
689 int size = buffer.length(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
690 process(null, buffer); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
691 return size-buffer.length(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
692 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
693 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
694 public int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
695 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
696 if (header!=null && header.hasContent()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
697 return flush(header); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
698 if (buffer!=null && buffer.hasContent()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
699 return flush(buffer); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
700 if (trailer!=null && trailer.hasContent()) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
701 return flush(trailer); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
702 return 0; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
703 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
704 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
705 public boolean blockReadable(long millisecs) throws IOException |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
706 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
707 long now = System.currentTimeMillis(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
708 long end=millisecs>0?(now+millisecs):Long.MAX_VALUE; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
709 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
710 while (now<end) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
711 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
712 if (process(null,null)) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
713 break; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
714 _endp.blockReadable(end-now); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
715 now = System.currentTimeMillis(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
716 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
717 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
718 return now<end; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
719 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
720 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
721 public boolean blockWritable(long millisecs) throws IOException |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
722 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
723 return _endp.blockWritable(millisecs); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
724 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
725 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
726 public boolean isOpen() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
727 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
728 return _endp.isOpen(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
729 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
730 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
731 public Object getTransport() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
732 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
733 return _endp; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
734 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
735 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
736 public void flush() throws IOException |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
737 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
738 process(null, null); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
739 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
740 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
741 public void dispatch() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
742 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
743 _aEndp.dispatch(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
744 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
745 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
746 public void asyncDispatch() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
747 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
748 _aEndp.asyncDispatch(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
749 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
750 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
751 public void scheduleWrite() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
752 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
753 _aEndp.scheduleWrite(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
754 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
755 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
756 public void onIdleExpired(long idleForMs) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
757 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
758 _aEndp.onIdleExpired(idleForMs); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
759 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
760 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
761 public void setCheckForIdle(boolean check) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
762 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
763 _aEndp.setCheckForIdle(check); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
764 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
765 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
766 public boolean isCheckForIdle() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
767 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
768 return _aEndp.isCheckForIdle(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
769 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
770 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
771 public boolean isWritable() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
772 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
773 return _aEndp.isWritable(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
774 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
775 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
776 public boolean hasProgressed() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
777 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
778 return _progressed.getAndSet(false); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
779 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
780 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
781 public String getLocalAddr() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
782 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
783 return _aEndp.getLocalAddr(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
784 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
785 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
786 public String getLocalHost() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
787 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
788 return _aEndp.getLocalHost(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
789 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
790 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
791 public int getLocalPort() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
792 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
793 return _aEndp.getLocalPort(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
794 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
795 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
796 public String getRemoteAddr() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
797 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
798 return _aEndp.getRemoteAddr(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
799 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
800 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
801 public String getRemoteHost() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
802 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
803 return _aEndp.getRemoteHost(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
804 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
805 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
806 public int getRemotePort() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
807 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
808 return _aEndp.getRemotePort(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
809 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
810 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
811 public boolean isBlocking() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
812 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
813 return false; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
814 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
815 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
816 public int getMaxIdleTime() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
817 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
818 return _aEndp.getMaxIdleTime(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
819 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
820 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
821 public void setMaxIdleTime(int timeMs) throws IOException |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
822 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
823 _aEndp.setMaxIdleTime(timeMs); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
824 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
825 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
826 public Connection getConnection() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
827 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
828 return _connection; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
829 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
830 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
831 public void setConnection(Connection connection) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
832 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
833 _connection=(AsyncConnection)connection; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
834 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
835 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
836 public String toString() |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
837 { |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
838 // Do NOT use synchronized (SslConnection.this) |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
839 // because it's very easy to deadlock when debugging is enabled. |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
840 // We do a best effort to print the right toString() and that's it. |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
841 Buffer inbound = _inbound; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
842 Buffer outbound = _outbound; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
843 Buffer unwrap = _unwrapBuf; |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
844 int i = inbound == null? -1 : inbound.length(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
845 int o = outbound == null ? -1 : outbound.length(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
846 int u = unwrap == null ? -1 : unwrap.length(); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
847 return String.format("SSL %s i/o/u=%d/%d/%d ishut=%b oshut=%b {%s}", |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
848 _engine.getHandshakeStatus(), |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
849 i, o, u, |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
850 _ishut, _oshut, |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
851 _connection); |
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
852 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
853 |
940
b77d631b9e28
remove scheduleTimeout() and cancelTimeout()
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
854 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
855 } |