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.rp;
019
020
021import net.jcip.annotations.Immutable;
022
023import com.nimbusds.oauth2.sdk.ParseException;
024import com.nimbusds.oauth2.sdk.client.ClientInformationResponse;
025import com.nimbusds.oauth2.sdk.http.HTTPResponse;
026
027
028/**
029 * OpenID Connect client information response.
030 *
031 * <p>Example HTTP response:
032 *
033 * <pre>
034 * HTTP/1.1 200 OK
035 * Content-Type: application/json
036 * Cache-Control: no-store
037 * Pragma: no-cache
038 *
039 * {
040 *  "client_id"                       : "s6BhdRkqt3",
041 *  "client_secret"                   :"ZJYCqe3GGRvdrudKyZS0XhGv_Z45DuKhCUk0gBR1vZk",
042 *  "client_secret_expires_at"        : 1577858400,
043 *  "registration_access_token"       : "this.is.an.access.token.value.ffx83",
044 *  "registration_client_uri"         : "https://server.example.com/connect/register?client_id=s6BhdRkqt3",
045 *  "token_endpoint_auth_method"      : "client_secret_basic",
046 *  "application_type"                : "web",
047 *  "redirect_uris"                   : ["https://client.example.org/callback","https://client.example.org/callback2"],
048 *  "client_name"                     : "My Example",
049 *  "client_name#ja-Jpan-JP"          : "クライアント名",
050 *  "logo_uri"                        : "https://client.example.org/logo.png",
051 *  "subject_type"                    : "pairwise",
052 *  "sector_identifier_uri"           : "https://other.example.net/file_of_redirect_uris.json",
053 *  "jwks_uri"                        : "https://client.example.org/my_public_keys.jwks",
054 *  "userinfo_encrypted_response_alg" : "RSA1_5",
055 *  "userinfo_encrypted_response_enc" : "A128CBC-HS256",
056 *  "contacts"                        : ["[email protected]", "[email protected]"],
057 *  "request_uris"                    : ["https://client.example.org/rf.txt#qpXaRLh_n93TTR9F252ValdatUQvQiJi5BDub2BeznA"]
058 * }
059 * </pre>
060 *
061 * <p>Related specifications:
062 *
063 * <ul>
064 *     <li>OpenID Connect Dynamic Client Registration 1.0, section 3.2 and 4.3.
065 *     <li>OAuth 2.0 Dynamic Client Registration Management Protocol (RFC
066 *         7592), section 3.
067 *     <li>OAuth 2.0 Dynamic Client Registration Protocol (RFC 7591), section
068 *         3.2.1.
069 * </ul>
070 */
071@Immutable
072public class OIDCClientInformationResponse extends ClientInformationResponse {
073        
074        
075        /**
076         * Creates a new OpenID Connect client information response.
077         *
078         * @param clientInfo The OpenID Connect client information. Must not be
079         *                   {@code null}.
080         */
081        public OIDCClientInformationResponse(final OIDCClientInformation clientInfo) {
082
083                super(clientInfo);
084        }
085        
086        
087        /**
088         * Gets the OpenID Connect client information.
089         *
090         * @return The OpenID Connect client information.
091         */
092        public OIDCClientInformation getOIDCClientInformation() {
093
094                return (OIDCClientInformation)getClientInformation();
095        }
096        
097        
098        /**
099         * Parses an OpenID Connect client information response from the 
100         * specified HTTP response.
101         *
102         * @param httpResponse The HTTP response. Must not be {@code null}.
103         *
104         * @return The OpenID Connect client information response.
105         *
106         * @throws ParseException If the HTTP response couldn't be parsed to an
107         *                        OpenID Connect client information response.
108         */
109        public static OIDCClientInformationResponse parse(final HTTPResponse httpResponse)
110                throws ParseException {
111
112                httpResponse.ensureStatusCode(HTTPResponse.SC_OK, HTTPResponse.SC_CREATED);
113                OIDCClientInformation clientInfo = OIDCClientInformation.parse(httpResponse.getContentAsJSONObject());
114                return new OIDCClientInformationResponse(clientInfo);
115        }
116}