net.jini.jeri.ssl
Class HttpsEndpoint.HttpsConnection

java.lang.Object
  extended by net.jini.jeri.ssl.Utilities
      extended by net.jini.jeri.ssl.SslConnection
          extended by net.jini.jeri.ssl.HttpsEndpoint.HttpsConnection
All Implemented Interfaces:
HttpClientSocketFactory, Connection
Enclosing class:
HttpsEndpoint

private static final class HttpsEndpoint.HttpsConnection
extends SslConnection
implements HttpClientSocketFactory


Nested Class Summary
 
Nested classes/interfaces inherited from class net.jini.jeri.ssl.Utilities
Utilities.SSLContextInfo
 
Field Summary
private  HttpsEndpoint.HttpsEndpointImpl endpoint
          The associated endpoint.
private  HttpClientConnection httpClient
          The current HTTP client connection.
private  long idleTime
          The time this connection was found to be idle by the Reaper thread.
(package private)  String proxyHost
          The proxy host, or empty string if using a direct connection.
(package private)  int proxyPort
          The proxy port, ignored if using a direct connection.
 
Fields inherited from class net.jini.jeri.ssl.SslConnection
callContext, closed, port, serverHost, socketFactory, sslSocket, sslSocketFactory
 
Fields inherited from class net.jini.jeri.ssl.Utilities
ANY_KEY_ALGORITHM, clientLogger, DSA_KEY_ALGORITHM, getSubjectPermission, initLogger, INTEGRITY_PREFERRED, INTEGRITY_REQUIRED, RSA_KEY_ALGORITHM, serverLogger, UNKNOWN_PRINCIPAL
 
Constructor Summary
HttpsEndpoint.HttpsConnection(HttpsEndpoint.HttpsEndpointImpl endpoint, CallContext context, String serverHost, int port, String proxyHost, int proxyPort, SocketFactory socketFactory)
          Creates a connection.
 
Method Summary
(package private)  boolean checkIdle(long now)
          Returns true if the recorded idle time is more than IDLE_TIMEOUT milliseconds before now.
 void close()
          Closes this connection.
 Socket createSocket(String host, int port)
          Creates a plain socket to use to talk to the proxy host, else creates an SSL socket for a direct connection to the server.
 Socket createTunnelSocket(Socket s)
          Creates an SSL socket on top of the one the HTTP code used to connect through the proxy.
(package private)  void establishNewSocket()
          Attempts to create a new socket for the specified call context and cipher suites.
protected  String getProxyHost()
          Return the proxy host name.
(package private)  OutboundRequest newRequest(CallContext callContext)
          Uses the HTTPClientConnection to create an OutboundRequest object with the specified call context, and sets the idle time to 0.
(package private)  void noteIdle()
          Adds this connection to the set of idle connections recorded for the connection's endpoint.
private  boolean ping()
          Forward a ping request to the underlying HttpClientConnection.
private  Socket setSSLSocket(SSLSocket newSocket)
          Stores the new socket in the sslSocket field, does a handshake on it, and returns it.
(package private)  boolean usesHttpProxy()
          Return true if this connection is using an HTTP proxy.
 
Methods inherited from class net.jini.jeri.ssl.SslConnection
checkConnectPermission, createPlainSocket, establishCallContext, establishSuites, getChannel, getInputStream, getOutputStream, getUnfulfilledConstraints, populateContext, readResponseData, toString, useFor, writeRequestData
 
Methods inherited from class net.jini.jeri.ssl.Utilities
checkValidity, contains, doesEncryption, doesServerAuthentication, equals, firstX509Cert, getCertFactory, getCipherAlgorithm, getClassName, getClientPrincipals, getClientPrincipals, getClientSSLContextInfo, getKeyAlgorithm, getKeyExchangeAlgorithm, getPermittedKeyAlgorithms, getServerPrincipals, getServerSSLContextInfo, getSupportedCipherSuites, hasStrongCipherAlgorithm, logThrow, maintainsIntegrity, permittedKeyAlgorithm, position, releaseClientSSLContextInfo, safeEquals, subjectString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

endpoint

private final HttpsEndpoint.HttpsEndpointImpl endpoint
The associated endpoint.


proxyHost

final String proxyHost
The proxy host, or empty string if using a direct connection.


proxyPort

final int proxyPort
The proxy port, ignored if using a direct connection.


httpClient

private HttpClientConnection httpClient
The current HTTP client connection.


idleTime

private long idleTime
The time this connection was found to be idle by the Reaper thread. Set to zero each time a new request is initiated.

Constructor Detail

HttpsEndpoint.HttpsConnection

HttpsEndpoint.HttpsConnection(HttpsEndpoint.HttpsEndpointImpl endpoint,
                              CallContext context,
                              String serverHost,
                              int port,
                              String proxyHost,
                              int proxyPort,
                              SocketFactory socketFactory)
                        throws IOException
Creates a connection.

Throws:
IOException
Method Detail

establishNewSocket

void establishNewSocket()
                  throws IOException
Attempts to create a new socket for the specified call context and cipher suites.

Overrides:
establishNewSocket in class SslConnection
Throws:
SSLException - if the requested suites cannot be supported
IOException - if an I/O failure occurs

newRequest

OutboundRequest newRequest(CallContext callContext)
                     throws IOException
Uses the HTTPClientConnection to create an OutboundRequest object with the specified call context, and sets the idle time to 0.

Throws:
IOException

close

public void close()
           throws IOException
Description copied from interface: Connection
Closes this connection.

Specified by:
close in interface Connection
Overrides:
close in class SslConnection
Throws:
IOException - if an I/O exception occurs

checkIdle

boolean checkIdle(long now)
Returns true if the recorded idle time is more than IDLE_TIMEOUT milliseconds before now. If the recorded idle time is zero, sets the recorded idle time to now.


noteIdle

void noteIdle()
Adds this connection to the set of idle connections recorded for the connection's endpoint.


createSocket

public Socket createSocket(String host,
                           int port)
                    throws IOException
Creates a plain socket to use to talk to the proxy host, else creates an SSL socket for a direct connection to the server.

Specified by:
createSocket in interface HttpClientSocketFactory
Throws:
IOException

createTunnelSocket

public Socket createTunnelSocket(Socket s)
                          throws IOException
Creates an SSL socket on top of the one the HTTP code used to connect through the proxy.

Specified by:
createTunnelSocket in interface HttpClientSocketFactory
Throws:
IOException

setSSLSocket

private Socket setSSLSocket(SSLSocket newSocket)
                     throws IOException
Stores the new socket in the sslSocket field, does a handshake on it, and returns it.

Throws:
IOException

usesHttpProxy

boolean usesHttpProxy()
Return true if this connection is using an HTTP proxy.


ping

private boolean ping()
              throws IOException
Forward a ping request to the underlying HttpClientConnection.

Throws:
IOException

getProxyHost

protected String getProxyHost()
Return the proxy host name.

Overrides:
getProxyHost in class SslConnection


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