f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay * The contents of this file are subject to the terms of the Common Development and
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay * Distribution License (the License). You may not use this file except in compliance with the
4c5b7dcefc02999147efb135d58ceb4c88fc7d7cMark de Reeper * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay * specific language governing permission and limitations under the License.
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay * When distributing Covered Software, include this CDDL Header Notice in each file and include
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay * Header, with the fields enclosed by brackets [] replaced by your own identifying
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay * information: "Portions copyright [year] [name of copyright owner]".
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay * Copyright 2014-2016 ForgeRock AS.
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport org.forgerock.openam.oauth2.OAuth2Constants.UrlLocation;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport static org.forgerock.openam.oauth2.OAuth2Constants.Params.RESPONSE_TYPE;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport static org.forgerock.openam.oauth2.OAuth2Constants.UrlLocation.*;
073875d677d0cc89aa2cc1187c975225a2ead9d3Phill Cunnington * Thrown when the requested scope is invalid, unknown, or malformed.
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay * @since 12.0.0
6a901ebad73ff7eae18de9ed218aa15187babca0Jonathan Scudderpublic class InvalidScopeException extends OAuth2Exception {
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay * Constructs a new InvalidScopeException with the default message.
8945f1b58614bdedf14efc01f9830688207cca04Phill Cunnington this("The requested scope is invalid, unknown, or malformed.");
756d4b8bce5a58e5bd8fe686688b6c42d2e7052bPhill Cunnington * Constructs a new InvalidScopeException with the specified message.
4c5b7dcefc02999147efb135d58ceb4c88fc7d7cMark de Reeper * The {@link UrlLocation} for the parameters are defaulted to QUERY.
4c5b7dcefc02999147efb135d58ceb4c88fc7d7cMark de Reeper * @param message The reason for the exception.
756d4b8bce5a58e5bd8fe686688b6c42d2e7052bPhill Cunnington public InvalidScopeException(final String message) {
7bc2a743f1c860eaeaa2a23d8981311d720d5004Phill Cunnington * Constructs a new InvalidScopeException with the specified message.
73c26b2cdf320b53fe8467cc81228e04e3c540c0Phill Cunnington * @param message The reason for the exception.
73c26b2cdf320b53fe8467cc81228e04e3c540c0Phill Cunnington * @param parameterLocation Indicates the location of the parameters in the URL.
7bc2a743f1c860eaeaa2a23d8981311d720d5004Phill Cunnington public InvalidScopeException(final String message, final UrlLocation parameterLocation) {
7bc2a743f1c860eaeaa2a23d8981311d720d5004Phill Cunnington super(400, "invalid_scope", message, parameterLocation);
7bc2a743f1c860eaeaa2a23d8981311d720d5004Phill Cunnington * Creates a new InvalidScopeException by deducing the UrlLocation from the OAuth2Request.
7bc2a743f1c860eaeaa2a23d8981311d720d5004Phill Cunnington * @param message The reason for the exception.
7bc2a743f1c860eaeaa2a23d8981311d720d5004Phill Cunnington * @param request The request from which we can work out what UrlLocation is needed.
7bc2a743f1c860eaeaa2a23d8981311d720d5004Phill Cunnington * @return The created exception.
7bc2a743f1c860eaeaa2a23d8981311d720d5004Phill Cunnington public static InvalidScopeException create(final String message, final OAuth2Request request) {
7bc2a743f1c860eaeaa2a23d8981311d720d5004Phill Cunnington final Set<String> responseTypes = Utils.splitResponseType(request.<String>getParameter(RESPONSE_TYPE));