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.ClientRegistrationErrorResponse; 008import com.nimbusds.oauth2.sdk.client.ClientRegistrationResponse; 009import com.nimbusds.oauth2.sdk.http.HTTPResponse; 010 011 012/** 013 * Parser of OpenID Connect client registration response messages. 014 * 015 * <p>Related specifications: 016 * 017 * <ul> 018 * <li>OpenID Connect Dynamic Client Registration 1.0, section 3.2 and 3.3. 019 * <li>OAuth 2.0 Dynamic Client Registration Protocol 020 * (draft-ietf-oauth-dyn-reg-14), section 3.2, 4.3 and 5. 021 * </ul> 022 */ 023@Immutable 024public class OIDCClientRegistrationResponseParser { 025 026 027 /** 028 * Parses an OpenID Connect client registration response from the 029 * specified HTTP response. 030 * 031 * @param httpResponse The HTTP response. Must not be {@code null}. 032 * 033 * @return The OpenID Connect client registration response. 034 * 035 * @throws ParseException If the HTTP response couldn't be parsed to an 036 * OpenID Connect client registration response. 037 */ 038 public static ClientRegistrationResponse parse(final HTTPResponse httpResponse) 039 throws ParseException { 040 041 if (httpResponse.getStatusCode() == HTTPResponse.SC_OK) 042 return OIDCClientInformationResponse.parse(httpResponse); 043 else 044 return ClientRegistrationErrorResponse.parse(httpResponse); 045 } 046 047 048 /** 049 * Prevents public instantiation. 050 */ 051 private OIDCClientRegistrationResponseParser() { } 052}