001: /*
002: * Copyright 1999,2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.catalina.net;
018:
019: import java.io.IOException;
020: import java.net.InetAddress;
021: import java.net.ServerSocket;
022: import java.security.KeyStoreException;
023: import java.security.NoSuchAlgorithmException;
024: import java.security.UnrecoverableKeyException;
025: import java.security.KeyManagementException;
026: import java.security.cert.CertificateException;
027: import org.apache.catalina.net.ServerSocketFactory;
028:
029: /**
030: * Default server socket factory, which returns unadorned server sockets.
031: *
032: * @author db@eng.sun.com
033: * @author Harish Prabandham
034: * @author Craig R. McClanahan
035: */
036:
037: public final class DefaultServerSocketFactory implements
038: ServerSocketFactory {
039:
040: // --------------------------------------------------------- Public Methods
041:
042: /**
043: * Returns a server socket which uses all network interfaces on
044: * the host, and is bound to a the specified port. The socket is
045: * configured with the socket options (such as accept timeout)
046: * given to this factory.
047: *
048: * @param port the port to listen to
049: *
050: * @exception IOException input/output or network error
051: * @exception KeyStoreException error instantiating the
052: * KeyStore from file (SSL only)
053: * @exception NoSuchAlgorithmException KeyStore algorithm unsupported
054: * by current provider (SSL only)
055: * @exception CertificateException general certificate error (SSL only)
056: * @exception UnrecoverableKeyException internal KeyStore problem with
057: * the certificate (SSL only)
058: * @exception KeyManagementException problem in the key management
059: * layer (SSL only)
060: */
061: public ServerSocket createSocket(int port) throws IOException,
062: KeyStoreException, NoSuchAlgorithmException,
063: CertificateException, UnrecoverableKeyException,
064: KeyManagementException {
065:
066: return (new ServerSocket(port));
067:
068: }
069:
070: /**
071: * Returns a server socket which uses all network interfaces on
072: * the host, is bound to a the specified port, and uses the
073: * specified connection backlog. The socket is configured with
074: * the socket options (such as accept timeout) given to this factory.
075: *
076: * @param port the port to listen to
077: * @param backlog how many connections are queued
078: *
079: * @exception IOException input/output or network error
080: * @exception KeyStoreException error instantiating the
081: * KeyStore from file (SSL only)
082: * @exception NoSuchAlgorithmException KeyStore algorithm unsupported
083: * by current provider (SSL only)
084: * @exception CertificateException general certificate error (SSL only)
085: * @exception UnrecoverableKeyException internal KeyStore problem with
086: * the certificate (SSL only)
087: * @exception KeyManagementException problem in the key management
088: * layer (SSL only)
089: */
090: public ServerSocket createSocket(int port, int backlog)
091: throws IOException, KeyStoreException,
092: NoSuchAlgorithmException, CertificateException,
093: UnrecoverableKeyException, KeyManagementException {
094:
095: return (new ServerSocket(port, backlog));
096:
097: }
098:
099: /**
100: * Returns a server socket which uses only the specified network
101: * interface on the local host, is bound to a the specified port,
102: * and uses the specified connection backlog. The socket is configured
103: * with the socket options (such as accept timeout) given to this factory.
104: *
105: * @param port the port to listen to
106: * @param backlog how many connections are queued
107: * @param ifAddress the network interface address to use
108: *
109: * @exception IOException input/output or network error
110: * @exception KeyStoreException error instantiating the
111: * KeyStore from file (SSL only)
112: * @exception NoSuchAlgorithmException KeyStore algorithm unsupported
113: * by current provider (SSL only)
114: * @exception CertificateException general certificate error (SSL only)
115: * @exception UnrecoverableKeyException internal KeyStore problem with
116: * the certificate (SSL only)
117: * @exception KeyManagementException problem in the key management
118: * layer (SSL only)
119: */
120: public ServerSocket createSocket(int port, int backlog,
121: InetAddress ifAddress) throws IOException,
122: KeyStoreException, NoSuchAlgorithmException,
123: CertificateException, UnrecoverableKeyException,
124: KeyManagementException {
125:
126: return (new ServerSocket(port, backlog, ifAddress));
127:
128: }
129:
130: }
|