001 /*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License"). You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at
010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 * Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 * Copyright 2006-2008 Sun Microsystems, Inc.
026 */
027 package org.opends.server.protocols.jmx;
028
029 import java.io.IOException;
030 import java.net.ServerSocket;
031 import java.rmi.server.RMIServerSocketFactory;
032 import java.rmi.server.RMISocketFactory;
033
034
035 /**
036 * The RMI connector class starts and stops the JMX RMI connector server.
037 * There are 2 different connector servers
038 * <ul>
039 * <li> the RMI Client connector server, supporting TLS-encrypted.
040 * communication, server authentication by certificate and client
041 * authentication by providing appropriate LDAP credentials through
042 * SASL/PLAIN.
043 * <li> the RMI client connector server, supporting TLS-encrypted
044 * communication, server authentication by certificate, client
045 * authentication by certificate and identity assertion through SASL/PLAIN.
046 * </ul>
047 * <p>
048 * Each connector is registered into the JMX MBean server.
049 */
050
051 /**
052 * An implementation of the socketServer.
053 */
054 public class OpendsRmiServerSocketFactory implements RMIServerSocketFactory
055 {
056
057 /**
058 * The Platform RMISocketFactory.
059 */
060 private RMIServerSocketFactory ssf =
061 RMISocketFactory.getDefaultSocketFactory() ;
062
063 /*
064 * The Created ServerSocket.
065 */
066 ServerSocket serverSocket ;
067
068 /**
069 * Create a server socket on the specified port
070 * (port 0 indicates an anonymous port).
071 * @param port the port number
072 * @return the server socket on the specified port
073 * @throws IOException if an I/O error occurs during server socket creation
074 */
075 public ServerSocket createServerSocket(int port) throws IOException
076 {
077 serverSocket = ssf.createServerSocket(port) ;
078 return serverSocket ;
079 }
080
081 /**
082 * Close the underlying socket.
083 *
084 * @throws IOException If an I/O error occurs when closing the socket.
085 */
086 protected void close() throws IOException
087 {
088 serverSocket.close() ;
089 }
090 }