public final class SslServerEndpoint extends Object implements ServerEndpoint
ServerEndpoint that uses TLS/SSL to support
 invocation constraints for direct communication over TCP sockets. 
 Instances of this class are intended to be created for use with the BasicJeriExporter class. Calls to enumerateListenEndpoints return instances of SslEndpoint. 
This class supports at least the following constraints, possibly limited by the available cipher suites:
ClientAuthentication
 ClientMaxPrincipal, when it contains an X500Principal
 ClientMaxPrincipalType, when it contains
        X500Principal
 ClientMinPrincipal, when it contains a single
        X500Principal only
 ClientMinPrincipalType, when it contains
        X500Principal only
 Confidentiality
 ConfidentialityStrength, a provider-specific constraint for
        specifying weak or strong confidentiality
 ConnectionAbsoluteTime, trivially, since this only takes effect
        on the client side
 ConnectionRelativeTime, trivially, since this only takes effect
        on the client side
 ConstraintAlternatives, if the elements all have the same
        actual class and at least one element is supported
 Delegation.NO
 Delegation.YES, trivially, for anonymous clients
 DelegationAbsoluteTime, trivially, when delegation is not
        supported
 DelegationRelativeTime, trivially, when delegation is not
        supported
 Integrity.YES
 ServerAuthentication
 ServerMinPrincipal, when it contains a single
        X500Principal only
 
 This class authenticates as a single Principal if the following
 items are present in the server Subject: 
X500Principal
 CertPath, whose
      getType method returns "X.509", and for which calling
      getSubjectDN on the certificate chain's first element
      returns that principal's name
 X500PrivateCredential, stored as a private credential, whose
      getCertificate method returns a value equal to the first
      element of the certificate chain, and whose getPrivateKey
      method returns the associated private key
 
 In addition, this class will only dispatch remote calls that authenticate as
 a given principal if the caller of listen on the class's
 ServerEndpoint.ListenEndpoint has been granted AuthenticationPermission with that principal as the local principal, the
 principal representing the authenticated identity of the client for the call
 (if any) as the peer principal, and the accept action. 
 This class supports remote connections between authenticated servers and
 authenticated or anonymous clients, and between anonymous servers and
 anonymous clients. Connections between anonymous servers and authenticated
 clients are not supported. Because of the suites available in the TLS/SSL
 protocol, support for Confidentiality.NO requires the server to
 authenticate with an RSA public key. 
 If the server subject contains principals and credentials that would permit
 authentication of more than one X500Principal, the endpoint
 will make an arbitrary choice of the principal to use for authentication,
 and will continue to make the same choice so long as subject contents,
 validity of credentials, and security permissions do not change. 
 The host name specified when creating an SslServerEndpoint
 instance controls the host name that will be contained in
 SslEndpoint instances produced when enumerateListenEndpoints is invoked to listen on
 the server endpoint; the host name does not affect the behavior of the
 listen operation itself, which listens on all of the local system's network
 addresses. If the host name in the server endpoint is null,
 then the host name in the SslEndpoint instances that it
 produces will be the default server host name, which is the IP address
 string of the InetAddress returned by InetAddress.getLocalHost when
 enumerateListenEndpoints is invoked. 
 This class permits specifying a SocketFactory for creating the
 Socket instances that the associated SslEndpoint
 instances use to make remote connections back to the server, and a ServerSocketFactory for creating the ServerSocket instances that
 the server endpoint uses to accept remote connections. These socket
 factories and sockets should not implement the TLS/SSL protocol; it is the
 responsibility of the implementation to establish TLS/SSL connections over
 the sockets it obtains from the socket factories. In particular, instances
 of SSLSocketFactory and SSLServerSocketFactory should not be
 used, and the factories used should not return instances of SSLSocket or SSLServerSocket. 
 A SocketFactory used with instances of this class should be
 serializable, and must implement Object.equals to obey
 the guidelines that are specified for equals methods of Endpoint instances. A ServerSocketFactory used with instances
 of this class must implement Object.equals to obey the
 guidelines that are specified for equals methods of ListenEndpoint instances. 
This class uses the Jini extensible remote invocation (Jini ERI) multiplexing protocol to map outgoing requests to socket connections.
SslEndpoint, 
ConfidentialityStrengthServerEndpoint.ListenContext, ServerEndpoint.ListenCookie, ServerEndpoint.ListenEndpoint, ServerEndpoint.ListenHandle| Modifier and Type | Method and Description | 
|---|---|
InvocationConstraints | 
checkConstraints(InvocationConstraints constraints)
Checks that it is possible to receive requests that either
 fully or partially satisfy the specified requirements, and
 returns any constraints that must be fully or partially
 implemented by higher layers in order to fully satisfy all of
 the specified requirements. 
 | 
