1 /*
2  * hunt-proton: AMQP Protocol library for D programming language.
3  *
4  * Copyright (C) 2018-2019 HuntLabs
5  *
6  * Website: https://www.huntlabs.net
7  *
8  * Licensed under the Apache-2.0 License.
9  *
10  */
11 module hunt.proton.engine.impl.ssl.DefaultSslEngineFacade;
12 
13 //import hunt.io.ByteBuffer;
14 //
15 //import javax.net.ssl.SSLEngine;
16 //import javax.net.ssl.SSLEngineResult;
17 //import javax.net.ssl.SSLEngineResult.HandshakeStatus;
18 //import javax.net.ssl.SSLEngineResult.Status;
19 //import javax.net.ssl.SSLException;
20 //import javax.net.ssl.SSLSession;
21 //
22 //
23 //class DefaultSslEngineFacade : ProtonSslEngine
24 //{
25 //    private SSLEngine _sslEngine;
26 //
27 //    /**
28 //     * Our testing has shown that application buffers need to be a bit larger
29 //     * than that provided by {@link SSLSession#getApplicationBufferSize()} otherwise
30 //     * {@link Status#BUFFER_OVERFLOW} will result on {@link SSLEngine#unwrap}.
31 //     * Sun's own example uses 50, so we use the same.
32 //     */
33 //    private static int APPLICATION_BUFFER_EXTRA = 50;
34 //
35 //    DefaultSslEngineFacade(SSLEngine sslEngine)
36 //    {
37 //        _sslEngine = sslEngine;
38 //    }
39 //
40 //    @Override
41 //    public SSLEngineResult wrap(ByteBuffer src, ByteBuffer dst) throws SSLException
42 //    {
43 //        return _sslEngine.wrap(src, dst);
44 //    }
45 //
46 //    @Override
47 //    public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer dst) throws SSLException
48 //    {
49 //        return _sslEngine.unwrap(src, dst);
50 //    }
51 //
52 //    /**
53 //     * @see #APPLICATION_BUFFER_EXTRA
54 //     */
55 //    @Override
56 //    public int getEffectiveApplicationBufferSize()
57 //    {
58 //        return getApplicationBufferSize() + APPLICATION_BUFFER_EXTRA;
59 //    }
60 //
61 //    private int getApplicationBufferSize()
62 //    {
63 //        return _sslEngine.getSession().getApplicationBufferSize();
64 //    }
65 //
66 //    @Override
67 //    public int getPacketBufferSize()
68 //    {
69 //        return _sslEngine.getSession().getPacketBufferSize();
70 //    }
71 //
72 //    @Override
73 //    public String getCipherSuite()
74 //    {
75 //        return _sslEngine.getSession().getCipherSuite();
76 //    }
77 //
78 //    @Override
79 //    public String getProtocol()
80 //    {
81 //        return _sslEngine.getSession().getProtocol();
82 //    }
83 //
84 //    @Override
85 //    public Runnable getDelegatedTask()
86 //    {
87 //        return _sslEngine.getDelegatedTask();
88 //    }
89 //
90 //    @Override
91 //    public HandshakeStatus getHandshakeStatus()
92 //    {
93 //        return _sslEngine.getHandshakeStatus();
94 //    }
95 //
96 //    @Override
97 //    public boolean getUseClientMode()
98 //    {
99 //        return _sslEngine.getUseClientMode();
100 //    }
101 //
102 //    @Override
103 //    public String toString()
104 //    {
105 //        StringBuilder builder = new StringBuilder();
106 //        builder.append("DefaultSslEngineFacade [_sslEngine=").append(_sslEngine).append("]");
107 //        return builder.toString();
108 //    }
109 //
110 //}