001package com.nimbusds.openid.connect.provider.spi.tokens;
002
003
004import com.nimbusds.oauth2.sdk.id.Identifier;
005import net.jcip.annotations.ThreadSafe;
006
007
008/**
009 * Service Provider Interface (SPI) for generating and decoding
010 * identifier-based access tokens. Implementations must be thread-safe.
011 */
012@ThreadSafe
013public interface IdentifierAccessTokenCodec {
014        
015        
016        /**
017         * Generates a new identifier-based access token.
018         *
019         * @param tokenAuthz The access token authorisation. Not {@code null}.
020         * @param context    The token encoder context. Not {@code null}.
021         *
022         * @return The identifier-based access token.
023         */
024        IdentifierAccessToken generate(final AccessTokenAuthorization tokenAuthz, final TokenEncoderContext context);
025        
026        
027        /**
028         * Decodes the specified bearer access token value to extract the token
029         * identifier.
030         *
031         * @param tokenValue The bearer access token value. Not {@code null}.
032         * @param context    The token codec context. Not {@code null}.
033         *
034         * @return The access token identifier.
035         *
036         * @throws TokenDecodeException If decoding failed.
037         */
038        Identifier decode(final String tokenValue, final TokenCodecContext context)
039                throws TokenDecodeException;
040}