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 2012-2014 ForgeRock AS. 015 */ 016 017package org.forgerock.json.resource.http; 018 019import org.forgerock.services.context.Context; 020import org.forgerock.json.resource.ResourceException; 021 022/** 023 * A factory which is responsible for creating new request {@code Context}s for 024 * each JSON request. The returned context must include a 025 * {@link org.forgerock.services.context.RootContext} as its root and may include 026 * zero or more sub-contexts. 027 * <p> 028 * As an example, a context factory may return a context chain which includes 029 * authentication state information. 030 */ 031public interface HttpContextFactory { 032 033 /** 034 * Returns the context which should be used for the provided HTTP request. 035 * 036 * @param parent 037 * The parent context. 038 * @param request 039 * The HTTP request which is about to be processed. 040 * @return The context which should be used for the provided HTTP request. 041 * @throws ResourceException 042 * If a request context could not be obtained. 043 */ 044 Context createContext(Context parent, org.forgerock.http.protocol.Request request) throws ResourceException; 045}