Websphere MQ Everyplace

com.ibm.mqe.adapters
Class MQeWESAuthenticationAdapter

java.lang.Object
  |
  +--com.ibm.mqe.adapters.MQeCommunicationsAdapter
        |
        +--com.ibm.mqe.adapters.MQeTcpipAdapter
              |
              +--com.ibm.mqe.adapters.MQeWESAuthenticationAdapter
Direct Known Subclasses:
WESAuthenticationGUIAdapter

public class MQeWESAuthenticationAdapter
extends MQeTcpipAdapter

This adapter provides support for tunnelling HTTP requests through Websphere Everyplace authentication proxies and transparent proxies. This is a communications adapter that extends MQeTcpipHttpAdapter and, as such, can be used as a replacement for this - or any other - communications adapter. The adapter provides theWebSphere MQ Everyplace application with the static method setBasicAuthorization() in which the user can include user ID and password strings. Once set, each subsequent write call causes the class to add an authorization line to the HTTP header. This authorization line contains the user ID and password information which the adapter encodes to Base64.

For example: Authorization:Basic QmFzZTY0OmlzTm90RW5jcnlwdGVk

If an HTTP header that is supplied to the adapter write already contains an authorization line, the existing line is used. Note that basic Web authorization requires that the user’s credentials are encoded in Base64 inside the HTTP header. Note that this is not an encrypted format, Base64 is a clear text encoding, the contents of which can be viewed by anyone that has access to the HTTP flows. If you wish to avoid sending Base64 information unencrypted over a network, you need to provide a security solution such asWebSphere MQ Everyplace message level security.

The MQeWESAuthenticationAdapter also intercepts adapter reads, checking for the following invalid responses from the server:

  • Unauthorized (401), Forbidden (403) or Proxy Authentication Required (407) responses. The adapter throws an MQeException of type MQe.Except_Authenticate back to the application.
  • Not found responses (404). An MQeException of type MQe.Except_NotFound is thrown.
  • Server errors (50x) and all other client errors (40x). An MQeException of type MQe.Except_NotSupported is thrown.

    The text of all exceptions is the header line that contains the actual response type, for example "HTTP/1.1 500 Internal Server Error".

    After a failure response, the adapter scans the returned response header for any realm information. This information can be obtained later by using the static getRealm() method on the MQeWESAuthenticationAdapter.

    This class extends MQeTcpipAdapter.


    Field Summary
     
    Fields inherited from class com.ibm.mqe.adapters.MQeCommunicationsAdapter
    COMMS_ADAPTER_ADDRESS, COMMS_ADAPTER_CLASS, COMMS_ADAPTER_GROUP_SIZE, COMMS_ADAPTER_HTTP_VERSION, COMMS_ADAPTER_LISTEN, COMMS_ADAPTER_NONBLOCKING_TIMEOUT, COMMS_ADAPTER_NOPERSIST, COMMS_ADAPTER_PERSIST, COMMS_ADAPTER_PKTSIZE, COMMS_ADAPTER_PORT, COMMS_ADAPTER_RETRIES, COMMS_ADAPTER_SERVLET, COMMS_ADAPTER_TIMEOUT, COMMS_ADAPTER_VARIANCE, listeningAdapter, persistentAdapter, responderAdapter
     
    Constructor Summary
    MQeWESAuthenticationAdapter()
               
     
    Method Summary
     void activate(MQePropertyProvider info)
              Initializes the adapter.
    static java.lang.String getDeviceName()
              Returns the current originating device name.
    static java.lang.String getRealm()
              Determines the realm information, based on the challenge supplied by the server.
     byte[] read()
              Reads data coming from Websphere Everyplace.
    static void setBasicAuthorization(java.lang.String userid, java.lang.String password)
              The setBasicAuthorization method sets the userid and password that will be encoded in to Base64 and sent across the HTTP flow.
    static void setDeviceName(java.lang.String name)
              Sets the name of the originating device, as used by the User-Agent field in the HTTP requests.
     void writeData(byte[] data)
              Writes bytes to the HTTP stream.
     
    Methods inherited from class com.ibm.mqe.adapters.MQeTcpipAdapter
    close, open, readLength, readln, temporaryClose, waitForContact
     
    Methods inherited from class com.ibm.mqe.adapters.MQeCommunicationsAdapter
    createNewAdapter, isStopDemanded, isStopRequested, writeResponse
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    MQeWESAuthenticationAdapter

    public MQeWESAuthenticationAdapter()
    Method Detail

    setBasicAuthorization

    public static void setBasicAuthorization(java.lang.String userid,
                                             java.lang.String password)

    The setBasicAuthorization method sets the userid and password that will be encoded in to Base64 and sent across the HTTP flow.

    Returns:
    void

    setDeviceName

    public static void setDeviceName(java.lang.String name)

    Sets the name of the originating device, as used by the User-Agent field in the HTTP requests.

    Parameters:
    name - String representing the device name.
    Returns:
    void

    getDeviceName

    public static java.lang.String getDeviceName()

    Returns the current originating device name.

    Returns:
    String containing the device name

    getRealm

    public static java.lang.String getRealm()

    Determines the realm information, based on the challenge supplied by the server.

    Returns:
    A String representing the realm for which authentication is sought, or a blank string if no realm could be determined.

    activate

    public void activate(MQePropertyProvider info)
                  throws java.lang.Exception

    Initializes the adapter.

    When the adapter is being used as a transparent proxy, it also sets up the adapter’s proxy settings.

    Otherwise this method behaves like the MQeTcpipAdapter.

    Overrides:
    activate in class MQeTcpipAdapter
    Returns:
    void
    Throws:
    java.lang.Exception
    See Also:
    MQeCommunicationsAdapter.COMMS_ADAPTER_ADDRESS, MQeCommunicationsAdapter.COMMS_ADAPTER_PORT, MQeCommunicationsAdapter.COMMS_ADAPTER_LISTEN, MQeCommunicationsAdapter.COMMS_ADAPTER_TIMEOUT, MQeCommunicationsAdapter.COMMS_ADAPTER_PKTSIZE, MQeCommunicationsAdapter.COMMS_ADAPTER_RETRIES, com.ibm.mqe.adapters.MQeCommunicationsAdapter#COMMS_ADAPTER_THREAD_STOP_CHECK

    read

    public byte[] read()
                throws java.lang.Exception

    Reads data coming from Websphere Everyplace.

    The authentication server will only ever send a standard HTTP response, so we can use the superclass to do the reading for us. However, this method interprets any failure response codes and converts them into an appropriate MQeException.

    Specified by:
    read in class MQeCommunicationsAdapter
    Returns:
    byte[] A byte array that contains the data that was read.
    Throws:
    MQeException -
  • MQe.Except_Authenticate for Unauthorized (401), Forbidden (403) or proxy authentication required (407) responses.
  • MQe.Except_NotFound for "not found" responses (404).
  • MQe.Except_NotSupported for server errors (50x) and all other client errors (40x).
    java.lang.Exception

  • writeData

    public void writeData(byte[] data)
                   throws java.lang.Exception

    Writes bytes to the HTTP stream.

    Adds the WWW-Authenticate line to the user data before passing it on to the underlying HTTP adapter.

    Specified by:
    writeData in class MQeCommunicationsAdapter
    Parameters:
    data - byte[] The data to be written.
    Returns:
    void
    Throws:
    java.lang.Exception

    Websphere MQ Everyplace