Source for javax.net.ssl.SSLServerSocket

   1: /* SSLServerSocket.java -- a server socket for SSL connections.
   2:    Copyright (C) 2004 Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: 
  39: package javax.net.ssl;
  40: 
  41: import java.io.IOException;
  42: 
  43: import java.net.InetAddress;
  44: import java.net.ServerSocket;
  45: 
  46: /**
  47:  * A server socket that allows clients to connect via the SSL protocol.
  48:  */
  49: public abstract class SSLServerSocket extends ServerSocket
  50: {
  51: 
  52:   // Constructors.
  53:   // -------------------------------------------------------------------------
  54: 
  55:   protected SSLServerSocket() throws IOException
  56:   {
  57:     super();
  58:     //super(0);
  59:     //throw new UnsupportedOperationException("1.4 socket methods not enabled");
  60:   }
  61: 
  62:   protected SSLServerSocket(int port) throws IOException
  63:   {
  64:     super(port);
  65:   }
  66: 
  67:   protected SSLServerSocket(int port, int backlog) throws IOException
  68:   {
  69:     super(port, backlog);
  70:   }
  71: 
  72:   protected SSLServerSocket(int port, int backlog, InetAddress bindAddress)
  73:     throws IOException
  74:   {
  75:     super(port, backlog, bindAddress);
  76:   }
  77: 
  78:   // Abstract methods.
  79:   // -------------------------------------------------------------------------
  80: 
  81:   /**
  82:    * Returns the list of cihper suites that are currently enabled in this
  83:    * server socket. Sockets accepted by this server socket will only have
  84:    * these suites enabled.
  85:    *
  86:    * @return The enabled cipher suites.
  87:    */
  88:   public abstract String[] getEnabledCipherSuites();
  89: 
  90:   /**
  91:    * Sets the list enabled cipher suites.
  92:    *
  93:    * @param suites The cipher suites to enable.
  94:    */
  95:   public abstract void setEnabledCipherSuites(String[] suites);
  96: 
  97:   /**
  98:    * Returns the list of enabled protocols, such as "SSLv3" and "TLSv1".
  99:    *
 100:    * @return The enabled protocols.
 101:    */
 102:   public abstract String[] getEnabledProtocols();
 103: 
 104:   /**
 105:    * Sets the list of enabled protocols.
 106:    *
 107:    * @param protocols The list of protocols to enable.
 108:    */
 109:   public abstract void setEnabledProtocols(String[] protocols);
 110: 
 111:   /**
 112:    * Returns whether or not sessions will be created, i.e., whether or not
 113:    * this server socket will allow SSL session resumption.
 114:    *
 115:    * @return True if sessions will be created.
 116:    */
 117:   public abstract boolean getEnableSessionCreation();
 118: 
 119:   /**
 120:    * Sets whether or not sessions will be created.
 121:    *
 122:    * @param enabled The new enabled value.
 123:    */
 124:   public abstract void setEnableSessionCreation(boolean enabled);
 125: 
 126:   /**
 127:    * Returns whether or not this server socket will require clients to
 128:    * authenticate themselves, such as through a certificate.
 129:    *
 130:    * @return True if clients must authenticate themselves.
 131:    */
 132:   public abstract boolean getNeedClientAuth();
 133: 
 134:   /**
 135:    * Enabled or disables the requirement that clients authenticate themselves.
 136:    * When this is set to <code>true</code>, connections will be rejected if
 137:    * connecting clients do not provide proper authentication.
 138:    *
 139:    * @param needAuth The new need auth value.
 140:    */
 141:   public abstract void setNeedClientAuth(boolean needAuth);
 142: 
 143:   /**
 144:    * Returns whether or not sockets accepted by this server socket will do
 145:    * their handshake as the client-side. The default is false.
 146:    *
 147:    * @return True if client mode will be used.
 148:    */
 149:   public abstract boolean getUseClientMode();
 150: 
 151:   /**
 152:    * Sets whether or not sockets accepted by this server socket will be
 153:    * created in client mode.
 154:    *
 155:    * @param clientMode The new client mode value.
 156:    */
 157:   public abstract void setUseClientMode(boolean clientMode);
 158: 
 159:   /**
 160:    * Returns whether or not this socket will ask for, but not require, that
 161:    * connecting clients authenticate themselves. Clients that do not
 162:    * provide authentication they will still be allowed to connect.
 163:    *
 164:    * @return True if this server socket wants client authentication.
 165:    */
 166:   public abstract boolean getWantClientAuth();
 167: 
 168:   /**
 169:    * Sets whether or not this server socket will want client authentication.
 170:    *
 171:    * @param wantAuth The new want auth value.
 172:    */
 173:   public abstract void setWantClientAuth(boolean wantAuth);
 174: 
 175:   /**
 176:    * Returns a list of cipher suites that this server socket supports.
 177:    *
 178:    * @return The list of supported suites.
 179:    */
 180:   public abstract String[] getSupportedCipherSuites();
 181: 
 182:   /**
 183:    * Returns a list of SSL protocols supported by this server socket.
 184:    *
 185:    * @return The list of supported protocols.
 186:    */
 187:   public abstract String[] getSupportedProtocols();
 188: }