Endpoint | 
enumerateListenEndpoints(ServerEndpoint.ListenContext listenContext)
Passes the  
ListenEndpoint for this SslServerEndpoint to
 listenContext, which will ensure an active listen
 operation on the endpoint, and returns an SslEndpoint
 instance corresponding to the listen operation chosen by
 listenContext. | 
boolean | 
equals(Object object)
Two instances of this class are equal if they have server subjects that
 compare equal using  
==; have server principals that are
 either both null or are equal when compared as the elements
 of a Set; have the same values for server host and port; have
 socket factories that are either both null, or have the
 same actual class and are equal; and have server socket factories
 that are either both null, or have the same actual class
 and are equal. | 
String | 
getHost()
Returns the host name that will be used in  
SslEndpoint instances
 created by listening on this object, or null if enumerateListenEndpoints will use the default
 server host. | 
static SslServerEndpoint | 
getInstance(int port)
Returns a TLS/SSL server endpoint for the specified port. 
 | 
static SslServerEndpoint | 
getInstance(String serverHost,
           int port)
Returns a TLS/SSL server endpoint for the specified server host and
 port. 
 | 
static SslServerEndpoint | 
getInstance(String serverHost,
           int port,
           SocketFactory socketFactory,
           ServerSocketFactory serverSocketFactory)
Returns a TLS/SSL server endpoint for the specified server host, port,
 and socket factories. 
 | 
static SslServerEndpoint | 
getInstance(Subject serverSubject,
           X500Principal[] serverPrincipals,
           String serverHost,
           int port)
Returns a TLS/SSL server endpoint for the specified server subject,
 server principals, server host, and port. 
 | 
static SslServerEndpoint | 
getInstance(Subject serverSubject,
           X500Principal[] serverPrincipals,
           String serverHost,
           int port,
           SocketFactory socketFactory,
           ServerSocketFactory serverSocketFactory)
Returns a TLS/SSL server endpoint for the specified server subject,
 server principals, server host, port, and socket factories. 
 | 
int | 
getPort()
Returns the TCP port on which this object listens for connections, or
  
0 if it selects a free port. | 
Set | 
getPrincipals()
Returns an immutable set of the principals that this instance uses for
 authentication, or  
null if it is anonymous. | 
ServerSocketFactory | 
getServerSocketFactory()
Returns the server socket factory that this server endpoint uses to
 create  
ServerSocket instances, or null if it uses
 default server sockets. | 
SocketFactory | 
getSocketFactory()
Returns the socket factory that the associated  
SslEndpoint
 instances created by listening on this server endpoint use to create
 Socket instances, or null if they use default
 sockets. | 
int | 
hashCode()
Returns a hash code value for this object. 
 | 
String | 
toString()
Returns a string representation of this object. 
 | 
public static SslServerEndpoint getInstance(int port)
null server host (which requests that enumerateListenEndpoints compute the default
 server host), the subject associated with the current access control
 context, the principals in the subject with appropriate public and
 private credentials for which the caller has AuthenticationPermission to listen, and null socket
 factories to create default sockets. A port of
 0 requests listening on any free port.port - the port on which to listen for connections, or
              0 for any free portSslServerEndpoint instanceIllegalArgumentException - if port is negative or
               greater than 65535public static SslServerEndpoint getInstance(String serverHost, int port)
AuthenticationPermission to listen, and null socket
 factories to create default sockets. A serverHost of
 null requests that enumerateListenEndpoints compute the default server host. A
 port of 0 requests listening on any free port.serverHost - the name that clients should use to connect to this
              server, or null to use the defaultport - the port on which to listen for connections, or
              0 for any free portSslServerEndpoint instanceIllegalArgumentException - if port is negative or
               greater than 65535public static SslServerEndpoint getInstance(String serverHost, int port, SocketFactory socketFactory, ServerSocketFactory serverSocketFactory)
AuthenticationPermission to listen. A serverHost of
 null requests that enumerateListenEndpoints compute the default server host. A
 port of 0 requests listening on any free
 port. A socketFactory of null uses default
 sockets in the associated SslEndpoint. A
 serverSocketFactory of null uses default
 server sockets.serverHost - the name that clients should use to connect to this
              server, or null to use the defaultport - the port on which to listen for connections, or
              0 for any free portsocketFactory - the socket factory for use in the associated
              SslEndpoint instances, or nullserverSocketFactory - the server socket factory, or
              nullSslServerEndpoint instanceIllegalArgumentException - if port is negative or
               greater than 65535public static SslServerEndpoint getInstance(Subject serverSubject, X500Principal[] serverPrincipals, String serverHost, int port)
