001package com.nimbusds.oauth2.sdk.client;
002
003
004import com.nimbusds.oauth2.sdk.ParseException;
005import com.nimbusds.oauth2.sdk.Response;
006import com.nimbusds.oauth2.sdk.http.HTTPResponse;
007
008
009/**
010 * The base abstract for client registration responses.
011 *
012 * <p>Related specifications:
013 *
014 * <ul>
015 *     <li>OAuth 2.0 Dynamic Client Registration Protocol 
016 *         (draft-ietf-oauth-dyn-reg-12), section 5.
017 * </ul>
018 *
019 * @author Vladimir Dzhuvinov
020 */
021public abstract class ClientRegistrationResponse implements Response {
022
023
024        /**
025         * Parses a client registration response from the specified HTTP 
026         * response.
027         *
028         * @param httpResponse The HTTP response. Must not be {@code null}.
029         *
030         * @return The client registration response.
031         *
032         * @throws ParseException If the HTTP response couldn't be parsed to a
033         *                        client registration response.
034         */
035        public static ClientRegistrationResponse parse(final HTTPResponse httpResponse)
036                throws ParseException {
037                
038                if (httpResponse.getStatusCode() == HTTPResponse.SC_OK)
039                        return ClientInformationResponse.parse(httpResponse);
040                else
041                        return ClientRegistrationErrorResponse.parse(httpResponse);
042        }
043}