com.sun.grizzly.http.portunif
Class HttpRedirector

java.lang.Object
  extended by com.sun.grizzly.http.portunif.HttpRedirector

public class HttpRedirector
extends Object

Utility class used to redirect an HTTP(s) request to another protocol and endpoint. The following scenarios are supported: (1) http://host:port1 to https://host:port1 (2) https://host:port1 to http://host:port1 (3) http://host:port2 to https://host:port1 (4) https://host:port2 to https://host:port1 (5) http://host:port2 to http://host:port1 (6) https://host:port2 to http://host:port1 This class internally start an NIO Selector listening on an 'external' port to a 'redirect' port. All requests to the external port, independently of the protocol are redirected to the 'redirect' port.

Author:
Jeanfrancois Arcand

Method Summary
static void redirect(Context context, ByteBuffer byteBuffer, Integer redirectPort, boolean redirectToSecure)
          Redirect a un-secure request (http) to http or https.
static void redirect(Context context, PUProtocolRequest protocolRequest)
          Redirect a un-secure request (http) to http or https.
static void redirect(Context context, PUProtocolRequest protocolRequest, boolean redirectToSecure)
          Redirect a un-secure request (http) to http or https.
static void redirectSSL(Context context, PUProtocolRequest protocolRequest)
          Redirect a secure request (https) to http or https.
static void redirectSSL(Context context, PUProtocolRequest protocolRequest, boolean redirectToSecure)
          Redirect a secure request (https) to http or https.
static void redirectSSL(Context context, SSLEngine sslEngine, ByteBuffer byteBuffer, ByteBuffer outputBB, Integer redirectPort, boolean redirectToSecure)
          Redirect a secure request (https) to http or https.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

redirectSSL

public static void redirectSSL(Context context,
                               PUProtocolRequest protocolRequest)
                        throws IOException
Redirect a secure request (https) to http or https.

Parameters:
context - Context of the current SelectionKey event
protocolRequest - PortUnification protocol request information
Throws:
IOException

redirectSSL

public static void redirectSSL(Context context,
                               PUProtocolRequest protocolRequest,
                               boolean redirectToSecure)
                        throws IOException
Redirect a secure request (https) to http or https.

Parameters:
context - Context of the current SelectionKey event
protocolRequest - PortUnification protocol request information
redirectToSecure - if true - request will be redirected to HTTPS protocol, otherwise HTTP
Throws:
IOException

redirectSSL

public static void redirectSSL(Context context,
                               SSLEngine sslEngine,
                               ByteBuffer byteBuffer,
                               ByteBuffer outputBB,
                               Integer redirectPort,
                               boolean redirectToSecure)
                        throws IOException
Redirect a secure request (https) to http or https.

Parameters:
context - Context of the current SelectionKey event
sslEngine - the sslEngine servicing the current request
byteBuffer - input buffer
outputBB - output buffer
redirectPort - the port to redirect to. If not specified, the port of the current socket will be used
redirectToSecure - if true, the request will be redirected using the HTTPS protocol, otherwise HTTP
Throws:
IOException

redirect

public static void redirect(Context context,
                            PUProtocolRequest protocolRequest)
                     throws IOException
Redirect a un-secure request (http) to http or https.

Parameters:
context - Context of the current SelectionKey event
protocolRequest - PortUnification protocol request information
Throws:
IOException

redirect

public static void redirect(Context context,
                            PUProtocolRequest protocolRequest,
                            boolean redirectToSecure)
                     throws IOException
Redirect a un-secure request (http) to http or https.

Parameters:
context - Context of the occured SelectionKey event
protocolRequest - PortUnification protocol request information
redirectToSecure - if true - request will be redirected to HTTPS protocol, otherwise HTTP
Throws:
IOException

redirect

public static void redirect(Context context,
                            ByteBuffer byteBuffer,
                            Integer redirectPort,
                            boolean redirectToSecure)
                     throws IOException
Redirect a un-secure request (http) to http or https.

Parameters:
context - Context of the current SelectionKey event
byteBuffer - input buffer
redirectPort - the port to redirect to. If not specified, the port of the current socket will be used
redirectToSecure - if true - request will be redirected to HTTPS protocol, otherwise HTTP
Throws:
IOException


Copyright © 2012 Oracle Corporation. All Rights Reserved.