null socket
 factories to create default sockets. A serverSubject of
 null uses the subject associated with the current access
 control context. A serverPrincipals of null
 uses the principals in the subject with appropriate public and private
 credentials for which the caller has AuthenticationPermission to
 listen; otherwise that argument specifies the principals to use, or that
 the server should be anonymous if the argument has no elements.  If
 non-null, the value of serverPrincipals is
 neither retained nor modified; subsequent changes to that argument have
 no effect on the instance created. A serverHost of
 null requests that enumerateListenEndpoints compute the default server host. A
 port of 0 requests listening on any free port.serverSubject - the Subject to use for authenticating
              the server or null to use the current subjectserverPrincipals - the principals to use for authenticating the
              server, or null to use any available principals in
              the subjectserverHost - the name that clients should use to connect to this
              server, or null to use the defaultport - the port on which to listen for connections, or
              0 for any free portSslServerEndpoint instanceIllegalArgumentException - if port is negative or
               greater than 65535NullPointerException - if serverPrincipals is not
               null and any of its elements are nullpublic static SslServerEndpoint getInstance(Subject serverSubject, X500Principal[] serverPrincipals, String serverHost, int port, SocketFactory socketFactory, ServerSocketFactory serverSocketFactory)
serverSubject of null uses the subject
 associated with the current access control context. A
 serverPrincipals of null uses the principals
 in the subject with appropriate public and private credentials for which
 the caller has AuthenticationPermission to listen; otherwise
 that argument specifies the principals to use, or that the server should
 be anonymous if the argument has no elements. If non-null,
 the value of serverPrincipals is neither retained nor
 modified; subsequent changes to that argument have no effect on the
 instance created. A serverHost of null
 requests that enumerateListenEndpoints
 compute the default server host. A port of 0
 requests listening on any free port. A socketFactory of
 null uses default sockets in the associated SslEndpoint. A serverSocketFactory of null
 uses default server sockets.serverSubject - the Subject to use for authenticating
              the server or null to use the current subjectserverPrincipals - the principals to use for authenticating the
              server, or null to use any available principals in
              the subjectserverHost - the name that clients should use to connect to this
              server, or null to use the defaultport - the port on which to listen for connections, or
              0 for any free portsocketFactory - the socket factory for use in the associated
              SslEndpoint instances, or nullserverSocketFactory - the server socket factory, or
              nullSslServerEndpoint instanceIllegalArgumentException - if port is negative or
               greater than 65535NullPointerException - if serverPrincipals is not
               null and any of its elements are nullpublic String getHost()
SslEndpoint instances
 created by listening on this object, or null if enumerateListenEndpoints will use the default
 server host.SslEndpoint instances
               created by listening on this object, or null if
               using the defaultpublic int getPort()
0 if it selects a free port.0 if it selects a free portpublic Set getPrincipals()
null if it is anonymous.nullpublic SocketFactory getSocketFactory()
SslEndpoint
 instances created by listening on this server endpoint use to create
 Socket instances, or null if they use default
 sockets.null if they use default socketspublic ServerSocketFactory getServerSocketFactory()
ServerSocket instances, or null if it uses
 default server sockets.null if it uses default
               server socketspublic String toString()
public InvocationConstraints checkConstraints(InvocationConstraints constraints) throws UnsupportedConstraintException
 This implementation only returns Integrity.YES constraints.
checkConstraints in interface ServerCapabilitiesconstraints - the constraints that must be supportedSecurityException - if the current security context does not have
               the permissions necessary to perform this operationNullPointerException - if constraints is
               nullUnsupportedConstraintException - if the transport layer
 aspects of any of the specified requirements are not supported
 by this instance (either in general or in the current security
 context)public int hashCode()
public boolean equals(Object object)
==; have server principals that are
 either both null or are equal when compared as the elements
 of a Set; have the same values for server host and port; have
 socket factories that are either both null, or have the
 same actual class and are equal; and have server socket factories
 that are either both null, or have the same actual class
 and are equal.public Endpoint enumerateListenEndpoints(ServerEndpoint.ListenContext listenContext) throws IOException
ListenEndpoint for this SslServerEndpoint to
 listenContext, which will ensure an active listen
 operation on the endpoint, and returns an SslEndpoint
 instance corresponding to the listen operation chosen by
 listenContext. 
 If this server endpoint's server host is null, then the
 endpoint returned will contain the default server host. This method
 computes the default by invoking InetAddress.getLocalHost to obtain an InetAddress for the
 local host. If InetAddress.getLocalHost throws an
 exception, this method throws that exception. The default host name will
 be the string returned by invoking getHostAddress on that InetAddress. If there is a security
 manager, its checkConnect method will be invoked with the string returned by
 invoking getHostName on that same
 InetAddress as the host argument and -1 as the
 port argument; this could result in a
 SecurityException. 
 This method invokes addListenEndpoint on
 listenContext once, passing a ListenEndpoint
 as described below.  If addListenEndpoint throws an
 exception, then this method throws that exception.  Otherwise, this
 method returns an SslEndpoint instance with the host name
 described above, the TCP port number bound by the listen operation
 represented by the ListenHandle returned by addListenEndpoint, and the same
 SocketFactory as this SslServerEndpoint. 
 The ListenEndpoint passed to
 addListenEndpoint represents the server subject, server
 principals, TCP port number, and ServerSocketFactory of
 this SslServerEndpoint.  Its methods behave as follows: 
 ListenHandle
 listen(RequestDispatcher):
 
