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 2016 ForgeRock AS. 015 */ 016 017package org.forgerock.http.oauth2; 018 019import java.util.Set; 020 021import org.forgerock.http.protocol.Request; 022import org.forgerock.http.protocol.ResponseException; 023import org.forgerock.services.context.Context; 024 025/** A {@link ResourceAccess} encapsulates the logic of required scope selection. */ 026public interface ResourceAccess { 027 028 /** 029 * Returns the scopes required to access the resource. 030 * 031 * @param context 032 * The current context which might be used to retrieve required scopes. 033 * @param request 034 * The current OAuth2 request which might be used to retrieve required scopes. 035 * @return Scopes required to access the resource. Should never return {@code null}. 036 * @throws ResponseException 037 * If an error occurred while resolving scope set 038 */ 039 Set<String> getRequiredScopes(final Context context, final Request request) throws ResponseException; 040}