net.jini.jeri.kerberos
Class KerberosServerEndpoint.ListenHandleImpl

java.lang.Object
  extended by net.jini.jeri.kerberos.KerberosServerEndpoint.ListenHandleImpl
All Implemented Interfaces:
ServerEndpoint.ListenHandle
Enclosing class:
KerberosServerEndpoint

private final class KerberosServerEndpoint.ListenHandleImpl
extends Object
implements ServerEndpoint.ListenHandle

A runnable class which creates a server socket and listens for client connections. It also maintains a reference to each of the accepted connections that have not been closed yet.


Field Summary
private  int acceptFailureCount
           
private  long acceptFailureTime
           
private  boolean closed
           
private  Set connections
           
private  RequestDispatcher dispatcher
           
(package private)  KerberosServerEndpoint.ListenCookieImpl listenCookie
          ListenCookie of the listen operation
private  Object lock
           
private  SecurityContext securityContext
          The security context at the time of the listen.
(package private)  GSSCredential serverCred
          The credential this server uses to authenticate itself
private  KerberosKey serverKey
          The Kerberos key used for server authentication
private  ServerSocket serverSocket
           
 
Constructor Summary
KerberosServerEndpoint.ListenHandleImpl(RequestDispatcher dispatcher, KerberosKey serverKey, GSSCredential serverCred, ServerSocket serverSocket, SecurityContext securityContext)
           
 
Method Summary
private  boolean checkKey()
          Check whether the server key for this listen operation is still valid and present in the server subject.
 void close()
          Close the server socket and all accepted connections
private  boolean continueAfterAcceptFailure(Throwable t)
          Throttles the accept loop after ServerSocket.accept throws an exception, and decides whether to continue at all.
private  void executeAcceptLoop()
          Executes the accept loop.
 ServerEndpoint.ListenCookie getCookie()
          Returns a ListenCookie to identify the listen operation as the return value of the ListenContext.addListenEndpoint method.
(package private)  void remove(KerberosServerEndpoint.ServerConnectionImpl connection)
          Remove a server connection from the connection list of this listen operation.
(package private)  void startAccepting()
          Starts the accept loop.
 String toString()
          Returns a string representation of this listen handle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dispatcher

private final RequestDispatcher dispatcher

securityContext

private final SecurityContext securityContext
The security context at the time of the listen.


serverKey

private KerberosKey serverKey
The Kerberos key used for server authentication


serverCred

final GSSCredential serverCred
The credential this server uses to authenticate itself


listenCookie

KerberosServerEndpoint.ListenCookieImpl listenCookie
ListenCookie of the listen operation


serverSocket

private final ServerSocket serverSocket

connections

private final Set connections

lock

private final Object lock

closed

private boolean closed

acceptFailureTime

private long acceptFailureTime

acceptFailureCount

private int acceptFailureCount
Constructor Detail

KerberosServerEndpoint.ListenHandleImpl

KerberosServerEndpoint.ListenHandleImpl(RequestDispatcher dispatcher,
                                        KerberosKey serverKey,
                                        GSSCredential serverCred,
                                        ServerSocket serverSocket,
                                        SecurityContext securityContext)
Method Detail

startAccepting

void startAccepting()
Starts the accept loop.


executeAcceptLoop

private void executeAcceptLoop()
Executes the accept loop. The accept loop runs with the full privileges of this code; "accept" SocketPermissions are checked against the direct user of this endpoint later, when the ServerConnectionManager calls checkPermissions on the InboundRequest before passing it to the RequestDispatcher.


getCookie

public ServerEndpoint.ListenCookie getCookie()
Description copied from interface: ServerEndpoint.ListenHandle
Returns a ListenCookie to identify the listen operation as the return value of the ListenContext.addListenEndpoint method.

Specified by:
getCookie in interface ServerEndpoint.ListenHandle
Returns:
a ListenCookie to identify the listen operation

close

public void close()
Close the server socket and all accepted connections

Specified by:
close in interface ServerEndpoint.ListenHandle

toString

public String toString()
Returns a string representation of this listen handle.

Overrides:
toString in class Object

remove

void remove(KerberosServerEndpoint.ServerConnectionImpl connection)
Remove a server connection from the connection list of this listen operation. Only effective if the listen operation has not been closed yet.


checkKey

private boolean checkKey()
Check whether the server key for this listen operation is still valid and present in the server subject.

Returns:
true if the server key is still valid and present in the server subject, false otherwise.

continueAfterAcceptFailure

private boolean continueAfterAcceptFailure(Throwable t)
Throttles the accept loop after ServerSocket.accept throws an exception, and decides whether to continue at all. The current code is borrowed from the JRMP implementation; it always continues, but it delays the loop after bursts of failed accepts.

This method is copied from net.jini.jeri.tcp.TcpServerEndpoint.



Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.