001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2009 Sun Microsystems Inc.
015 * Portions Copyright 2010–2011 ApexIdentity Inc.
016 * Portions Copyright 2011-2014 ForgeRock AS.
017 */
018
019package org.forgerock.openig.http;
020
021import java.security.Principal;
022
023import org.forgerock.openig.util.ExtensibleFieldMap;
024
025/**
026 * An HTTP exchange of request and response, and the root object for the exchange object model.
027 * The exchange object model parallels the document object model, exposing elements of the
028 * exchange. It supports this by exposing its fixed attributes and allowing arbitrary
029 * attributes via its {@code ExtensibleFieldMap} superclass.
030 * <p>
031 * The contract of an exchange is such that it is the responsibility of the caller of a
032 * {@link org.forgerock.openig.handler.Handler} object to create and populate the request object,
033 * and responsibility of the handler to create and populate the response object.
034 * <p>
035 * If an existing response object exists in the exchange and the handler intends to replace
036 * it with another response object, it must first check to see if the existing response
037 * object has an entity, and if it does, must call its {@code close} method in order to signal
038 * that the processing of the response from a remote server is complete.
039 */
040public class Exchange extends ExtensibleFieldMap {
041
042    /** Self-referential value to make this the root object in the exchange object model. */
043    public Exchange exchange = this;
044
045    /** The request portion of the HTTP exchange. */
046    public Request request;
047
048    /** The response portion of the HTTP exchange. */
049    public Response response;
050
051    /** The principal associated with the request, or {@code null} if unknown. */
052    public Principal principal;
053
054    /** Session context associated with the remote client. */
055    public Session session;
056}