001: //jTDS JDBC Driver for Microsoft SQL Server and Sybase
002: //Copyright (C) 2004 The jTDS Project
003: //
004: //This library is free software; you can redistribute it and/or
005: //modify it under the terms of the GNU Lesser General Public
006: //License as published by the Free Software Foundation; either
007: //version 2.1 of the License, or (at your option) any later version.
008: //
009: //This library is distributed in the hope that it will be useful,
010: //but WITHOUT ANY WARRANTY; without even the implied warranty of
011: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: //Lesser General Public License for more details.
013: //
014: //You should have received a copy of the GNU Lesser General Public
015: //License along with this library; if not, write to the Free Software
016: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: //
018: package net.sourceforge.jtds.ssl;
019:
020: import java.io.IOException;
021: import java.io.InputStream;
022: import java.io.OutputStream;
023: import java.net.Socket;
024: import java.net.SocketException;
025:
026: /**
027: * A socket that mediates between JSSE and the DB server.
028: *
029: * @author Rob Worsnop
030: * @author Mike Hutchinson
031: * @version $Id: TdsTlsSocket.java,v 1.3 2005/04/28 14:29:31 alin_sinpalean Exp $
032: */
033: class TdsTlsSocket extends Socket {
034: private final Socket delegate;
035: private final InputStream istm;
036: private final OutputStream ostm;
037:
038: /**
039: * Constructs a TdsTlsSocket around an underlying socket.
040: *
041: * @param delegate the underlying socket
042: */
043: TdsTlsSocket(Socket delegate) throws IOException {
044: this .delegate = delegate;
045: istm = new TdsTlsInputStream(delegate.getInputStream());
046: ostm = new TdsTlsOutputStream(delegate.getOutputStream());
047: }
048:
049: /*
050: * (non-Javadoc)
051: *
052: * @see java.net.Socket#close()
053: */
054: public synchronized void close() throws IOException {
055: // Do nothing. Underlying socket closed elsewhere
056: }
057:
058: /*
059: * (non-Javadoc)
060: *
061: * @see java.net.Socket#getInputStream()
062: */
063: public InputStream getInputStream() throws IOException {
064: return istm;
065: }
066:
067: /*
068: * (non-Javadoc)
069: *
070: * @see java.net.Socket#getOutputStream()
071: */
072: public OutputStream getOutputStream() throws IOException {
073: return ostm;
074: }
075:
076: /*
077: * (non-Javadoc)
078: *
079: * @see java.net.Socket#isConnected()
080: */
081: public boolean isConnected() {
082: return true;
083: }
084:
085: /*
086: * (non-Javadoc)
087: *
088: * @see java.net.Socket#setSoTimeout(int)
089: */
090: public synchronized void setSoTimeout(int timeout)
091: throws SocketException {
092: delegate.setSoTimeout(timeout);
093: }
094:
095: /*
096: * (non-Javadoc)
097: *
098: * @see java.net.Socket#setTcpNoDelay(boolean)
099: */
100: public void setTcpNoDelay(boolean on) throws SocketException {
101: delegate.setTcpNoDelay(on);
102: }
103: }
|