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