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.openid.connect.sdk.op; 019 020 021import java.net.MalformedURLException; 022import java.net.URI; 023import java.net.URL; 024 025import com.nimbusds.oauth2.sdk.AbstractRequest; 026import com.nimbusds.oauth2.sdk.SerializeException; 027import com.nimbusds.oauth2.sdk.http.HTTPRequest; 028import com.nimbusds.oauth2.sdk.id.Issuer; 029import com.nimbusds.oauth2.sdk.util.URIUtils; 030import net.jcip.annotations.Immutable; 031 032 033/** 034 * OpenID Provider (OP) configuration request. 035 * 036 * <p>Example HTTP request: 037 * 038 * <pre> 039 * GET /.well-known/openid-configuration HTTP/1.1 040 * Host: example.com 041 * </pre> 042 * 043 * <p>Related specifications: 044 * 045 * <ul> 046 * <li>OpenID Connect Discovery 1.0, section 4.1. 047 * </ul> 048 */ 049@Immutable 050public class OIDCProviderConfigurationRequest extends AbstractRequest { 051 052 053 /** 054 * The well-known path for OpenID Provider metadata. 055 */ 056 public static final String OPENID_PROVIDER_WELL_KNOWN_PATH = "/.well-known/openid-configuration"; 057 058 059 /** 060 * Creates a new OpenID Provider configuration request. 061 * 062 * @param issuer The issuer. Must represent a valid URL. 063 */ 064 public OIDCProviderConfigurationRequest(final Issuer issuer) { 065 super(URI.create(URIUtils.removeTrailingSlash(URI.create(issuer.getValue())) + OPENID_PROVIDER_WELL_KNOWN_PATH)); 066 } 067 068 069 @Override 070 public HTTPRequest toHTTPRequest() { 071 072 URL url; 073 074 try { 075 url = getEndpointURI().toURL(); 076 077 } catch (IllegalArgumentException | MalformedURLException e) { 078 079 throw new SerializeException(e.getMessage(), e); 080 } 081 082 return new HTTPRequest(HTTPRequest.Method.GET, url); 083 } 084}