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.net.URI; 022import java.security.Principal; 023 024import org.forgerock.openig.util.ExtensibleFieldMap; 025 026/** 027 * An HTTP exchange of request and response, and the root object for the exchange object model. 028 * The exchange object model parallels the document object model, exposing elements of the 029 * exchange. It supports this by exposing its fixed attributes and allowing arbitrary 030 * attributes via its {@code ExtensibleFieldMap} superclass. 031 * <p> 032 * The contract of an exchange is such that it is the responsibility of the caller of a 033 * {@link org.forgerock.openig.handler.Handler} object to create and populate the request object, 034 * and responsibility of the handler to create and populate the response object. 035 * <p> 036 * If an existing response object exists in the exchange and the handler intends to replace 037 * it with another response object, it must first check to see if the existing response 038 * object has an entity, and if it does, must call its {@code close} method in order to signal 039 * that the processing of the response from a remote server is complete. 040 */ 041public class Exchange extends ExtensibleFieldMap { 042 043 /** Self-referential value to make this the root object in the exchange object model. */ 044 public Exchange exchange = this; 045 046 /** The request portion of the HTTP exchange. */ 047 public Request request; 048 049 /** The response portion of the HTTP exchange. */ 050 public Response response; 051 052 /** The principal associated with the request, or {@code null} if unknown. */ 053 public Principal principal; 054 055 /** Session context associated with the remote client. */ 056 public Session session; 057 058 /** The info we can obtain from the client from this request. */ 059 public ClientInfo clientInfo; 060 061 /** 062 * The original message's URI, as received by the web container. This value is set by the receiving servlet and 063 * is immutable. 064 */ 065 public final URI originalUri; 066 067 /** 068 * Builds a new Exchange without any originalUri value (will be {@code null}). 069 */ 070 public Exchange() { 071 this(null); 072 } 073 074 /** 075 * Builds a new Exchange with the given originalUri value (can be {@code null}). 076 * 077 * @param originalUri 078 * original message's URI, as received by the web container 079 */ 080 public Exchange(final URI originalUri) { 081 this.originalUri = originalUri; 082 } 083}