001/*
002 * $HeadURL: http://juliusdavies.ca/svn/not-yet-commons-ssl/tags/commons-ssl-0.3.9/src/java/org/apache/commons/ssl/SSLSocketWrapper.java $
003 * $Revision: 121 $
004 * $Date: 2007-11-13 21:26:57 -0800 (Tue, 13 Nov 2007) $
005 *
006 * ====================================================================
007 * Licensed to the Apache Software Foundation (ASF) under one
008 * or more contributor license agreements.  See the NOTICE file
009 * distributed with this work for additional information
010 * regarding copyright ownership.  The ASF licenses this file
011 * to you under the Apache License, Version 2.0 (the
012 * "License"); you may not use this file except in compliance
013 * with the License.  You may obtain a copy of the License at
014 *
015 *   http://www.apache.org/licenses/LICENSE-2.0
016 *
017 * Unless required by applicable law or agreed to in writing,
018 * software distributed under the License is distributed on an
019 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
020 * KIND, either express or implied.  See the License for the
021 * specific language governing permissions and limitations
022 * under the License.
023 * ====================================================================
024 *
025 * This software consists of voluntary contributions made by many
026 * individuals on behalf of the Apache Software Foundation.  For more
027 * information on the Apache Software Foundation, please see
028 * <http://www.apache.org/>.
029 *
030 */
031
032package org.apache.commons.ssl;
033
034import javax.net.ssl.HandshakeCompletedListener;
035import javax.net.ssl.SSLSession;
036import javax.net.ssl.SSLSocket;
037import java.io.IOException;
038import java.io.InputStream;
039import java.io.OutputStream;
040import java.net.InetAddress;
041import java.net.SocketAddress;
042import java.net.SocketException;
043import java.nio.channels.SocketChannel;
044
045/**
046 * @author Credit Union Central of British Columbia
047 * @author <a href="http://www.cucbc.com/">www.cucbc.com</a>
048 * @author <a href="mailto:juliusdavies@cucbc.com">juliusdavies@cucbc.com</a>
049 * @since 16-Aug-2006
050 */
051public class SSLSocketWrapper extends SSLSocket {
052    protected SSLSocket s;
053
054    public SSLSocketWrapper(SSLSocket s) {
055        this.s = s;
056    }
057
058    /* javax.net.ssl.SSLSocket */
059
060    public void addHandshakeCompletedListener(HandshakeCompletedListener hcl) {
061        s.addHandshakeCompletedListener(hcl);
062    }
063
064    public void removeHandshakeCompletedListener(HandshakeCompletedListener hcl) {
065        s.removeHandshakeCompletedListener(hcl);
066    }
067
068    public String[] getSupportedCipherSuites() {
069        return s.getSupportedCipherSuites();
070    }
071
072    public boolean getEnableSessionCreation() {
073        return s.getEnableSessionCreation();
074    }
075
076    public String[] getEnabledCipherSuites() {
077        return s.getEnabledCipherSuites();
078    }
079
080    public String[] getSupportedProtocols() { return s.getSupportedProtocols(); }
081
082    public String[] getEnabledProtocols() { return s.getEnabledProtocols(); }
083
084    public SSLSession getSession() { return s.getSession(); }
085
086    public boolean getUseClientMode() { return s.getUseClientMode(); }
087
088    public boolean getNeedClientAuth() { return s.getNeedClientAuth(); }
089
090    public boolean getWantClientAuth() { return s.getWantClientAuth(); }
091
092    public void setEnabledCipherSuites(String[] cs) {
093        s.setEnabledCipherSuites(cs);
094    }
095
096    public void setEnabledProtocols(String[] ep) {
097        s.setEnabledProtocols(ep);
098    }
099
100    public void startHandshake() throws IOException { s.startHandshake(); }
101
102    public void setUseClientMode(boolean b) { s.setUseClientMode(b); }
103
104    public void setNeedClientAuth(boolean b) { s.setNeedClientAuth(b); }
105
106    public void setWantClientAuth(boolean b) { s.setWantClientAuth(b); }
107
108    public void setEnableSessionCreation(boolean b) {
109        s.setEnableSessionCreation(b);
110    }
111
112    /* java.net.Socket */
113
114    public SocketChannel getChannel() { return s.getChannel(); }
115
116    public InetAddress getInetAddress() { return s.getInetAddress(); }
117
118    public boolean getKeepAlive() throws SocketException {
119        return s.getKeepAlive();
120    }
121
122    public InetAddress getLocalAddress() { return s.getLocalAddress(); }
123
124    public int getLocalPort() { return s.getLocalPort(); }
125
126    public SocketAddress getLocalSocketAddress() {
127        return s.getLocalSocketAddress();
128    }
129
130    public boolean getOOBInline() throws SocketException {
131        return s.getOOBInline();
132    }
133
134    public int getPort() { return s.getPort(); }
135
136    public int getReceiveBufferSize() throws SocketException {
137        return s.getReceiveBufferSize();
138    }
139
140    public SocketAddress getRemoteSocketAddress() {
141        return s.getRemoteSocketAddress();
142    }
143
144    public boolean getReuseAddress() throws SocketException {
145        return s.getReuseAddress();
146    }
147
148    public int getSendBufferSize() throws SocketException {
149        return s.getSendBufferSize();
150    }
151
152    public int getSoLinger() throws SocketException { return s.getSoLinger(); }
153
154    public int getSoTimeout() throws SocketException { return s.getSoTimeout(); }
155
156    public boolean getTcpNoDelay() throws SocketException {
157        return s.getTcpNoDelay();
158    }
159
160    public int getTrafficClass() throws SocketException {
161        return s.getTrafficClass();
162    }
163
164    public boolean isBound() { return s.isBound(); }
165
166    public boolean isClosed() { return s.isClosed(); }
167
168    public boolean isConnected() { return s.isConnected(); }
169
170    public boolean isInputShutdown() { return s.isInputShutdown(); }
171
172    public boolean isOutputShutdown() { return s.isOutputShutdown(); }
173
174    public void sendUrgentData(int data) throws IOException {
175        s.sendUrgentData(data);
176    }
177
178    public void setKeepAlive(boolean on) throws SocketException {
179        s.setKeepAlive(on);
180    }
181
182    public void setOOBInline(boolean on) throws SocketException {
183        s.setOOBInline(on);
184    }
185
186    public void setReceiveBufferSize(int size) throws SocketException {
187        s.setReceiveBufferSize(size);
188    }
189
190    public void setReuseAddress(boolean on) throws SocketException {
191        s.setReuseAddress(on);
192    }
193
194    public void setSendBufferSize(int size) throws SocketException {
195        s.setSendBufferSize(size);
196    }
197
198    public void setSoLinger(boolean on, int l) throws SocketException {
199        s.setSoLinger(on, l);
200    }
201
202    public void setSoTimeout(int timeout) throws SocketException {
203        s.setSoTimeout(timeout);
204    }
205
206    public void setTcpNoDelay(boolean on) throws SocketException {
207        s.setTcpNoDelay(on);
208    }
209
210    public void setTrafficClass(int tc) throws SocketException {
211        s.setTrafficClass(tc);
212    }
213
214    public void shutdownInput() throws IOException { s.shutdownInput(); }
215
216    public void shutdownOutput() throws IOException { s.shutdownOutput(); }
217
218    public String toString() { return s.toString(); }
219
220    /*  Java 1.5
221     public void setPerformancePreferences(int connectionTime, int latency, int bandwidth)
222     {
223         s.setPerformancePreferences( connectionTime, latency, bandwidth );
224     }
225     */
226
227    public void bind(SocketAddress bindpoint) throws IOException {
228        s.bind(bindpoint);
229    }
230
231    public void close() throws IOException {
232        s.close();
233    }
234
235    public void connect(SocketAddress endpoint) throws IOException {
236        s.connect(endpoint);
237    }
238
239    public void connect(SocketAddress endpoint, int timeout) throws IOException {
240        s.connect(endpoint, timeout);
241    }
242
243    public InputStream getInputStream() throws IOException {
244        return s.getInputStream();
245    }
246
247    public OutputStream getOutputStream() throws IOException {
248        return s.getOutputStream();
249    }
250
251}