Listens for requests received on this endpoint's TCP port, dispatching them to the suppliedRequestDispatcherin the form ofInboundRequestinstances.When the implementation of this method needs to create a new
ServerSocket, it will do so by invoking one of thecreateServerSocketmethods that returns a bound server socket on the containedServerSocketFactoryif non-null, or it will create aServerSocketdirectly otherwise.If there is a security manager, its
checkListenmethod will be invoked with this endpoint's TCP port; this could result in aSecurityException. In addition, for each server principal in this endpoint, the security manager'scheckPermissionmethod will be invoked with anAuthenticationPermissioncontaining the server principal and thelistenaction; this could also result in aSecurityException. Furthermore, before a givenInboundRequestgets dispatched to the supplied request dispatcher, the security manager'scheckAcceptmethod must have been successfully invoked in the security context of thislisteninvocation with the remote IP address and port of theSocketused to receive the request, and if the server authenticated itself to the client, the security manager'scheckPermissionmethod must have been successfully invoked in the same context with anAuthenticationPermissioncontaining that authenticated server principal as local principal, the client's authenticated principal (if any) as peer principal, and theacceptaction. ThecheckPermissionsmethod of the dispatchedInboundRequestalso performs these latter security checks. (Note that in some cases, the implementation may carry out some of these security checks indirectly, such as through invocations ofServerSocket's constructors oracceptmethod.)Requests will be dispatched in a
PrivilegedActionwrapped by aSecurityContextobtained when this method was invoked, with theAccessControlContextof thatSecurityContextin effect.Dispatched requests will implement
populateContextto populate the given collection with an element that implements theClientHostinterface, and an element that implements theClientSubjectinterface. TheClientHostelement implementsgetClientHostto return the IP address of theSocketthat the request was received over (seeSocket.getInetAddress()).Throws
IOExceptionif an I/O exception occurs while performing this operation, such as if the TCP port is already in use.Throws
SecurityExceptionif there is a security manager and an invocation of itscheckListenorcheckPermissionmethod fails.Throws
NullPointerExceptionifrequestDispatcherisnull
void checkPermissions():
 Verifies that the current security context has all of the security permissions necessary to listen for requests on this endpoint.If there is a security manager, its
checkListenmethod will be invoked with this endpoint's TCP port; this could result in aSecurityException. In addition, for each server principal in this endpoint, the security manager'scheckPermissionmethod will be invoked with anAuthenticationPermissioncontaining the server principal and thelistenaction; this could also result in aSecurityException.Throws
SecurityExceptionif there is a security manager and an invocation of itscheckListenorcheckPermissionmethod fails.
boolean equals(Object):
 Compares the specified object with thisListenEndpointfor equality.This method returns
trueif and only if the specified object is also aListenEndpointproduced by anSslServerEndpoint, and the two listen endpoints both have server subjects that compare equal using==; have server principals that are either bothnullor are equal when compared as the elements of aSet; have the same values for TCP port; and have server socket factories that are either bothnull, or have the same actual class and are equal.
enumerateListenEndpoints in interface ServerEndpointlistenContext - the ListenContext to pass
 this ServerEndpoint's ListenEndpoint
 instances toEndpoint instance for sending requests
 to this ServerEndpoint's communication endpoints
 being listened onSecurityException - if there is a security manager, and either its
               checkListen method fails,
               or serverHost is null and the security
               manager's checkConnect
               method fails; or if the calling thread does not have permission
               to authenticate as each of the endpoint's server principals when
               listening for connectionsIllegalArgumentException - if an invocation of the
               addListenEndpoint method on the supplied
               ListenContext returns a ListenCookie
               that does not correspond to the ListenEndpoint that
               was passed to itNullPointerException - if listenContext is
               nullUnknownHostException - if this instance's server host 
               is null and InetAddress.getLocalHost
               throws an UnknownHostExceptionUnsupportedConstraintException - if the server subject is missing
               any of the endpoint's server principals or the associated
               credentialsIOException - if an I/O exception occurs while attempting
 to listen for requests on the communication endpoints
 represented by this ServerEndpoint.  This could
 occur, for example, if an I/O resource associated with one of
 the communication endpoints is already in exclusive use, or if
 there are insufficient I/O resources for the operation.