1 /*
2 * Copyright 2018 The Netty Project
3 *
4 * The Netty Project licenses this file to you under the Apache License,
5 * version 2.0 (the "License"); you may not use this file except in compliance
6 * with the License. You may obtain a copy of the License at:
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations
14 * under the License.
15 */
16 package io.netty5.handler.ssl;
17
18 import io.netty5.util.ReferenceCounted;
19
20 import javax.net.ssl.SSLException;
21 import javax.net.ssl.SSLSession;
22 import java.security.cert.Certificate;
23
24 /**
25 * {@link SSLSession} that is specific to our native implementation and {@link ReferenceCounted} to track native
26 * resources.
27 */
28 interface OpenSslSession extends SSLSession {
29
30 /**
31 * Return the {@link OpenSslSessionId} that can be used to identify this session.
32 */
33 OpenSslSessionId sessionId();
34
35 /**
36 * Set the local certificate chain that is used. It is unexpected this array will be changed at all,
37 * and so it's ok to not copy the array.
38 */
39 void setLocalCertificate(Certificate[] localCertificate);
40
41 /**
42 * Set the {@link OpenSslSessionId} for the {@link OpenSslSession}.
43 */
44 void setSessionId(OpenSslSessionId id);
45
46 @Override
47 OpenSslSessionContext getSessionContext();
48
49 /**
50 * Expand (or increase) the value returned by {@link #getApplicationBufferSize()} if necessary.
51 * <p>
52 * This is only called in a synchronized block, so no need to use atomic operations.
53 * @param packetLengthDataOnly The packet size which exceeds the current {@link #getApplicationBufferSize()}.
54 */
55 void tryExpandApplicationBufferSize(int packetLengthDataOnly);
56
57 /**
58 * Called once the handshake has completed.
59 */
60 void handshakeFinished(byte[] id, String cipher, String protocol, byte[] peerCertificate,
61 byte[][] peerCertificateChain, long creationTime, long timeout) throws SSLException;
62 }