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