001package com.nimbusds.openid.connect.provider.spi.tokens.response;
002
003
004import com.nimbusds.oauth2.sdk.TokenResponse;
005
006
007/**
008 * Service Provider Interface (SPI) for composing custom token responses.
009 * Implementations must be thread-safe.
010 *
011 * <p>This SPI can be used to include additional parameters in the token
012 * response, such as an {@code authorization_details} parameter required in
013 * OAuth 2.0 Rich Authorization Requests.
014 */
015public interface CustomTokenResponseComposer {
016        
017        
018        /**
019         * Composes a custom token response.
020         *
021         * @param originalResponse The original success or error response. For
022         *                         an OpenID token response an instance of
023         *                         {@link com.nimbusds.openid.connect.sdk.OIDCTokenResponse}.
024         *                         Not {@code null}.
025         * @param context          The token response context. Not
026         *                         {@code null}.
027         *
028         * @return The token response to return to the client. If no
029         *         customisation is required the original response.
030         */
031        TokenResponse compose(final TokenResponse originalResponse, final TokenResponseContext context);
032}