001/* 002 * oauth2-oidc-sdk 003 * 004 * Copyright 2012-2016, Connect2id Ltd and contributors. 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use 007 * this file except in compliance with the License. You may obtain a copy of the 008 * License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software distributed 013 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 014 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 015 * specific language governing permissions and limitations under the License. 016 */ 017 018package com.nimbusds.oauth2.sdk; 019 020 021import java.net.URI; 022 023import com.nimbusds.oauth2.sdk.http.HTTPRequest; 024import com.nimbusds.oauth2.sdk.util.URIUtils; 025 026 027/** 028 * The base abstract class for OAuth 2.0 and OpenID Connect configuration 029 * requests. 030 */ 031public abstract class AbstractConfigurationRequest extends AbstractRequest { 032 033 034 /** 035 * Creates a new base abstract request. 036 * 037 * @param baseURI The base URI. Must not be {@code null}. 038 * @param wellKnownPath The well known path to prepend to any existing 039 * path component in the base URI. Must not be 040 * {@code null}. 041 * @param strategy The well-known path composition strategy. Must 042 * not be {@code null}. 043 */ 044 public AbstractConfigurationRequest(final URI baseURI, final String wellKnownPath, final WellKnownPathComposeStrategy strategy) { 045 046 super(WellKnownPathComposeStrategy.POSTFIX.equals(strategy) ? 047 URI.create(URIUtils.removeTrailingSlash(baseURI) + wellKnownPath) : 048 URIUtils.prependPath(baseURI, wellKnownPath)); 049 } 050 051 052 @Override 053 public HTTPRequest toHTTPRequest() { 054 055 return new HTTPRequest(HTTPRequest.Method.GET, getEndpointURI()); 056 } 057}