View Javadoc
1   /*
2    * Copyright 2014 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    *   http://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.netty.handler.ssl;
17  
18  import java.nio.ByteBuffer;
19  
20  import javax.net.ssl.SSLEngine;
21  import javax.net.ssl.SSLEngineResult;
22  import javax.net.ssl.SSLEngineResult.HandshakeStatus;
23  import javax.net.ssl.SSLException;
24  import javax.net.ssl.SSLParameters;
25  import javax.net.ssl.SSLSession;
26  
27  class JdkSslEngine extends SSLEngine {
28      private final SSLEngine engine;
29      private final JdkSslSession session;
30  
31      JdkSslEngine(SSLEngine engine) {
32          this.engine = engine;
33          session = new JdkSslSession(engine);
34      }
35  
36      @Override
37      public JdkSslSession getSession() {
38          return session;
39      }
40  
41      public SSLEngine getWrappedEngine() {
42          return engine;
43      }
44  
45      @Override
46      public void closeInbound() throws SSLException {
47          engine.closeInbound();
48      }
49  
50      @Override
51      public void closeOutbound() {
52          engine.closeOutbound();
53      }
54  
55      @Override
56      public String getPeerHost() {
57          return engine.getPeerHost();
58      }
59  
60      @Override
61      public int getPeerPort() {
62          return engine.getPeerPort();
63      }
64  
65      @Override
66      public SSLEngineResult wrap(ByteBuffer byteBuffer, ByteBuffer byteBuffer2) throws SSLException {
67          return engine.wrap(byteBuffer, byteBuffer2);
68      }
69  
70      @Override
71      public SSLEngineResult wrap(ByteBuffer[] byteBuffers, ByteBuffer byteBuffer) throws SSLException {
72          return engine.wrap(byteBuffers, byteBuffer);
73      }
74  
75      @Override
76      public SSLEngineResult wrap(ByteBuffer[] byteBuffers, int i, int i2, ByteBuffer byteBuffer) throws SSLException {
77          return engine.wrap(byteBuffers, i, i2, byteBuffer);
78      }
79  
80      @Override
81      public SSLEngineResult unwrap(ByteBuffer byteBuffer, ByteBuffer byteBuffer2) throws SSLException {
82          return engine.unwrap(byteBuffer, byteBuffer2);
83      }
84  
85      @Override
86      public SSLEngineResult unwrap(ByteBuffer byteBuffer, ByteBuffer[] byteBuffers) throws SSLException {
87          return engine.unwrap(byteBuffer, byteBuffers);
88      }
89  
90      @Override
91      public SSLEngineResult unwrap(ByteBuffer byteBuffer, ByteBuffer[] byteBuffers, int i, int i2) throws SSLException {
92          return engine.unwrap(byteBuffer, byteBuffers, i, i2);
93      }
94  
95      @Override
96      public Runnable getDelegatedTask() {
97          return engine.getDelegatedTask();
98      }
99  
100     @Override
101     public boolean isInboundDone() {
102         return engine.isInboundDone();
103     }
104 
105     @Override
106     public boolean isOutboundDone() {
107         return engine.isOutboundDone();
108     }
109 
110     @Override
111     public String[] getSupportedCipherSuites() {
112         return engine.getSupportedCipherSuites();
113     }
114 
115     @Override
116     public String[] getEnabledCipherSuites() {
117         return engine.getEnabledCipherSuites();
118     }
119 
120     @Override
121     public void setEnabledCipherSuites(String[] strings) {
122         engine.setEnabledCipherSuites(strings);
123     }
124 
125     @Override
126     public String[] getSupportedProtocols() {
127         return engine.getSupportedProtocols();
128     }
129 
130     @Override
131     public String[] getEnabledProtocols() {
132         return engine.getEnabledProtocols();
133     }
134 
135     @Override
136     public void setEnabledProtocols(String[] strings) {
137         engine.setEnabledProtocols(strings);
138     }
139 
140     @Override
141     public SSLSession getHandshakeSession() {
142         return engine.getHandshakeSession();
143     }
144 
145     @Override
146     public void beginHandshake() throws SSLException {
147         engine.beginHandshake();
148     }
149 
150     @Override
151     public HandshakeStatus getHandshakeStatus() {
152         return engine.getHandshakeStatus();
153     }
154 
155     @Override
156     public void setUseClientMode(boolean b) {
157         engine.setUseClientMode(b);
158     }
159 
160     @Override
161     public boolean getUseClientMode() {
162         return engine.getUseClientMode();
163     }
164 
165     @Override
166     public void setNeedClientAuth(boolean b) {
167         engine.setNeedClientAuth(b);
168     }
169 
170     @Override
171     public boolean getNeedClientAuth() {
172         return engine.getNeedClientAuth();
173     }
174 
175     @Override
176     public void setWantClientAuth(boolean b) {
177         engine.setWantClientAuth(b);
178     }
179 
180     @Override
181     public boolean getWantClientAuth() {
182         return engine.getWantClientAuth();
183     }
184 
185     @Override
186     public void setEnableSessionCreation(boolean b) {
187         engine.setEnableSessionCreation(b);
188     }
189 
190     @Override
191     public boolean getEnableSessionCreation() {
192         return engine.getEnableSessionCreation();
193     }
194 
195     @Override
196     public SSLParameters getSSLParameters() {
197         return engine.getSSLParameters();
198     }
199 
200     @Override
201     public void setSSLParameters(SSLParameters sslParameters) {
202         engine.setSSLParameters(sslParameters);
203     }
204 }